Presentation is loading. Please wait.

Presentation is loading. Please wait.

UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Shadows.

Similar presentations


Presentation on theme: "UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Shadows."— Presentation transcript:

1 UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Shadows

2 Goals 1. Understand the problem with “rendering” shadows 2. Review the different methods to do it

3 The nature of shadows  Shadows don’t really exist  They are just “missing light”  Missing because another object occluded the light  Shadows are not necessarily cast by another object!  Your arm can cast a shadow over your body  This is called “self-shadowing”  Often games don’t bother doing this  Shadows are fuzzy around the edges  Shadows don’t accumulate  Two objects hiding the light at a point, looks the same as a single object

4 The problem with shadows  Shadows rarely add to gameplay  It’s easy to just ignore them  But they do add a feel of completeness to the scene  Shadows are an O(N 2 ) problem  Every object can get shadowed by every other object  Also scaled up by the number of lights!  The computational scale of this problem is untenable  Something is going to give

5 Method #1: blob shadows  An amorphous & fuzzy dark splotch under an object  This is the easiest method  Forget the lights  Forget the O(N 2 )  Cast a single shadow on the floor and be done  Worry only about Z-fighting  Shadow won’t climb up the walls

6 Method #2: projective shadows  Cast by a single light  “Flatten” the object on the floor  Manipulate the world matrix to accomplish this It needs to be a “degenerate” matrix: Y_column = 0 Add a skew for more sideways shadows  Shadow shows the shape of the object  Skinned objects are ok  Paint it opaque black or use transparency with a stencil op to mask  Worry about Z-fighting too  Shadow won’t climb up the walls

7 Method #3: Shadow buffer  Cast by a single light  Render the entire scene’s depth values into a texture  From the point of view of the light!  This light’s view space is what we call light space  Then render the scene with shadows  Sample from this texture to find out if pixel is in shadow  Must calculate perspective correction in light space!

8 Shadow buffer pros  Supports self-shadowing  But easily riddled with artifacts  Crawling up the walls works great  Fuzziness uses PCF “Percentage Closest Filtering”  Or fancier methods like variance maps  Scales great: O(N)

9 Shadow buffer cons  Shadows can appear blocky (buffer pixels showing)  Adjust light’s projection matrix to manipulate perspective  PCF doesn’t eliminate this  Only one light is supported  Can use multiple shadow maps, but it gets expensive

10 Method #4: Shadow volume  Cast by a single light  Render the scene normally  Then render an extruded version of the shadow casters  Render front & back faces  Render into stencil buffer only  Stencil accumulates an even/odd marker  Shadowed pixels end up with odd markers  Finally, render full-screen quad to paint odd pixels with shadow  Transparency is ok

11 Shadow volume pros  Self-shadowing is supported  Artifacts can be avoided by manipulating the extrusion  Crawling up the walls works great  Shadows are pixel-perfect: no blockiness  Scales very well: O(N)  N is the number of shadow casters

12 Shadow volume cons  Shadows are too perfectly sharp (no fuzziness)  Can render multiple times in multi-tap fashion  But it gets expensive  Only one light  Can render multiple times  Multiple lights can share the full-screen pass  Workarounds require access to the stencil bytes


Download ppt "UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Shadows."

Similar presentations


Ads by Google