Shadow Algorithms Gerald Matzka Computer Science Seminar Overview

  • Slides: 23
Download presentation
Shadow Algorithms Gerald Matzka Computer Science Seminar

Shadow Algorithms Gerald Matzka Computer Science Seminar

Overview n Introduction n Shadow Algorithms u Fake Shadow u Vertex Projection u Shadow

Overview n Introduction n Shadow Algorithms u Fake Shadow u Vertex Projection u Shadow Z-Buffer u Shadow Volume Reconstruction u Static Shadow n Use Cases G. Matzka, 2001. 06. 20 2

Introduction n Why Shadow? n What is Shadow? n Anatomy of Shadow n Umbra

Introduction n Why Shadow? n What is Shadow? n Anatomy of Shadow n Umbra vs. Penumbra n Shadow Volume G. Matzka, 2001. 06. 20 3

Why Shadow? n Objects appear not n n anchored Shadow provides additional information Second

Why Shadow? n Objects appear not n n anchored Shadow provides additional information Second view of an object Without shadow object seems to float State of the art G. Matzka, 2001. 06. 20 4

Definition: Shadow n “An area that is only partially irradiated or illuminated due to

Definition: Shadow n “An area that is only partially irradiated or illuminated due to blockage of light by an opaque object. ” n 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. G. Matzka, 2001. 06. 20 5

Umbra vs. Penumbra n Area light sources produce soft shadow n Umbra: area in

Umbra vs. Penumbra n Area light sources produce soft shadow n Umbra: area in full shadow n Penumbra: boundary area; gradient from full shadow to light G. Matzka, 2001. 06. 20 6

Definition: Shadow Volume n Shadow planes n Volume formed from n n n shadow

Definition: Shadow Volume n Shadow planes n Volume formed from n n n shadow planes Open and infinite Inside in shadow outside in light Must be clipped and capped G. Matzka, 2001. 06. 20 7

Shadow Algorithms n Fake Shadow n Vertex Projection n Shadow Z-Buffer n Shadow Volume

Shadow Algorithms n Fake Shadow n Vertex Projection n Shadow Z-Buffer n Shadow Volume Reconstruction n Static Shadow G. Matzka, 2001. 06. 20 8

Fake Shadow n No exact calculation n Approximation of shadow position and shape n

Fake Shadow n No exact calculation n Approximation of shadow position and shape n Estimated by center or anchor of object n Pro: simple, fast n Contra: flat ground, only ground shading, not exact, rotate limitations G. Matzka, 2001. 06. 20 9

Vertex Projection n Object projected to ground n Exact mathematical calculation n Pro: still

Vertex Projection n Object projected to ground n Exact mathematical calculation n Pro: still simple, exact, no rotate limitations n Contra: flat ground, only ground shading G. Matzka, 2001. 06. 20 10

Shadow Z-Buffer n Based on hidden surfaces n Light’s point of view rendering into

Shadow Z-Buffer n Based on hidden surfaces n Light’s point of view rendering into Z-Buffer n Camera’s point of view rendering, lookup in ZBuffer n Transformation between camera and light view n Z-value compare shadowed or lit G. Matzka, 2001. 06. 20 11

Shadow Z-Buffer cont. n Problems: inaccuracies in calculations u self-shadowing: small fudge factor u

Shadow Z-Buffer cont. n Problems: inaccuracies in calculations u self-shadowing: small fudge factor u point-sampling: area-sampling n Pro: accurate, medium effort n Contra: blocky, self-shadowing, compare with neighbor, drawn twice G. Matzka, 2001. 06. 20 12

Shadow Volumes n Count of Shadow Volumes at viewing position n front plus back

Shadow Volumes n Count of Shadow Volumes at viewing position n front plus back minus n Three steps: u silhouette generation u drawing of shadow volume(s) u rendering the shadow G. Matzka, 2001. 06. 20 13

Shadow Volumes cont. n Step 1: Silhouette generation u boundaries between adjacent front-facing and

Shadow Volumes cont. n Step 1: Silhouette generation u boundaries between adjacent front-facing and back-facing polygons silhouette u adding light vertex to silhouette vertexes shadow planes u shadow planes together with object shadow volume G. Matzka, 2001. 06. 20 14

Shadow Volumes cont. n Step 2: Drawing of Shadow volume u rendered twice in

Shadow Volumes cont. n Step 2: Drawing of Shadow volume u rendered twice in stencil buffer (cull- mode) G. Matzka, 2001. 06. 20 15

Shadow Volumes cont. n Step 3: Rendering the Shadow u stencil buffer holds shadow

Shadow Volumes cont. n Step 3: Rendering the Shadow u stencil buffer holds shadow u render a polygon using stencil buffer bits u shadow for one light created n Repeat for next light from step 1 G. Matzka, 2001. 06. 20 16

Shadow Volumes cont. n Pro: u greatly improved realism u hardware support of stencil

Shadow Volumes cont. n Pro: u greatly improved realism u hardware support of stencil buffer n Contra: u high requirement on fill-rate u sharp shadow u additional scene management G. Matzka, 2001. 06. 20 17

Shadow Volume Reconstruction n mixture of Z-Buffer and Shadow Volume n light’s point of

Shadow Volume Reconstruction n mixture of Z-Buffer and Shadow Volume n light’s point of view rendering n edge filter to create silhouette image n silhouette image used as shadow volume n clip and cap shadow volume n draw shadow volume n apply shadow accordingly G. Matzka, 2001. 06. 20 18

Shadow Volume Reconstruction n Pro: u smoother than Z-Buffer u faster than Shadow Volume

Shadow Volume Reconstruction n Pro: u smoother than Z-Buffer u faster than Shadow Volume n Contra: u additional step (edge filter, reconstruction) u inaccuracies (edge filter, reconstruction) G. Matzka, 2001. 06. 20 19

Static Shadow n not a real-time Shadow Algorithm n none moving or none animating

Static Shadow n not a real-time Shadow Algorithm n none moving or none animating objects n pre-calculated shadow maps n rendered as normal polygons G. Matzka, 2001. 06. 20 20

Use Cases n Games and 3 D Engines n Ray-Tracers (no real-time shading) n

Use Cases n Games and 3 D Engines n Ray-Tracers (no real-time shading) n Trade-Off between speed and quality!!! n Outcast: derived Z-Buffer algorithm, caused by voxel and polygon mixture G. Matzka, 2001. 06. 20 21

Conclusion n Shadow gives large amount of information n Shadow generation is a classic

Conclusion n Shadow gives large amount of information n Shadow generation is a classic computer graphics problem n Several basic algorithms with advantages and disadvantages n State of the art in modern computer games G. Matzka, 2001. 06. 20 22

The End Thanks for listening!

The End Thanks for listening!