Game Development Reference
In-Depth Information
struct Input {
float2 uv_MainTex;
float2 uv_BumpMap;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
o.Normal = UnpackNormal (tex2D (_BumpMap,
IN.uv_BumpMap));
}
ENDCG
}
We just take the bump texture to create a normal map by getting the normals from
the texture using UnpackNormal and set it to the normal of SurfaceOutput
(o.Normal) .
Note
Normals, or surface normals, are a technique used to add details on the surface of
the object without using more polygons by faking the lighting of bumps and
dents.
11. Finally, we go back to Unity and apply the texture to our model. Let's click on the
Heroine model in the Hierarchy view to bring its Inspector view up. In the In-
spector view, we will go to the material component and set the following:
Texture : Drag-and-drop Diffuse in the Textures folder from the Project
view to this thumbnail
Bumpmap : Drag-and-drop Normal in the Textures folder from the Pro-
ject view to this thumbnail
You will see the Inspector view, as shown in the following screenshot:
Search WWH ::




Custom Search