Shadows Shadows Shadows is important in scenes consolidating

  • Slides: 22
Download presentation
Shadows

Shadows

Shadows • Shadows is important in scenes, consolidating spatial relationships • “Geometric shadows”: the

Shadows • 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? )

Type of Shadows • Sharp-edged or soft-edged? • Umbra and penumbra – Umbra: the

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

A Simple Shadow on A Ground Plane (Blinn’ 88) • Throwing shadows onto a

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(xl, yl, zl) • Point on the object P(xp, yp, zp) • Shadow at S(xsw, ysw, 0)

Blinn’s Algorithm • Considering the geometry: S = P - a. L

Blinn’s Algorithm • Considering the geometry: S = P - a. L

Blinn’s Shadow Algorithm • In matrix form: • In fact, this is a form

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

Shadow Algorithms • Basic idea: Determine which surfaces can be "seen" from the light

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 + S 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)

General approach • Main idea: – Point P is in shadow P is not

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

Shadow Map § 1 st pass: create a z-buffer from light position, store distance

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 3 D 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!!

Shadow Map • Advantage: – Simple • Disadvantage: – Shadow distance from light position

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

Shadow Volumes • Create a shadow volume for each front facing polygon • Put

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

Shadow Volumes

Shadow Volumes

Using Shadow Volumes §Front facing polygon hides all in back (A); back-facing does not(C);

Using Shadow Volumes §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?

Shadow Volume Example

Shadow Volume Example

Shadow Volume • Advantage: – Object space precision • Disadvantage: – Polygon count explodes

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

Shadowing using Weiler. Atherton Algorithm • Using the Weiler-Atherton visible surface determination algorithm twice:

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)

Algorithm 1. Perform Weiler-Atherton algorithm to extract visible polygon fragments to the light source

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

WA Shadowing

WA Shadowing

Shadows – Span line • Pre-process – Project all polygons onto a sphere center

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 a list of polygons that will cast shadows on it

Shadows – Span Line §Run time, use a modified span-line rendering algorithm §For each

Shadows – Span Line §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

Three cases of spans • Shadow polygon does not cover the current scan-line (span)

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

Span-Line Shadow • Object space • High time complexity

Span-Line Shadow • Object space • High time complexity