The previous article, which halflambert the custom illumination, is similar to this one, but when it is calculated, it is no longer multiplied by the direction and Atten.
The Halflam of the light incident direction and the point product of the method are used as coordinates, and the RGB values of the Ramptexture (Halflam,halflam) points are found as the mixed values multiplied by the albedo and incident light colors of S.
The code is as follows:
Shader"CUSTOM/11.26/2"{properties{_ramptex ("Ramp Texture", 2D) =" White"{} _maintex ("Ramp Texture", 2D) =" White"{}}subshader{tags{"Rendertype"="Opaque"} LOD $Cgprogram#pragmaSurface Surf Rampsampler2d _ramptex; Sampler2d _maintex; structinput{FLOAT2 Uv_maintex; }; voidSurf (Input in,inout surfaceoutput o) {half4 c=tex2d (_maintex,in.uv_maintex); O.albedo=C.rgb; O.alpha=C.A; } inline Float4 Lightingramp (surfaceoutput s,fixed3 lightdir,fixedatten) { floatlightdif=dot (s.normal,lightdir); floathalflam=0.5*lightdif+0.5; FLOAT3 Ramp=tex2d (_RAMPTEX,FLOAT2 (Halflam,halflam)). RGB; Float4 Col; Col.rgb=s.albedo*_lightcolor0.rgb*ramp; COL.A=S.alpha; returnCol; } endcg}fallback"Diffuse"}
:
[Xiao Ming learns shader] 4. Custom Lighting----Ramptexture