Game Development Reference
In-Depth Information
Shader programming - Diffuse and Bump
(normal) maps
In this first step, we will import
Chapter3.unitypackage
(which is already included
in the FBX model and textures) and create a shader program, which will include all the
properties that we can edit from the
Material Inspector
. We will start by assigning the
Diffuse and Bump (normal) maps. Then, we will use the built-in lighting models,
Lam-
bert
and
BlinnPhong
, which are located in the
Lighting.cginc
file inside the Un-
ity application, to see our result.
Note
Lambert
or diffuse reflection will cause all closed polygons to reflect light equally in all
directions when rendered. This algorithm is named after Johann Heinrich Lambert, who in-
vented it.
Blinn-Phong
or Blinn-Phong reflection is a shading model that is a modification of the
Phong reflection model and was developed by Jim Blinn.
The
Phong
reflection model is a shading model that includes a model for the reflection of
light from surfaces. It also has a compatible method of estimating pixel colors using the in-
terpolation of surface normals across rasterized (or bitmap) polygons. This was developed
by Bui Tuong Phong.
The references used are as follows:
We can find
Lighting.cginc
from the following locations:
•
For Windows
:
{unity install path}/Data/CGIncludes/Light-
ing.cginc
•
For Mac
:
/Applications/Unity/Unity.app/Contents/CGIn-
cludes/Lighting.cginc