Home | Lehre | Videos | Texte | Vorträge | Software | Person | Impressum, Datenschutzerklärung | Blog
Index Buffer
Most surfaces consist of connected triangles, what means that most
vertices are shared between several triangles. It is not efficient to store
three vertices per triangle, neither concerning memory use nor concerning
the computation of 3D transformations. Instead, store each vertex only
once and tell the graphics card how to "connect the dots". This is done
through an index buffer: an array of integers giving the number of the
vertices in the order in which they are to be connected, i.e., three numbers
per triangle. See demo.
Reflection Models
Real surfaces can display extraordinarily complex light reflection behavior:
Think for instance of perls or of holograms. In basic computer graphics,
the reflective behavior of a surface is approximated using four additive
components ("Phong model"):
-
Emission [Ausstrahlung]: The surface has a certain color, irrespective
of light sources
-
Ambient [Umgebungs-...]: The surface shows a base color irrespective of
direction or shadowing.
-
Diffuse [diffus]: The surface shows matte reflections.
-
Specular [glänzend] The surface shows glossy highlights. Highlights
on highly polished materials have a small diameter.
The diffuse component changes with the surface orientation towards the
light. Let n be the normal vector at a surface point, i.e., a vector
of length one (unit vector) perpendicular to the surface and pointing outside.
Let l be a unit vector pointing from this point to the light source.
If f is the angle between both vectors, then
the lighting will be proportional to cos(f),
which can be computed easily by forming the dot product of n and
l.
The specular component changes not only with light direction, but also
with viewing direction. Let v be the unit vector pointing from the
point on the surface to the viewer. The viewer looks straight into the
highlight if we have a mirror-like situation, i.e., n is half-way
between l and v. Thus, form the "half vector" h
:= (l+v)/|l+v|, another unit vector. If h
= n, the viewer looks at the center of the highlight. Thus, use
the dot product h.n to control the amount of light. However,
this expression decays too slowly as the viewer moves away from the center
of the highlight. We take the n-th power ("Phong exponent", n
= 10...100) to accelerate the decay: (h.n)n.
Note that the point of maximum brightness of the diffuse component does
not coincide with the center of the specular highlight. The latter depends
on the position of the viewer, whereas the former does not.
According to physics, the effect of a point light source should decay
with the square of the distance between light source and surface. However,
this leads to overly dark images because we do not yet take indirect illumination
into account in a reasonable manner. Typically, one sticks to linear decay
or no decay at all (see demo).
Smooth Shading
On standard graphics cards, these lighting computations [Vorsicht: nicht
"lightning"] happen per vertex. The resulting colors are interpolated
across the triangular faces to yield quite smooth shading ("Gouraud interpolation";
demo in DirectX and Cinema 4D). However, any small highlight in the center
of a face will be missed; furthermore, sharp highlights reveal the underlying
triangular structure. Thus, standard offline renderers use the more expensive
"Phong interpolation", in which the normals instead of the colors are interpolated
across the faces and the lighting model is evaluated per pixel (demo in
DirectX). Using pixel shaders, this can be done on current graphics hardware,
too.