Download Shadow details explanation and more Exercises Computer Graphics in PDF only on Docsity!
Interactive Computer GraphicsG. Kamberov 1
Shadows and Transparency
Interactive Computer GraphicsG. Kamberov 2
Introduction
- Shadows in CG
- Why? What?
- Basic Algorithms.
- Transparency
- Readings:
- FVDFHP Chapter 14.4 and 14.
- Angel Chapter 5.10, Red Book 4th^ edition, 446-450, 485, 603 and ff; Real Time Rendering by Haines and Moller (RTR), p. 177.
- Tom McRaynolds, Blythe, D., Grantham, B., Nelson, S., "Programming with OpenGL: Advanced Techniques", Course 17 notes at SIGGRAPH '98, http://www.opengl.org/resources/tutorials/advanced/advanced98/notes/
- Advanced Shadow Map Parameterization www.mpi-sb.mpg.de/~tannen/papers/diploma.pdf
Interactive Computer GraphicsG. Kamberov 3
Shadows
Why do we need them?
The “optics” and geometry of shadows.
Phenomena.
Basic algorithms
OpenGL tools
Interactive Computer GraphicsG. Kamberov 4
What does a shadow do?
- • ShadowsShadows provide
- Visual cues about the spatial relationships between the different components in a scene.
- Additional information and views of objects
- Anchors: Without shadows objects seem to float/hover.
- Improved “realism”.
- Lighting environment cues
Interactive Computer GraphicsG. Kamberov 7
No Shadows vs Shadows
Interactive Computer GraphicsG. Kamberov 8
SHADOW defs
- Shadow = region of relative “darkness” in
an illuminated region due to light
occlusions by objects in the scene.
- Colored shadows:
- multiple lights
- filtering
- diffraction
Interactive Computer GraphicsG. Kamberov 9
Umbra, penumbra.
- Umbra: area in full shadow
- Penumbra: boundary area; gradient from full shadow to light
- Penumbra appears when we deal with extended light sources.
Interactive Computer GraphicsG. Kamberov 10
Penumbra
- To understand the penumbra think of the extended light source as a collection of point sources.
- Parts of the shadow receiver will be illuminated by some (but possibly not all) of these point sources
Interactive Computer GraphicsG. Kamberov 13
Shadow algos
- Fake Shadow
- Planar Projection
- Shading and shadows
- Shadow Volume
- Shadow Z-Buffer
Interactive Computer GraphicsG. Kamberov 14
Fake shadows
- Special purpose algos. Work only in special cases.
- Basic example
- project or use some other shape aprox of the object onto a plane (the floor).
- keep the shadow as part of the object description
Interactive Computer GraphicsG. Kamberov 15
- See Ch 14 in the red book. The Angel
book CD has a sample code.
- Project onto each receiver/ground plane
with COP the light source.
- Limited to planar receivers, anti-shadow
errors (if top most “occluder” vertex is
above the light source).
Projection shadows
Interactive Computer GraphicsG. Kamberov 16
Projected shadows continued
Interactive Computer GraphicsG. Kamberov 22
Z-buffer outline
- Render the scene from the camera view using z-buffer algorithm - z-depth = distance to light source
- Render scene with eye=COP
- A visible point is in shadow if it is farter away from the light source then the current value in the shadow buffer.
Interactive Computer GraphicsG. Kamberov 23
Shadow map/z-buffer alg. WILLMS
- Render the scene from the view point of the light source. Store the z-buffer into a “shadow map”.
- Render the scene from the camera view. Let the T be the transform re-aligning the camera coordinate system to the coordinate system of the light source.
- For each pixel in the camera view let P=(x,y,z) be the 3D coordinates of the corresponding visible scene point. Transform the camera coordinates (x,y,z) into light source coordinates (u,v,w) (u,v,w)=T(x,y,z).
- Let q be the “z” value at the (u,v) pixel in the shadow map.
- If(q < w) then P is in shadow not lit by this source else P is shaded a lit by this source Do this for each source if multiple sources are present.
Interactive Computer GraphicsG. Kamberov 24
z-bfr
- Pro:
- Works for any object that can be scan converted.
- Real-time hard shadows
- API & hardware implementations
- Con:
- Could be slow cost: O (number of sources).
- Aliasing problems.
- Issue what if the light is inside the scene? - SM models light with a single view frustum - For inside point sources could use six-view cube. Stitching problems
Interactive Computer GraphicsG. Kamberov 26
Shadow volumes CROW
- Three steps:
- silhouette generation
- drawing of shadow volume(s)
- rendering the shadow
Interactive Computer GraphicsG. Kamberov 29
Lit/No lit algo problems
- Viewer is inside a SV
- Shadow polygons intersect near plane of
the view frustum
Interactive Computer GraphicsG. Kamberov 31
Transparency
Interactive Computer GraphicsG. Kamberov 32
Outline
- Simple techniques. No special
hardware required (as long as fill
pattern/stippling is supported), rendering
order does not matter
- Screen door transparency
- Polygon Stippling (OpenGL support)
- Blending - based techniques Use the a
bit in RGBA. Rendering order may
matter.
Interactive Computer GraphicsG. Kamberov 33
Screen door transparency
- To make a polygon to appear transparent render it with a checkerboard fill pattern, every other pixel is rendered - an object behind this polygon is 50% visible.
- Cons & limitations (i) single transparent polygon is possible; (ii) allows only 50% transparency
- A related technique supported by OpenGL uses polygon stippling. - Red book 4th edition, Chapter 14, p 590 (Cheesy translucency), and Chapter 2 ( Stippling polygons, pp 59-63 )
Interactive Computer GraphicsG. Kamberov 36
Blending without depth sorting
- Z-buffer approach
- Enable z- buffer
- Render opaque objects
- Make z-buffer read only glDepthMask(GL_FALSE);
- Enable blending, set blending function
- Render translucent objects
- Blending function approach
- Enable z- buffer
- Render opaque objects
- Enable blending, set blending function to c= Ac (^) s + c (^) d glBlendFunc(GL_SRC_ALPHA,GL_ONE);
- Render translucent objects