Top Banner
CSL 859: CSL 859: Advanced Advanced Computer Computer Graphics Graphics Dept of Computer Sc. & Dept of Computer Sc. & Engg. Engg. IIT Delhi IIT Delhi
25

CSL 859: Advanced Computer Graphics

Jan 21, 2016

Download

Documents

glenys

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 - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSL 859: Advanced Computer Graphics

CSL 859: CSL 859: Advanced Advanced Computer Computer GraphicsGraphicsDept of Computer Sc. & Engg.Dept of Computer Sc. & Engg.

IIT DelhiIIT Delhi

Page 2: CSL 859: Advanced Computer Graphics

Shadow VolumesShadow Volumes

Page 3: CSL 859: Advanced Computer Graphics

Shadow VolumesShadow Volumes

Page 4: CSL 859: Advanced Computer Graphics

Stencil BufferStencil Buffer Like color/z buffer; one entry per pixelLike color/z buffer; one entry per pixel

Traditionally a few bits of Z-bufferTraditionally a few bits of Z-buffer Stencil value also masks whether to renderStencil value also masks whether to render Render to StencilRender to Stencil

Stencil operationStencil operationvoid void StencilFuncStencilFunc (enum  (enum funcfunc, int , int refref, uint , uint maskmask ) )

NEVER, ALWAYS, LESS, LEQUAL, EQUAL, NEVER, ALWAYS, LESS, LEQUAL, EQUAL, GEQUAL, GREATER, or NOTEQUALGEQUAL, GREATER, or NOTEQUAL

void void StencilOpStencilOp (enum  (enum sfailsfail, enum , enum zfailzfail, enum , enum zpasszpass) ) KEEP, ZERO, REPLACE, INCR, DECR, INVERTKEEP, ZERO, REPLACE, INCR, DECR, INVERT

glEnableglEnable((GL_STENCIL_TESTGL_STENCIL_TEST))

Page 5: CSL 859: Advanced Computer Graphics

Stencil Shadow Volume Stencil Shadow Volume OverviewOverview

Render the scene with shadow colorRender the scene with shadow color For each light sourceFor each light source

Using the depth from pass 1, construct a Using the depth from pass 1, construct a mask in the stencil buffer enabling mask in the stencil buffer enabling pixels not in shadowpixels not in shadow

Shadow volume constructed by Shadow volume constructed by computing silhouettes of occluderscomputing silhouettes of occluders And capping the volumesAnd capping the volumes

Render the scene again, lit this time.Render the scene again, lit this time. Stencil buffer masks out shadowed areasStencil buffer masks out shadowed areas

Page 6: CSL 859: Advanced Computer Graphics

Stencil GenerationStencil Generation Disable depth and color writesDisable depth and color writes Set the stencil operation to increment on Set the stencil operation to increment on

depth depth passpass (counting shadows in front of (counting shadows in front of the object)the object)

Enable back-face culling (ie front drawing)Enable back-face culling (ie front drawing) Draw the shadow volumes (ie front faces)Draw the shadow volumes (ie front faces) Set the stencil operation to decrement on Set the stencil operation to decrement on

depth depth passpass Enable front-face cullingEnable front-face culling Draw the shadow volumes (ie back faces)Draw the shadow volumes (ie back faces)

What if Eye is in shadow?What if Eye is in shadow?

Page 7: CSL 859: Advanced Computer Graphics

Stencil Shadow VolumesStencil Shadow Volumes

a b

Page 8: CSL 859: Advanced Computer Graphics

Reverse StencilReverse Stencil Disable depth and color writesDisable depth and color writes Enable front-face cullingEnable front-face culling Set the stencil operation to increment on Set the stencil operation to increment on

depth depth failfail (counting shadows behind the (counting shadows behind the object).object).

Render the shadow volumes (ie back faces)Render the shadow volumes (ie back faces) Enable back-face cullingEnable back-face culling Set the stencil operation to decrement on Set the stencil operation to decrement on

depth depth failfail.. Render the shadow volumes (ie front faces)Render the shadow volumes (ie front faces)

Page 9: CSL 859: Advanced Computer Graphics

Shadow Map AliasingShadow Map Aliasing

single shadow map pixel

Page 10: CSL 859: Advanced Computer Graphics

Perspective Shadow Perspective Shadow MapsMaps

[Stamminger & Grettakis 02][Stamminger & Grettakis 02]

Page 11: CSL 859: Advanced Computer Graphics

Deep Shadow MapDeep Shadow Map

Deep shadow mapsDeep shadow maps Instead of storing a Instead of storing a

depth at each pixeldepth at each pixel Store a series of Store a series of

depths w/ reduction depths w/ reduction of light transmittedof light transmitted

Important for Important for complex self-complex self-shadowing modelsshadowing models

Hair, cloudsHair, clouds

[Lokovic & Veach 2000]

Page 12: CSL 859: Advanced Computer Graphics

Deep Shadow MapsDeep Shadow Maps

With self-shadowingWithout self-shadowing

Page 13: CSL 859: Advanced Computer Graphics

Shadows from Area LightShadows from Area Light

Accumulation bufferAccumulation buffer Higher resolution than final imageHigher resolution than final image

Sample area lightSample area light Render from multiple light-pointsRender from multiple light-points

AverageAverage

[Heckbert & Herf 97]Overlapping shadows have undesired artifacts

Page 14: CSL 859: Advanced Computer Graphics

Fake Soft ShadowsFake Soft Shadows

Extend shadow map [Chan & Durand Extend shadow map [Chan & Durand 03]03]

Use extra primitives (Use extra primitives (smoothiessmoothies) to ) to soften shadowssoften shadows

light’s view (blockers only) light’s view (blockers + smoothies)

Page 15: CSL 859: Advanced Computer Graphics

Fake Soft ShadowsFake Soft Shadows

Shadows not geometrically correct Shadows not geometrically correct Shadows appear Shadows appear qualitativelyqualitatively like like

soft shadowssoft shadows

Hard shadows Fake soft shadows

Page 16: CSL 859: Advanced Computer Graphics

Shadow Map CreationShadow Map Creation

Render blockers into depth mapRender blockers into depth map

light’s view

observer’s view

Page 17: CSL 859: Advanced Computer Graphics

Silhouette DetectionSilhouette Detection

Find blockers’ silhouette edges in Find blockers’ silhouette edges in object spaceobject space

object-space silhouettesobject-space silhouettes

observer’s view

light’s view

Page 18: CSL 859: Advanced Computer Graphics

Construct SmoothiesConstruct Smoothies

Blocker only:Blocker only:silhouette vertex

silhouette edges

blocker exterior

Page 19: CSL 859: Advanced Computer Graphics

Construct SmoothiesConstruct Smoothies

Blocker + smoothies:Blocker + smoothies:

silhouette vertex

silhouette edges

smoothie edge

smoothie corner

t

t

blocker exterior

Page 20: CSL 859: Advanced Computer Graphics

Construct SmoothiesConstruct Smoothies Smoothie edgesSmoothie edges: rectangles in screen : rectangles in screen

space with a fixed widthspace with a fixed width Smoothie corners:Smoothie corners: connect adjacent connect adjacent

smoothie edgessmoothie edges

t

t

geometry shading

Page 21: CSL 859: Advanced Computer Graphics

Render SmoothiesRender Smoothies Store depth and alpha values into Store depth and alpha values into

smoothie buffersmoothie bufferSmoothie Buffer (depth) Smoothie Buffer (alpha)

light’s viewpoint

Page 22: CSL 859: Advanced Computer Graphics

Compute ShadowsCompute Shadows

Compute intensity using depth Compute intensity using depth comparisonscomparisons

smoothie

light source

blocker

receiver

Page 23: CSL 859: Advanced Computer Graphics

Hard ShadowHard Shadow

Image sample behind blocker Image sample behind blocker (intensity = 0)(intensity = 0)

smoothie

light source

blocker

receivercompletely in shadow

Page 24: CSL 859: Advanced Computer Graphics

Soft ShadowsSoft Shadows

Image sample behind smoothie Image sample behind smoothie (intensity = (intensity = ))

partially in shadow

smoothie

light source

blocker

receiver

Page 25: CSL 859: Advanced Computer Graphics

No ShadowNo Shadow

Image sample illuminated Image sample illuminated (intensity = 1)(intensity = 1)

illuminated

smoothie

light source

blocker

receiver