Game Development Reference
In-Depth Information
In Unity, we can choose three types of
Rendering Paths
:
Vertex Lit
,
Forward
, and
Deferred Lighting
.
Vertex Lit
is basically the lowest lighing
quality and doesn't support any real-ime shadows.
Forward
is shader-
based, which is the default seing in Unity and only supports real-ime
shadow from one direcional light.
Deferred Lighting
is the rendering path
with the most lighing and shadow quality, which is only for the Unity Pro
with no support on mobile devices. We can get more informaion about the
Rendering Path
from the following website:
http://unity3d.com/support/documentation/Manual/
RenderingPaths.html
Next, we add
half3 viewDir;
in
struct Input {}
, which will allow us to get the user
view direcion vector. This parameter will be used to calculate the specular relecion on
our model.
Inside the
surf()
funcion, we calculated the rim power or the brightness of our
backlight, which is
fixed rim = 1.0 - saturate(dot (normalize(IN.viewDir),
o.Normal));
by using the saturaion of the dot product of the view direcion normalize
and surface normals. In the next line (
o.Emission = (_RimColor.rgb * pow (rim, _
RimPower));
), we muliply the rim light color with the power of the rim power that we got.
Then, we assigned the result to
o.Emission
to show the rim light effect on our object.
Then, in the
LightingRampSpecular()
funcion, we changed the calculaion of the
lighing by using the Half-Lambert model, which will make our object brighter with the light
that will warp around the object by dividing it by half and plus half (
fixed diff = NdotL
* 0.5 + 0.5;
).
Half-Lambert lighing is a technique irst developed in the original Half-Life.
It is designed to prevent the rear of an object losing its shape and looking too
flat. Half Lambert is a completely non-physical technique and gives a purely
perceived visual enhancement and is an example of a forgiving lighing model.
Reference from
http://developer.valvesoftware.com/wiki/
Half_Lambert
.