Game Development Reference
In-Depth Information
o.Specular = _Shininess;
o.Gloss = c.a;
o.Normal = UnpackNormal (tex2D (_BumpMap,
IN.uv_BumpMap));
}
ENDCG
}
Basically, we just added three properties for Ambient as well as Specular color and shini-
ness. Then, in the
surf()
function, we changed
half4
to
fixed4
to increase the per-
formance by reducing the precision of our texture. We also multiplied
c.rgb
with
_Am-
bientColor.rgb
and
c.a
with
_AmbientColor.a
. This will add the color value
from the
_AmbientColor
properties with our main texture. Then, we passed
_Shini-
ness
to
o.Specular
and
c.a
to
o.Gloss
to control the amount of gloss on our
model.
If we open the diffuse texture in Photoshop and go to the alpha channel, we will see the
black and white color area, which is used to specify the amount of glossiness on our char-
acter. As we can see in the following screenshot, the armor path is white and the character
skin is almost black: