自定义兰伯特

来源:互联网 发布:大数据龙头股雪球 编辑:程序博客网 时间:2024/06/11 00:57
Shader "Custom/Silhouette" {    Properties {        _MainTex ("Main Tex", 2D) = "white" {}        _DotProduct("Normal intensity",Range(-1,1))=0.25    }    SubShader {        Tags { "Queue"="Transparent" "IngnoreProjector"="True" "RenderType"="Transparent" }        LOD 200        CGPROGRAM        // Physically based Standard lighting model, and enable shadows on all light types        #pragma surface surf SimpleLambert alpha:fade nolighting        // Use shader model 3.0 target, to get nicer looking lighting        #pragma target 3.0        sampler2D _MainTex;        struct Input {            float2 uv_MainTex;            float3 worldNormal;            float3 viewDir;        };        float4 LightingSimpleLambert(inout SurfaceOutput s,half3 lightDir,half atten)        {            half NdotL = dot(s.Normal,lightDir);            half4 c;            //unity5 光照强度增大2倍             c.rgb = s.Albedo*_LightColor0.rgb*(NdotL*atten*1);            c.a = s.Alpha;            return c;        }        float _DotProduct;        void surf (Input IN, inout SurfaceOutput o) {            fixed4 c = tex2D(_MainTex,IN.uv_MainTex);            o.Albedo = c.rgb;            float border = 1-(abs(dot(IN.viewDir,IN.worldNormal)));            float alpha = (border*(1-_DotProduct)+_DotProduct);            o.Alpha = c.a*alpha;        }        ENDCG    }    FallBack "Diffuse"}
0 0
原创粉丝点击