Game Development Reference
In-Depth Information
Shadows
Only the DirectionalLight and PointLight objects can cast shadows. Casting
shadows first requires that we enable shadows on the renderer:
renderer.shadowMapEnabled = true;
If you want, you can also set renderer.shadowMapSoft = true , which will
somewhat smooth the edges of the shadows.
Then, each object that will cast or receive shadows must be explicitly set to do so.
(Shadows are disabled by default because calculating shadows can be slow.) For our
city scene, we'll enable shadow receiving for our floor and both casting and receiving
for our buildings:
floor.receiveShadow = true;
city.castShadow = true;
city.receiveShadow = true;
The castShadow and receiveShadow properties do pretty much what they sound
like—enabling casting and receiving shadows.
Finally, we configure our DirectionalLight object to use shadows:
light.castShadow = true;
light.shadowDarkness = 0.5;
light.shadowMapWidth = 2048;
light.shadowMapHeight = 2048;
light.position.set(500, 1500, 1000);
light.shadowCameraFar = 2500;
// DirectionalLight only; not necessary for PointLight
light.shadowCameraLeft = -1000;
light.shadowCameraRight = 1000;
light.shadowCameraTop = 1000;
light.shadowCameraBottom = -1000;
 
Search WWH ::




Custom Search