Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth...
-
Upload
marjorie-smith -
Category
Documents
-
view
245 -
download
2
Transcript of Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth...
![Page 1: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/1.jpg)
Real-time Real-time Shadow Shadow MappingMapping
Real-time Real-time Shadow Shadow MappingMapping
![Page 2: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/2.jpg)
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
![Page 3: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/3.jpg)
First Pass(1)
• The scene is rendered from the light’s point of view into the depth texture
![Page 4: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/4.jpg)
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
![Page 5: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/5.jpg)
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
![Page 6: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/6.jpg)
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
![Page 7: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/7.jpg)
Depth Texture Comparison(2)
![Page 8: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/8.jpg)
Depth Texture Comparison(3)
The A < B shadowed fragment case
![Page 9: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/9.jpg)
Depth Texture Comparison(4)
The A = B shadowed fragment case
![Page 10: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/10.jpg)
Using Projective Texturing(1)
![Page 11: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/11.jpg)
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
![Page 12: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/12.jpg)
Ambient Shadows
• Improvement for completely black shadows
![Page 13: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/13.jpg)
Near and Far planes
• Distance between near and far planes should be minimized for better precision of Z value
![Page 14: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/14.jpg)
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
![Page 15: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/15.jpg)
Aliasing Problems
• There is still the problem of aliasing
![Page 16: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/16.jpg)
Summary
![Page 17: Real-time Shadow Mapping. Shadow Mapping Shadow mapping uses two-pass rendering - render depth texture from the light ’ s point-of-view - render from.](https://reader036.fdocuments.net/reader036/viewer/2022062321/56649ede5503460f94bee651/html5/thumbnails/17.jpg)
Implementation
• First pass uses the OpenSceneGraph library which based on OpenGL
• Second pass is done by hardware using cg and glsl language shaders