Home | Lehre | Videos | Texte | Vorträge | Software | Person | Impressum, Datenschutzerklärung | Blog
Shadows
-
Introduction
-
Part of Global Illumination (in the scientific sense, not in the sense
used in the marketing of 3D software)
-
Shadows are necessary to create realistic images.
-
Shadows facilitate to "understand" 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 planar 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 ("shadow acne") on
lit faces when the bias is to low for the given resolution of the texture.
-
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