Game Development Reference
In-Depth Information
fixed diff = NdotL * 0.5 + 0.5;
Note
Half Lambert lighting is a technique first developed in the original
Half-Life
. It is de-
signed to prevent the rear of an object from losing its shape and looking too flat. Half
Lambert is a completely non-physical technique and gives a purely perceived visual en-
hancement and is an example of a forgiving lighting model.
This reference is taken from
http://developer.valvesoftware.com/wiki/Half_Lambert
.
We can see the difference between each lighting model in the following diagram:
Next, we used
halfLambert
to calculate the ramp texture,
_Ramp
, to get the color res-
ult using the
tex2D()
function, as follows:
fixed3 ramp = tex2D (_Ramp, float2(halfLambert,
halfLambert)).rgb;
Then, we multiplied this value with the diffuse color and light color, as follows:
fixed3 rampDiffuse = s.Albedo * _LightColor0.rgb * ramp;
We will get a result that is different from the previous section, as shown in the following
screenshot: