您的位置:首页 > 其它

渐变纹理模拟光照

2016-10-12 10:37 211 查看
Shader "Custom/Toon" {
Properties {
_MainTex ("Main Tex", 2D) = "white" {}
_RampTex("Ramp Tex",2D)=""{}
}
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 Toon alpha:fade nolighting

// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0

sampler2D _MainTex;
sampler2D _RampTex;
struct Input {
float2 uv_MainTex;
};

fixed4 LightingToon(SurfaceOutput s,fixed3 lightDir,fixed atten)
{
half NdotL = dot(s.Normal,lightDir);
fixed4 col = tex2D(_RampTex,fixed2(NdotL,0.5));

fixed4 c;
c.rgb = s.Albedo*_LightColor0.rgb*col*atten;
c.a = s.Alpha;
return c;
}
void surf (Input IN, inout SurfaceOutput o) {

fixed4 c = tex2D(_MainTex,IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: