Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shadows. Shadows is important in scenes, consolidating spatial relationships “Geometric shadows”: the shape of an area in shadow Early days, just pasted.

Similar presentations


Presentation on theme: "Shadows. Shadows is important in scenes, consolidating spatial relationships “Geometric shadows”: the shape of an area in shadow Early days, just pasted."— Presentation transcript:

1 Shadows

2 Shadows is important in scenes, consolidating spatial relationships “Geometric shadows”: the shape of an area in shadow Early days, just pasted into the scene as textures to fake the shadow (can you think of any other places of such usage? )

3 Type of Shadows Sharp-edged or soft-edged? Umbra and penumbra –Umbra: the area completely cut off from the light source –Penumbra: receives some light from the light source (penumbra surrounds umbra) Depending on the types of light sources, may or may not get penumbra –Point source –Area source

4 A Simple Shadow on A Ground Plane (Blinn’88) Throwing shadows onto a flat plane Only works with scenes where objects don’t cast shadows on each other Assuming single light source at infinite distance – parallel light rays L(x l, y l, z l ) Point on the object P(x p, y p, z p ) Shadow at S(x sw, y sw, 0)

5 Blinn’s Algorithm Considering the geometry: S = P -  L

6 Blinn’s Shadow Algorithm In matrix form: In fact, this is a form of projection, oblique projection

7 Shadow Algorithms Basic idea: Determine which surfaces can be "seen" from the light source Surfaces that can not be seen from the light are in shadow Shadows in the illumination model: I = ambient +  Si (diffuse + specular) Si = 0 if light i is blocked (will cast a shadow) Si = 1 if light i is not blocked (the point is lit)

8 General approach Main idea: –Point P is in shadow  P is not visible from light source 4 algorithms are discussed in the following: –Shadow z-buffer, two-pass z-buffer or (shadow map) –Shadow volume –Shadowing using Weiler-Atherton algorithm –Projecting Polygons/Span-line

9 Shadow Map  1 st pass: create a z-buffer from light position, store distance from light source in shadow-buffer [x][y]. (only z-buffer, no color buffer)  2 nd pass: do z-buffer from eye position. for each visible pixel (x,y,z) in 3D image space  inverse map to world space  map to screen space of shadow buffer  Compare z with that in the shadow buffer[x][y]  If shadow buffer[x][y] is smaller, pixel is in shadow!!

10 Shadow Map Advantage: –Simple Disadvantage: –Shadow distance from light position may appear blocky –Storage –Light source in the view volume?

11 Shadow Volumes Create a shadow volume for each front facing polygon Put shadow volumes in the polygon database (just mark the polygons of the shadow volume as in-visible) Do parity test to determine if a visible point is in shadow or not

12 Shadow Volumes

13  Front facing polygon hides all in back (A); back-facing does not(C); vector view-to-point hits more front ones  One way to implement  For each pixel, need to keep a counter  Need to make sure the polygons are rendered in depth order, say, front-to-back  Every time a front-facing shadow polygon is encountered, increment  Every time a back-facing shadow polygon is encountered, decrement  Does it matter if the view point is in shadows? Using Shadow Volumes

14 Shadow Volume Example

15 Shadow Volume Advantage: –Object space precision Disadvantage: –Polygon count explodes with object complexity of geometry and number of light sources

16 Shadowing using Weiler- Atherton Algorithm Using the Weiler-Atherton visible surface determination algorithm twice: First for the light source, and then for the viewpoint (an object space method)

17 Algorithm 1.Perform Weiler-Atherton algorithm to extract visible polygon fragments to the light source 2.Transform the lit polygon fragments back into the modeling space. Each polygon fragment is linked to its original polygon as the surface detail polygons 3.Perform the regular visible surface determination again for the view point using Weiler-Atherton algorithm (note: we don’t need to consider the surface detail polygons here as they are coplanar with their original polygons) 4.Visible surfaces covered by surface detail polygons are rendered as lit, whereas uncovered visible surfaces are rendered in shadow. For multiple light sources, we perform (1),(2) multiple times

18 WA Shadowing

19 Shadows – Span line Pre-process –Project all polygons onto a sphere center around the light source –Disjoint ones are discarded –Overlapping ones are marked as ‘shadow pairs’ Output: for each polygon, there are a list of polygons that will cast shadows on it

20  Run time, use a modified span-line rendering algorithm  For each polygon with an empty ‘shadow pair’ list, proceed as usual  Otherwise, project the shadow polygons onto the plane where the current polygon resides  A casts shadow A’ on B Shadows – Span Line

21 Three cases of spans Shadow polygon does not cover the current scan-line (span) that is being generated Shadow polygon completely cover the current span Shadow polygon covers the current span partially

22 Span-Line Shadow Object space High time complexity


Download ppt "Shadows. Shadows is important in scenes, consolidating spatial relationships “Geometric shadows”: the shape of an area in shadow Early days, just pasted."

Similar presentations


Ads by Google