模板

作者: Rayson | 来源:发表于2020-06-18 22:04 被阅读0次
    // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
    
    // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
    
    Shader "Custom/testShader" {
     properties{
        _TextureSample0("Texture Sample 0", 2D) = "white" {}
        _normal("normal", 2D) = "white" {}
     }
     subshader {
        pass{
            Tags{ "RenderType" = "Opaque" "IsEmissive" = "true"  }
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag 
             #include "Lighting.cginc"
             
    
    
             uniform sampler2D _TextureSample0;
             uniform sampler2D _normal;
             uniform float4 _normal_ST;
    
             struct a2v
             {
                 float3 vertex : POSITION;        
                 float3 normal : NORMAL;                  
                 float4 texcoord : TEXCOORD0;      
             };
    
             struct v2f
             {
                 float4 pos : SV_POSITION;           //告诉unity,pos里包含了顶点在裁剪空间中的位置信息
                 fixed3 worldNormal:TEXCOORD0;
                 
             };
    
               v2f vert(a2v v)
               {
                  v2f o;
                  o.pos = UnityObjectToClipPos(v.vertex);       //使用v.vertex来访问模型空间的顶点坐标
                  o.worldNormal=mul(v.normal,(float3x3)unity_WorldToObject);
                  return o ;
               }
    
                fixed4 frag() : SV_Target
                {
    
                       return fixed4(1.0, 1.0, 1.0, 1.0);
                }
                ENDCG
        }
     }
    }
    

    相关文章

      网友评论

          本文标题:模板

          本文链接:https://www.haomeiwen.com/subject/dlvpxktx.html