UnityShader学习

UnityShader学习

 

 效果:UnityShader学习

 

笔记:

UnityShader学习

 

 UnityShader学习

 

 UnityShader学习

 

 

 代码:

Shader "Unlit/001"
{
    Properties
    {
        _Int("Int",Int) = 4
        _Float("Float",Float) = 1.0
        _Color("Color",color) = (0,0,0,0)
        _Vector("Vector",Vector) = (1,3,5,6)
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #include "UnityCG.cginc"


            fixed4 _Color;
            
            struct a2v   //application to vert
            {
                //用模型顶点填充v变量
                float4 vertex: POSITION;
                //用模型法线填充n变量
                float3 normal: NORMAL;
                //用模型第一套uv填充texcoord变量
                float4 texcoord:TEXCOORD0;
            };

            struct v2f
            {
                float4 pos:SV_POSITION;
                fixed3 color : COLOR0;
            };

            v2f vert(appdata_base v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.color = v.normal * 0.5 + fixed3(0.5,0.5,0.5);
                return o;
            }

            fixed4 frag(v2f i):SV_TARGET
            {
                fixed3 c = i.color;
                c *= _Color.rgb;
                return fixed4(c,0.1);
            }
            
            ENDCG
        }
    }
}

 

上一篇:CSS OM


下一篇:php实现浏览器端大文件分块上传