A2
A2
- In pass 1, the objects are rendered from the point of view of the
light source and a 'shadowTexture' is used to store the depth (in
the light's CCS transformed to the range [0,1]) of each fragment.
You do not need to edit or compile any C++ code. You need only to
edit four shader files: a vertex shader and a fragment shader for each
of the two passes.
Step 0
This is best done on the CasLab Linux machines. Compile the code,
then run it as
The program should show an empty window with a coordinate system and
a rotating line (which points to the light source).
Important Note
You should NOT do the following in the order given. Rather, get some
output on the screen first, then incrementally change the code and
test each change by drawing the intermediate results to the screen.
For example, first get the objects drawn. You can ignore the Pass 1
shaders and get the Pass 2 vertex shader to compute *only*
gl_Position. Then get the Pass 2 fragment shader to *only* output
an arbitrary colour. Once this is done, you'll see an approximation
of the scene.
Note that much of the work (e.g. Phong illumination and texture
colour lookup) can be done independently of the shadowing.
Pass 1
The pass 1 shaders are used when the scene is rendered from the
light's viewpoint, using orthographic projection because the light
is directional. (A point light source would use perspective
projection.) See 'render' in renderer.cpp for the details.
[1 mark] Then compute the vertex's depth in the light's CCS, and
convert this to the range [0,1] and pass that value to the fragment
shader.
After this step, you should be able to press 'd' (for debug) and see
the red shadow map. Press 'd' again to see the normal view.
The pass 2 shaders are used when the scene is rendered from the
eye's viewpoint, using perspective projection.
Edit pass2.vert:
Edit pass2.frag:
[1 mark] Use the texture colour (if texturing) or the colour from
the vertex shader (if not texturing).
To Hand In