09 Drawing in several passes
Shadows: first draw a depth map from the light
The bottom left shows the depth the light “sees”. Where an object blocks the light, the ground gets a shadow.
-33
-0.0040.002
Exercise
Drag the underlined numbers left and rightDrag numbers, or edit the code
renderer.shadowMap.enabled = true;light.castShadow = true;light.shadow.bias = ;mesh.castShadow = ;ground.receiveShadow = ;light.position.x = ;// in the shader, roughly:// float lit = myDepth - bias < mapDepth ? 1.0 : 0.0;
Shadow mapPass 1: view the scene from the light and record only depth. Pass 2: compare “my distance to the light” with the map.JS side
Shadow = draw a depth map from the light first, then check whether “my distance to the light” is further than the map says.
Try it
- Look at the bottom left: the light’s depth map
- Set bias to 0: stripes appear on surfaces (shadow acne)
- Turn off cast shadow