shadow algorithms gerald matzka computer science seminar
Post on 20-Dec-2015
221 views
TRANSCRIPT
Shadow AlgorithmsShadow Algorithms
Gerald MatzkaGerald Matzka
Computer Science SeminarComputer Science Seminar
2 / 22G. Matzka, 2001.06.20
OverviewOverview IntroductionIntroduction Shadow AlgorithmsShadow Algorithms
Fake ShadowFake Shadow Vertex ProjectionVertex Projection Shadow Z-BufferShadow Z-Buffer Shadow VolumeShadow Volume Shadow Volume Reconstruction Static Shadow
Use CasesUse Cases
3 / 22G. Matzka, 2001.06.20
IntroductionIntroduction Why Shadow?Why Shadow? What is Shadow?What is Shadow? Anatomy of ShadowAnatomy of Shadow Umbra vs. PenumbraUmbra vs. Penumbra Shadow VolumeShadow Volume
4 / 22G. Matzka, 2001.06.20
Why Shadow?Why Shadow? Objects appear not Objects appear not
anchoredanchored Shadow provides additional Shadow provides additional
informationinformation Second view of an objectSecond view of an object Without shadow object Without shadow object
seems to floatseems to float State of the artState of the art
5 / 22G. Matzka, 2001.06.20
Definition: ShadowDefinition: Shadow “An area that is only partially irradiated or
illuminated due to blockage of light by an opaque object.”
A point is in shadow relative to a given light source if rays from that light source cannot directly reach the point. Shadowed points cannot see the light.
6 / 22G. Matzka, 2001.06.20
Umbra vs. PenumbraUmbra vs. Penumbra Area light sources Area light sources
produce soft shadowproduce soft shadow
Umbra: area in full Umbra: area in full shadowshadow
Penumbra: boundary Penumbra: boundary area; gradient from full area; gradient from full shadow to lightshadow to light
7 / 22G. Matzka, 2001.06.20
Definition: Shadow VolumeDefinition: Shadow Volume Shadow planesShadow planes Volume formed from Volume formed from
shadow planesshadow planes Open and infiniteOpen and infinite Inside in shadow - Inside in shadow -
outside in lightoutside in light Must be clipped and Must be clipped and
cappedcapped
Point light source
Shadow Volume
objectlight vertex
8 / 22G. Matzka, 2001.06.20
Shadow AlgorithmsShadow Algorithms Fake ShadowFake Shadow Vertex ProjectionVertex Projection Shadow Z-BufferShadow Z-Buffer Shadow VolumeShadow Volume Shadow Volume Reconstruction Static Shadow
9 / 22G. Matzka, 2001.06.20
Fake ShadowFake Shadow No exact calculationNo exact calculation Approximation of Approximation of
shadow position and shadow position and shapeshape
Estimated by center or Estimated by center or anchor of objectanchor of object
Pro: simple, fastPro: simple, fast Contra: flat ground, only Contra: flat ground, only
ground shading, not ground shading, not exact, rotate limitationsexact, rotate limitations
10 / 22G. Matzka, 2001.06.20
Vertex ProjectionVertex Projection Object projected to Object projected to
groundground Exact mathematical Exact mathematical
calculationcalculation
Pro: still simple, exact, Pro: still simple, exact, no rotate limitationsno rotate limitations
Contra: flat ground, only Contra: flat ground, only ground shadingground shading
11 / 22G. Matzka, 2001.06.20
Shadow Z-BufferShadow Z-Buffer Based on hidden surfacesBased on hidden surfaces Light’s point of view Light’s point of view
rendering into Z-Bufferrendering into Z-Buffer Camera’s point of view Camera’s point of view
rendering, lookup in Z-rendering, lookup in Z-BufferBuffer
Transformation between Transformation between camera and light viewcamera and light view
Z-value compare - Z-value compare - shadowed or litshadowed or lit
12 / 22G. Matzka, 2001.06.20
Shadow Z-Buffer cont.Shadow Z-Buffer cont. Problems: Problems: inaccuracies in calculations
self-shadowing: small fudge factorself-shadowing: small fudge factor point-sampling: area-samplingpoint-sampling: area-sampling
Pro: Pro: accurate, medium effort Contra: blocky, self-shadowing, compare
with neighbor, drawn twice
13 / 22G. Matzka, 2001.06.20
Shadow VolumesShadow Volumes Count of Shadow Count of Shadow
Volumes at viewing Volumes at viewing positionposition
front plus front plus back minus back minus
Three steps:Three steps: silhouette generationsilhouette generation drawing of shadow drawing of shadow
volume(s)volume(s) rendering the shadowrendering the shadow
14 / 22G. Matzka, 2001.06.20
Step 1: Silhouette generationStep 1: Silhouette generation boundaries between adjacent front-facing
and back-facing polygons silhouette adding light vertex to silhouette vertexes
shadow planes shadow planes together with object
shadow volume
Shadow Volumes cont.Shadow Volumes cont.
15 / 22G. Matzka, 2001.06.20
Shadow Volumes cont.Shadow Volumes cont. Step 2: Drawing of Shadow volume
rendered twice in stencil buffer (cull-mode)
Point light source
Camera
12
1 0
Objects
16 / 22G. Matzka, 2001.06.20
Shadow Volumes cont.Shadow Volumes cont. Step 3: Rendering the ShadowStep 3: Rendering the Shadow
stencil buffer holds shadowstencil buffer holds shadow render a polygon using stencil buffer bitsrender a polygon using stencil buffer bits shadow for one light createdshadow for one light created
Repeat for next light from step 1Repeat for next light from step 1
17 / 22G. Matzka, 2001.06.20
Shadow Volumes cont.Shadow Volumes cont. Pro: Pro:
greatly improved realismgreatly improved realism hardware support of stencil bufferhardware support of stencil buffer
Contra:Contra: high requirement on fill-ratehigh requirement on fill-rate sharp shadowsharp shadow additional scene managementadditional scene management
18 / 22G. Matzka, 2001.06.20
Shadow Volume ReconstructionShadow Volume Reconstruction mixture of Z-Buffer and Shadow Volumemixture of Z-Buffer and Shadow Volume light’s point of view renderinglight’s point of view rendering edge filter to create silhouette imageedge filter to create silhouette image silhouette image used as shadow volumesilhouette image used as shadow volume clip and cap shadow volumeclip and cap shadow volume draw shadow volumedraw shadow volume apply shadow accordinglyapply shadow accordingly
19 / 22G. Matzka, 2001.06.20
Shadow Volume ReconstructionShadow Volume Reconstruction Pro:Pro:
smoother than Z-Buffersmoother than Z-Buffer faster than Shadow Volumefaster than Shadow Volume
Contra:Contra: additional step (edge filter, reconstruction) inaccuracies (edge filter, reconstruction)
20 / 22G. Matzka, 2001.06.20
Static ShadowStatic Shadow not a real-time Shadow Algorithmnot a real-time Shadow Algorithm none moving or none animating objectsnone moving or none animating objects pre-calculated shadow mapspre-calculated shadow maps rendered as normal polygonsrendered as normal polygons
21 / 22G. Matzka, 2001.06.20
Use CasesUse Cases Games and 3D EnginesGames and 3D Engines Ray-Tracers (no real-time shading)Ray-Tracers (no real-time shading) Trade-Off between speed and quality!!!Trade-Off between speed and quality!!!
Outcast: derived Z-Buffer Outcast: derived Z-Buffer algorithm, caused by algorithm, caused by voxel and polygon voxel and polygon mixturemixture
22 / 22G. Matzka, 2001.06.20
ConclusionConclusion Shadow gives large amount of informationShadow gives large amount of information Shadow generation is a classic computer Shadow generation is a classic computer
graphics problemgraphics problem Several basic algorithms with advantages Several basic algorithms with advantages
and disadvantagesand disadvantages State of the art in modern computer gamesState of the art in modern computer games