简单轮廓光
用于untiy的简单轮廓光.笔记
Shader "Level4/Rim/SimpleRim" {Properties {_MainTex ("Base (RGB)", 2D) = "white" {}_RimColor("Rim Color",color) = (1,1,1,1)_RimPower("Rim Power",float) = 2_Atten("Atten",float) = 2}SubShader {Tags { "RenderType"="Opaque" }LOD 200CGPROGRAM#pragma surface surf HalfLambertRimsampler2D _MainTex;half4 _RimColor;half _RimPower;half _Atten;struct Input {float2 uv_MainTex;};inline fixed4 LightingHalfLambertRim(SurfaceOutput s,half3 lightDir,half3 viewDir,half atten){half3 halfVector = normalize(lightDir+viewDir);fixed NdotL = max(0,dot(s.Normal,lightDir));fixed NdotE = max(0,dot(s.Normal,viewDir));fixed NdotH = max(0,dot(s.Normal,halfVector));fixed EdotH = max(0,dot(viewDir,halfVector));fixed halfLambert = pow(NdotL * 0.5 + 0.5,2);fixed rimLight = 1 - NdotE;rimLight = pow(rimLight,_RimPower) * NdotH;fixed4 c;c.rgb = (s.Albedo * _LightColor0.rgb + rimLight.xxx * _RimColor) * (halfLambert * atten * _Atten);c.a = s.Alpha;return c;}void surf (Input IN, inout SurfaceOutput o) {half4 c = tex2D (_MainTex, IN.uv_MainTex);o.Albedo = c.rgb;o.Alpha = c.a;}ENDCG} FallBack "Diffuse"}尝试改变 _RimColor,_RimPower,_Atten来查看效果.