![Page 1: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/1.jpg)
Erdem Alpay
Ala Nawaiseh
![Page 2: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/2.jpg)
Why Shadows?Real world has shadowsMore control of the game’s feel
dramatic effects spooky effects
Without shadows the realism of a scene is lost
Spatial location of models can be ambiguous
![Page 3: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/3.jpg)
Importance of Shadows
•Where is the light coming from?
•Where are the objects in relation to each other?
![Page 4: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/4.jpg)
Importance of Shadows
•Where is the light coming from?
•Where are the objects in relation to each other?
•Shadows are being cast and the answers to these questions are easily found.
![Page 5: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/5.jpg)
Common Real-Time Shadow Techniques
ShadowShadowvolumesvolumes
Light mapsLight maps
ProjectedProjectedplanarplanarshadowsshadows
HybridHybridapproachesapproaches
![Page 6: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/6.jpg)
Easy To Implement and with good results when casting shadows onto one planeSquishes the Model onto a plane in just one matrix multiplicationVery Fast Can extend to cast onto multiple planes, but each plane will require another rendering of the model.
Planar Projected Shadows
![Page 7: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/7.jpg)
Planar Projected Shadows
[x, y, z] is the difference between the center of the model and the light source. Ideally you want to use the distance from each vertex, However it is not as fast since the matrix will have to be computed on a per vertex basis instead of a per model basis.The vertices of the model are multiplied by the Planar Projection matrix.
Plane Eq: Ax + By + Cz + D = 0
![Page 8: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/8.jpg)
Shadow Mapping Lance Williams published the idea in 1978
Completely image-space algorithm No knowledge of scene’s geometry is
required must deal with aliasing artifacts
Well known software rendering technique
Pixar’s RenderMan uses the algorithm Basic shadowing technique for Toy Story,
etc.
![Page 9: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/9.jpg)
Two pass algorithm: First, render depth buffer from the light’s point-
of-view Essentially a 2D function indicating the
depth of the closest pixels to the light. The result is a “depth map” or “shadow
map”. Second, render scene from the eye’s point-
of-view For each rasterized fragment determine
fragment’s XYZ position relative to the light compare the depth value at light position XY
in the depth map to fragment’s light position Z
The Shadow Mapping
![Page 10: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/10.jpg)
The Shadow Mapping Cont.
The Shadow Map Comparison Two values
A = Z value from depth map 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 then the fragment is shadowed
If A and B are approximately equal, the fragment is lit
![Page 11: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/11.jpg)
Shadow Mappingwith a Picture in 2D (1)
lightsource
depth map Z = A
depth map’s image plane
A < B shadowed fragment case
First step
![Page 12: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/12.jpg)
Shadow Mappingwith a Picture in 2D (1)
lightsource
eyeposition
depth map Z = A
fragment’slight Z = B
depth map’s image plane
eye view image plane,a.k.a. the frame buffer
A < B shadowed fragment case
Second Step
![Page 13: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/13.jpg)
Shadow Mappingwith a Picture in 2D (2)
lightsource
eyeposition
depth map Z = A
fragment’slight Z = B
depth map image plane
eye view image plane,a.k.a. the frame buffer
A B unshadowed fragment case
![Page 14: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/14.jpg)
Shadow Mappingwith a Picture in 2D (3)
The depth map could be The depth map could be at a different resolution at a different resolution from the frame bufferfrom the frame buffer
This mismatch canThis mismatch canlead to artifactslead to artifacts
image precision mismatch!
An artifact is small error caused by the render process.
![Page 15: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/15.jpg)
More realistic Example for mapping
1st Pass
![Page 16: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/16.jpg)
More realistic Example for mapping
2nd Pass
![Page 17: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/17.jpg)
Z-Buffer (Depth Buffer)Speeds up games by telling the graphics processor not to render objects that aren't actually in view, specifically objects or parts of objects which are covered up by other geometry. Ranges from 16bit to 32bit, and it can take up as much memory as an extra frame buffer. If depth test is enabled,
when a new color that arrives for a pixel is closer to the window than the one already in the depth buffer.
If it passes, it then replaces the value already in the depth buffer.
![Page 18: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/18.jpg)
Stencil BufferIt's usually only 1bit or 8bit. The stencil allows applications to "tag" various regions of the frame buffer.The stencil buffer can tell the video card what it's allowed to redrawFor example, let's say you have an air simulation game where the view is from the cockpit. It would be a waste to render the cockpit interior every framethe cockpit interior is tagged with a stencil number > 1The stencil buffer tag will tell the video card to only redraw where it sees a 0 in the stencil buffer
![Page 19: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/19.jpg)
![Page 20: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/20.jpg)
What Is Shadow Volume
A volume of space formed by an occluderBounded by the edges of the occluder
First proposed by Frank Crow in 1977.
Notice that the “far”ends of the volumegoes to infinity
![Page 21: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/21.jpg)
How does Shadow Volume works
Compute the shadow volume for all visible polygons from the light sourceAdd the shadow volume polygons to the scene database Tag them as shadow polygons Assign its associated light source
![Page 22: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/22.jpg)
Approaches in shadow volumes
Initially set parity to 0 and shoot a ray from eye to P
Invert parity when the ray crosses the shadow volume boundary
Parity = 1 it is in shadow Parity = 0 it is not in Shadow
First approach : Parity Test When is a surface is inside shadow?
![Page 23: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/23.jpg)
Approaches in shadow volumes
First approach : Parity Test Problems with Parity Test
![Page 24: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/24.jpg)
How does Shadow Volumes Works
Consider a camera at any point outside of the shadow and a point being shaded. Shoot a ray from camera to the point. If the point is in the shadow volume it will have a positive value since the ray incremented the stencil buffer every time it entered the shadow volume (front facing), and decremented it when it left (back facing).
Second Approach : Counter•When is a surface is inside shadow?
![Page 25: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/25.jpg)
How does Shadow Volumes Works
•If the camera is within the shadow volume the incrementing and decrementing must be reversed. •This however is extra work for a check to determine the location of the camera must be made.
Shadowing object
light source
eye position
0
0
1
1 2 2
3
![Page 26: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/26.jpg)
Shadow Volumes
Step 1: Render scene Z-values
![Page 27: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/27.jpg)
Shadow Volumes
Front face: +1
Step 2: Render shadow volume faces
Back face: -1
![Page 28: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/28.jpg)
Shadow Volumes
Front face: ±0 (Depth test)Back face: ±0 (Depth test) = ±0
![Page 29: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/29.jpg)
Shadow Volumes
Front face: +1Back face: ±0 (Depth test) = +1
±0
![Page 30: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/30.jpg)
Shadow Volumes
Front face: +1Back face: -1 = ±0
±0+1
![Page 31: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/31.jpg)
Shadow Volumes
±0+1±0
Step 3: Apply shadow mask to scene
![Page 32: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/32.jpg)
ConclusionShadow Mapping: offers real-time shadowing effects Independent of scene complexity Does not mandate multi-pass as stenciled
shadow volumes do Ideal for shadows from spotlights
Shadow Volume: The addition of shadow volume polygons can
greatly increase your database size Using the stencil buffer approach, pixel fill
becomes a key speed factor More precise than shadow mapping Polygon count explodes with object complexity
of geometry and number of light sources
![Page 33: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/33.jpg)
ReferencesShadow Mapping References Lance Williams, “Casting Curved Shadows
on Curved Surfaces,” SIGGRAPH 78 (paper) William Reeves, David Salesin, and Robert
Cook (Pixar), “Rendering antialiased shadows with depth maps,” SIGGRAPH 87 (paper)
http://developer.nvidia.com/docs/IO/1830/ATT/shadow_mapping.pdf
![Page 34: Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel dramatic effects spooky effects Without shadows the](https://reader035.vdocuments.us/reader035/viewer/2022062321/56649dd35503460f94aca54d/html5/thumbnails/34.jpg)
ReferencesShadow Volume References Lance Williams, “Casting Curved Shadows
on Curved Surfaces,” SIGGRAPH 78 (paper) William Reeves, David Salesin, and Robert
Cook (Pixar), “Rendering antialiased shadows with depth maps,” SIGGRAPH 87 (paper)
http://developer.nvidia.com/docs/IO/1830/ATT/shadow_mapping.pdf
Shadow Volume Reconstruction from Depth Maps Michael D. McCool University of Waterloo