Adding Shadows: - Shadows Make An Image Much More Realistic
Adding Shadows: - Shadows Make An Image Much More Realistic
Adding Shadows: - Shadows Make An Image Much More Realistic
• Shadows as Texture
• Shadows Using a Shadow Buffer
Shadows as Texture
• The problem is to compute the shape of the shadow that is
cast.
• The shape of the shadow is determined by the projections
of each of the faces of the box onto the plane of the floor
using the source as the center of projection. The shadow
is the union of the projections of the six faces.
Shadows as Texture
• After drawing the plane using ambient,
diffuse, and specular light contributions,
draw the six projections of the box’s faces
on the plane using only ambient light.
– This will draw the shadow in the right shape
and color.
• Finally draw the box. (If the box is near the
plane parts of it might obscure portions of
the shadow.)
Shadows as Texture
• The projection of a vertex V on the original
object is given by V1 = S + (V - S) ([n·(A -
S)]/[n·(V - S)]), where S is the position of
the light source, A is a point on the plane,
and n is the normal to the plane.
Shadows Using a Shadow Buffer
• This method works for non-planar surfaces.
• The general idea is that any point hidden from the light
source is in shadow.
• A second depth buffer (the shadow buffer) is used. It
contains depth information about the scene from the
point of view of the light source.
Shadow Buffer Steps
• 1). Shadow buffer loading. The shadow buffer
is first initialized with 1.0 in each element, the
largest pseudodepth possible.
• Then, using a camera positioned at the light
source, each of the faces in the scene is scan
converted, but only the pseudodepth of the point
on the face is tested.
• Each element of the shadow buffer keeps track
of the smallest pseudodepth seen so far.
Shadow Buffer Steps
• Example: Suppose point P is on the ray from the source
through shadow buffer “pixel” d[i][j], and that point B on
the pyramid is also on this ray. If the pyramid is present,
d[i][j] contains the pseudodepth to B; if it happens to be
absent, d[i][j] contains the pseudodepth to P.
Shadow Buffer Steps
• The shadow buffer calculation is
independent of the eye position.
– In an animation where only the eye moves,
the shadow buffer is loaded only once.
– The shadow buffer must be recalculated;
however, whenever the objects move relative
to the light source.
Shadow Buffer Steps
• Render the scene. Each face in the scene is
rendered using the eye camera as usual.
• Suppose the eye camera sees point P through
pixel p[c][r]. When rendering p[c][r] we must find
– the pseudodepth D from the source to P;
– the index location [i][j] in the shadow buffer that is to
be tested;
– the value d[i][j] stored in the shadow buffer.
• If d[i][j] is less than D, the point P is in shadow,
and p[c][r] is set using only ambient light.
• Otherwise P is not in shadow and p[c][r] is set
using ambient, diffuse, and specular light.
OpenGL Pipeline with GLSL
• The pipeline begins with a collection of polygons
(vertices) as input, followed by a vertex processor
which runs vertex shaders.
Drawing shadows
• Step 1 : Activate and position the shadows
• Step 2 : Draw the shadows only
• Step 3: Draw the shadows from above
• Step 4 : Soften the shadows
• Step 5 : Create a new shadow Material
• Step 6 : Apply the material to a ground
polygon
• Step 7 : Shadow Mapping
BUMP Mapping
• Bump mapping is a technique developed
by Blinn, to give a surface a wrinkled or
dimpled appearance
Bump Mapping
• The figure shows an example of a torus
with and without bump mapping
Reflection Mapping