自定义简单高光模型

Shader "Custom/SimpleSpecular" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf SimpleSpeclar

        sampler2D _MainTex;

        half4 LightingSimpleSpeclar(SurfaceOutput s,half3 lightDir,half3 viewDir,half atten)
        {
            half3 h = normalize(lightDir+viewDir);

            half diff = max(0,dot(s.Normal,lightDir));

            float nh = max(0,dot(s.Normal,h));

            float spec = pow(nh,48.0);

            half4 c;

            c.rgb = (s.Albedo*_LightColor0.rgb*diff+_LightColor0.rgb*spec)*(atten*2);
            c.a = s.Alpha;
            return c;
        }

        struct Input {
            float2 uv_MainTex;
        };

        void surf (Input IN, inout SurfaceOutput o) {
            half4 c = tex2D (_MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb;
        }
        ENDCG
    } 
    FallBack "Diffuse"
}

你可能感兴趣的:(unity3d)