Home | Lehre | Videos | Texte | Vorträge | Software | Person | Impressum, Datenschutzerklärung | Blog
Shadows
-
Introduction
-
Shadows are necessary to create realistic images.
-
Shadows aid the viewer in perceiving a 3D scene.
-
Point light sources and directional light sources produce hard shadows.
-
Extended light sources produce soft shadows (center: "umbra", transition
region: "penumbra" [Halbschatten]).
-
There is a zoo of techniques to render shadows both offline and in real
time.
-
Techniques to compute shadows offline
-
Ray tracing
-
hard shadows
-
colored shadows under colored transparent objects, but no refraction in
shadows (cf. caustics)
-
Demo: Cinema 4D
-
Distribution ray tracing
-
physically correct soft shadows
-
noise vs. computation time
-
colored shadows under colored transparent objects, but no refraction in
shadows (cf. caustics)
-
Demo: Cinema 4D
-
Radiosity
-
physically correct soft shadows
-
no transparency
-
Demo: Cinema 4D (Note that Cinema doesn't employ the traditional radiosity
method but an extended ray tracing.)
-
Techniques to compute shadows in real time (or offline)
-
Flattened objects
-
Apply a certain matrix to flatten an object (see Matrix.Shadow in Managed
DirectX).
-
Render the result for instance using a semitransparent gray color.
-
Only works for level undergrounds.
-
Demo: student work in OpenGL
-
Shadow volumes
-
Idea: Regard the set of all points in space that are shadowed by an object
as its "shadow volume". If a viewing ray starts outside of the volume and
enters this volume as often as it leaves it, the ray hits a surface without
shadow; otherwise, the ray hits a spot within the shadow.
-
Generate the shadow volumes of all objects as (virtual) 3D objects: Find
the silhouette of the object as seen from the light source; extrude this
silhouette to infinity. This can be done as a preparatory step, but may
also be done using a vertex shader. Demo with DirectX.
-
Typically, the rendering is done using a stencil buffer: Render the scene
as usual, but only with the ambient lighting. Set the stencil buffer to
0 everywhere. The render the shadow volumes with the usual depth test.
However, switch off writing to the color and depth buffers. Rather, increment
the stencil buffer on frontfacing sides and decrement it on backfacing
sides. Finally render the scene with lighting, but skip all pixels where
the stencil buffer is not zero.
-
Demo with Managed DirectX (part of my contribution to the book ShaderX3)
-
Problems: geometry of the shadow volumes has to be computed; rendering
of shadows volumes needs to access many pixels many times; non-closed objects
are difficult to treat; only hard shadows; no transparency
-
Shadow map a.k.a. shadow buffer (often found in offline rendering software,
too)
-
Render the 3D scene as it appears from a light source; render only the
depth buffer, which becomes the "shadow map". Then render the scene as
usual and use the shadow map to decide whether or not a given point is
shadowed. To do so, regard the light ray from the light sources to the
given surface point. There is a pixel in the shadow map that (approximately)
corresponds to this ray. If the depth value stored for this ray is smaller
than the distance of the given point from the light source, this point
is inside the shadow.
-
Problems: additional rendering pass to compute the shadow map; texels of
the shadow map lead to ugly borderline between lit and shadowed parts;
no transparency (Note that Cinema 4D offers a specially extended shadow
map method that can do this.); soft shadows can be produced by averaging
over neighboring texels in the shadow map ("percentage-closer filtering"),
which, however yields physically wrong results
-
Demo: Cinema 4D
-
Most vexing problem: Due to the limited resolution of the shadow map, we
need some kind of bias to prevent producing shadows on the lit faces themselves.
Hence, the shadow "starts too late".
-
Demo: ATI Shadow Map shows the usual strange patters on lit faces when
the bias resolution of the texture is too coarse.
-
Demo: Maya, which as a default doesn't use the front faces of a objects
for the shadow map but rather forms a middle layer to sidestep many problems
related to bias
Stereoscopy
-
Principle
-
Generate one image per eye: "real" 3D
-
Problem: Viewer can't control the distance of his/her viewing focus; hence,
stereoscopy often uses an infinitely far focus, that is, the directions
of the two eyes form parallel lines
-
Problem: The eyes' lenses adjust themselves to the real screen. Thus, the
brain receives a perception from the muscles that contradicts the presented
geometry. Ongoing research tries to solve this problem.
-
Problem: If the display is attached to the head ("head-mounted display",
HMD), the 3D scene seems to rotate as the viewer turns his or her head.
A head tracking device is needed to compensate for this effect.
-
Problem: "VR sickness" caused for instance by the delay between the motion
of the head and corresponding changes in the display
-
Output
-
Present two images side-by-side; view them with parallel eyes orientation
or with crossed eyes
-
Red-green glasses and corresponding images (anaglyphic technique)
-
LC shutter glasses and fast CRT display: Show the left and the right frame
alternatingly
-
Use two data projectors [Beamer] with polarizers, a silver screen that
preserves polarization, and polarizing glasses
-
Head-mounted display with one LCD for each eye
-
Lenticular lenses [Riffellinsen] on paper
-
Lenticular lenses in front of an LC display
-
Stripe mask in front of an LC display, possibly with head tracking
-
Complex stripe mask to project several (e.g., eight) different images.
Demo: X3D-Display. Problems: severly reduced resolution and brightness
-
Software development
-
Quad-buffering in OpenGL
-
Front and back buffer separately for left and right images (four buffers,
hence "quad"); before issueing a rendering command, you have to specify
for which buffer it is intended.
-
Only present on expensive 3D cards (there is one in the lab); these cards
have a 3-pin output jack to control shutter glasses.
-
Nvidia stereo driver
-
Add-on to graphics driver; active in full-screen mode
-
Renders every frame twice with two different views; builds images for shutter
glasses or red-green glasses
-
Runs with regular 3D software
-
Shutter glasses are connected via special VGA splitting cable.