Game Development Reference
In-Depth Information
Objective complete - mini debriefing
Let's take a look at what we did here.
First, we added a new property,
_BumpMap
, which is used to get the surface normal of our
character's geometry.
Note
For more details on surface normals, refer to
http://en.wikipedia.org/wiki/
Properties can be created using the following syntax:
name ("display name", property type) = default value
The components of this code snippet are as follows:
•
name
: This is the name of the property inside the shader script
•
display
: This is the name that will be shown in the
Material Inspector
•
property type
: This is the type of the property that we can use in our shader
programming, which can be
Range
,
Color
,
2D
,
Rect
,
Cube
,
Float
, or
Vector
•
default
: This is the default value of our property
Note
Every time you add new properties in the
Properties
section, you will need to create
the same parameter inside
CGPROGRAM
in the
SubShader
section, as shown in the fol-
lowing code:
Properties { _BumpMap ("Bumpmap", 2D) = "bump" {} }
SubShader {
…
CGPROGRAM
#pragma surface surf Lambert
sampler2D _BumpMap;
…
ENDCG
}