Graphics Reference
In-Depth Information
In the preceding figure, you can see what a shadow map looks like. As you can see,
a shadow map contains the shadows of a scene prerendered in the target geometry,
in this case, a plane. If we use this image as a shadow map, we can easily view the
following scene:
In this scene, we use the shadow map to create shadows for the ground plane.
How to do it...
Using a shadow map is very easy. Before we look at the steps, make sure that you've
got a geometry and a material. In the following steps, we have THREE.Mesh with the
name floor:
1. A UV mapping defines how a face maps to a specific part of a texture. The
UV mapping in a geometry is stored in the faceVertexUvs property of a
geometry. The first element of this array contains the UV mappings used for
the other kinds of textures, and the second element contains the UV mapping
for the shadow map. As this value isn't filled by default, we point it to the first
element in the faceVertexUvs array:
floor.geometry.faceVertexUvs[1] =
floor.geometry.faceVertexUvs[0];
2. Next, you need to set the shadow map to the lightmap property of the ma-
terial:
Search WWH ::




Custom Search