Exercise | Solution |
---|---|
Part 1The scene to be rendered consists of three quadrilaterals (quads). One is a large texture mapped quad in the plane y = −1 (x in [−2, 2], z in [−1, −5]), the others are smaller quads colored red. Let us refer to the large quad as the ground. One of the two smaller quads should be parallel to y = −1, but placed above the ground (y = −0.5, x in [0.25, 0.75], z in [−1.25, −1.75]). The other should be perpendicular to y = −1 with two vertices intersecting the ground (x = −1, y in [−1, 0], z in [−2.5, −3]). Create a WebGL program that draws this scene. Here are some steps:
|
|
Part 2A light source position is needed to cast shadows. Introduce an animated point light that circles the scene with circle center (0, 2, −2) and radius 2. Implement projection shadows using the following steps:
|
|
Part 3One problem with shadow polygons is that they are drawn even if there is no ground polygon. Use the depth buffer with a depth test function that accepts fragments with greater depth values to draw shadow polygons only if there is also a ground polygon. Handle z-fighting using an offset in the projection matrix. [Angel 8.11.5]Introduce a uniform visibility variable in your fragment shader. Use this variable as a multiplication factor to draw the shadow polygons in black. |
|
Part 4The black shadows seem too dark. We would like to see a darker version of the ground texture in the shadows. Semi-transparent shadow polygons can achieve this effect. Enable blending and set an appropriate blending function to render a darker version of the ground texture in the shadows. [Angel 7.10-7.10.3] |