250 likes | 391 Views
CSL 859: Advanced Computer Graphics. Dept of Computer Sc. & Engg. IIT Delhi. Shadow Volumes. Shadow Volumes. Stencil Buffer. Like color/z buffer; one entry per pixel Traditionally a few bits of Z-buffer Stencil value also masks whether to render Render to Stencil Stencil operation
E N D
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi
Stencil Buffer • Like color/z buffer; one entry per pixel • Traditionally a few bits of Z-buffer • Stencil value also masks whether to render • Render to Stencil • Stencil operation void StencilFunc (enum func, int ref, uint mask ) NEVER, ALWAYS, LESS, LEQUAL, EQUAL, GEQUAL, GREATER, or NOTEQUALvoid StencilOp (enum sfail, enum zfail, enum zpass) KEEP, ZERO, REPLACE, INCR, DECR, INVERT glEnable(GL_STENCIL_TEST)
Stencil Shadow Volume Overview • Render the scene with shadow color • For each light source • Using the depth from pass 1, construct a mask in the stencil buffer enabling pixels not in shadow • Shadow volume constructed by computing silhouettes of occluders • And capping the volumes • Render the scene again, lit this time. • Stencil buffer masks out shadowed areas
Stencil Generation • Disable depth and color writes • Set the stencil operation to increment on depth pass (counting shadows in front of the object) • Enable back-face culling (ie front drawing) • Draw the shadow volumes (ie front faces) • Set the stencil operation to decrement on depth pass • Enable front-face culling • Draw the shadow volumes (ie back faces) What if Eye is in shadow?
Reverse Stencil • Disable depth and color writes • Enable front-face culling • Set the stencil operation to increment on depth fail (counting shadows behind the object). • Render the shadow volumes (ie back faces) • Enable back-face culling • Set the stencil operation to decrement on depth fail. • Render the shadow volumes (ie front faces)
single shadow map pixel Shadow Map Aliasing
Perspective Shadow Maps • [Stamminger & Grettakis 02]
Deep Shadow Map • Deep shadow maps • Instead of storing a depth at each pixel • Store a series of depths w/ reduction of light transmitted • Important for complex self-shadowing models • Hair, clouds [Lokovic & Veach 2000]
Deep Shadow Maps Without self-shadowing With self-shadowing
Shadows from Area Light • Accumulation buffer • Higher resolution than final image • Sample area light • Render from multiple light-points • Average [Heckbert & Herf 97] Overlapping shadows have undesired artifacts
Fake Soft Shadows • Extend shadow map [Chan & Durand 03] • Use extra primitives (smoothies) to soften shadows light’s view (blockers only) light’s view (blockers + smoothies)
Fake Soft Shadows • Shadows not geometrically correct • Shadows appear qualitatively like soft shadows Hard shadows Fake soft shadows
Shadow Map Creation • Render blockers into depth map observer’s view light’s view
Silhouette Detection • Find blockers’ silhouette edges in object space object-space silhouettes observer’s view light’s view
Construct Smoothies • Blocker only: silhouette vertex silhouette edges blocker exterior
Construct Smoothies • Blocker + smoothies: t silhouette vertex silhouette edges t smoothie edge smoothie corner blocker exterior
Construct Smoothies • Smoothie edges: rectangles in screen space with a fixed width • Smoothie corners: connect adjacent smoothie edges t t geometry shading
Render Smoothies • Store depth and alpha values into smoothie buffer Smoothie Buffer (alpha) Smoothie Buffer (depth) light’s viewpoint
light source smoothie blocker receiver Compute Shadows • Compute intensity using depth comparisons
Hard Shadow • Image sample behind blocker (intensity = 0) light source smoothie blocker receiver completely in shadow
Soft Shadows • Image sample behind smoothie (intensity = ) light source smoothie blocker receiver partially in shadow
No Shadow • Image sample illuminated (intensity = 1) light source smoothie blocker receiver illuminated