Download presentation
Presentation is loading. Please wait.
Published byMarjorie Smith Modified over 9 years ago
1
Real-time Shadow Mapping
2
Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from the eye ’ s point-of-view using depth texture Completely image-space implementation - no knowledge of scene ’ s geometry is required - must deal with aliasing artifacts
3
First Pass(1) The scene is rendered from the light ’ s point of view into the depth texture
4
First Pass(2) The result is a “ depth texture ” or “ shadow map ” - essentially a 2D function indicating the depth of the closest pixels to the light
5
Second Pass The scene is rendered from the eye ’ s point of view For each rasterized fragment - determine fragment ’ s XYZ position relative to the light - this light position should be setup to match the frustum used to create the depth texture - compare the depth value at light position XY in the depth texture to fragment ’ s light position Z
6
Depth Texture Comparison(1) Two values - A = Z value from depth texture at fragment ’ s light XY position - B = Z value of fragment ’ s XYZ light position If B is greater than A, then there must be something closer to the light than the fragment so the fragment is in shadow If A and B are approximately equal, the fragment is lit
7
Depth Texture Comparison(2)
8
Depth Texture Comparison(3) The A < B shadowed fragment case
9
Depth Texture Comparison(4) The A = B shadowed fragment case
10
Using Projective Texturing(1)
11
Using Projective Texturing(2) Normal 2D texture mapping uses (s, t) coordinates Now consider homogeneous texture coordinates - r/q holds the distance from the light - (s, t, r, q) --> (s/q, t/q, r/q) - similar to homogeneous clip coordinates where (x, y, z, w) = (x/w, y/w, z/w) Next compare texture value at (s/q, t/q) to value r/q - if texture[s/q, t/q] r/q then not shadowed - if texture[s/q, t/q] < r/q then shadowed
12
Ambient Shadows Improvement for completely black shadows
13
Near and Far planes Distance between near and far planes should be minimized for better precision of Z value
14
Z-Fighting Problem take place when eye space pixel coordinates are transformed into light space to get the respective depth texture samples due to machine rounding errors in this stage
15
Aliasing Problems There is still the problem of aliasing
16
Summary
17
Implementation First pass uses the OpenSceneGraph library which based on OpenGL Second pass is done by hardware using cg and glsl language shaders
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.