11 - Bump and Shadow Mapping Flashcards
Bump Mapping
Bump mapping simulates height variations on an object by adjusting the directions of surface normals.
Perception of surface height depends on lighting, by adjusting surface normal directions according to a bump map bumps are simulated.
Provide the normal as a texture.
What is an elevation map(heightmap/bump map)
a texture provided to the shader that defines, for each pixel on the model’s surface, how far from the polygonal mesh’s surface it should lie.
How does bump mapping work the steps
- Look up the heightmap for the current surface position
- Calculate the surface normal perturbation at this location from the heightmap
- Combine the calculated normal with the original one
- Calculate illumination for the new normal using a standard shading
Limitation of bump mapping
Shadows don’t reflect the changed height
Bump mapping with a normal map
skips out the computation above by directly applying the new normals, as opposed to computing them on-the-fly.
A normal map is an image that encodes the direction of the surface normal at each texel (texture pixel) of the object’s surface;
this can then be applied in the illumination model.
Shadowing algorithms
determine which pixels in a scene are in the light, or in shadow.
There are two types of shadowing algorithms: direct, and indirect.
Direct Shadowing:
- Shadow volumes
- Shadow maps
Indirect:
- Raytracing
- Radiosity
derived from the global illumination model
What is a shadow volume
shadow volumes work by creating a 3D volume, which represents the space where an object (known as the occluder object) would cast a shadow.
A point is in shadow if it is in the volume.
shadow volumes can be computationally expensive; this is because the shadow volumes are large
How do we know whether to render a shadow using shadow volumes?
- Trace rays from eye point into scene for each pixel
- Initialise a shadow counter to zero
- Calculate intersections with shadow volume(s)
- For each intersection (sorted by distance from eye)
a. Increase shadow volume counter if entering the volume
b. Decrease shadow counter if leaving the volume
If the counter is 0, the point is not in any shadow volume
Stencil Buffer
Shadow volumes can also be calculated using the stencil buffer algorithm.
Specifies which fragments should be drawn, allowing fine-grained clipping to arbitrary shapes (like a stencil)
How do we use the stencil buffer with shadow volumes?
Render the whole scene in the shadows (without the light source)
For all light sources, create a mask using Stencil buffer with gaps on the illuminated areas
Then rerender the scene with full lighting applying the stencil buffer.
Use blending to add to scene.
What is shadow MAPPING?
Render the scene from a light source perspective using a depth buffer (z-buffer) to asses whether the fragment is in the shade or the light.
A depth map texture with low res can cause aliasing.
Difference between shadow map and shadow volume
Shadow map is faster to compute but quality is dependent on the shadow map resolution
Shadow volumes can be computationally expensive as shadow volumes can be large