Game Development Reference
In-Depth Information
};
}
We can see that we put exclude_path:prepass after the #pragma line.
This means that this lighting model will only work on the forward lighting (no de-
ferred lighting). This is because we don't have the angle between the light direc-
tion and normal to calculate in the prepass, which is needed for the deferred light-
ing.
3. Add the following highlighted code inside the surf() function to create the
Rim Light effect using Emission :
void surf (Input IN, inout SurfaceOutput o) {
o.Normal = UnpackNormal (tex2D (_BumpMap,
IN.uv_BumpMap));
fixed rim = 1.0 - saturate(dot
(normalize(IN.viewDir), o.Normal));
o.Emission = (_RimColor.rgb * pow (rim,
_RimPower));
}
4. Finally, go to the custom lighting function LightingRampSpecular() . In
this, we will calculate the diffuse color by using the Half Lambert or Warp
Lambert method to get the lighting warp around our model. Then, we get the
ramp texture from the property and multiply it with the light color and our main
color texture. Let's modify and add the following code:
inline fixed4 LightingRampSpecular (SurfaceOutput s,
fixed3 lightDir, fixed3 viewDir, fixed atten) {
//Ambient
fixed3 ambient = s.Albedo * _AmbientColor.rgb;
//Ramp - Diffuse (Half Lambert)
fixed NdotL = saturate(dot (s.Normal, lightDir));
fixed halfLambert = NdotL * 0.5 + 0.5;
fixed3 ramp = tex2D(_Ramp, float2(halfLambert,
halfLambert)).rgb;
fixed3 diffuse = s.Albedo * _LightColor0.rgb * ramp;
//Specular
Search WWH ::




Custom Search