Starting from:
$30

$24

Lab 8Shadow Mapping Algorithm Solution

•    Create shadows cast by a point light source

    1. Place a camera at the light's position and see how close the nearest object is for every angle

    2. Decide wether a surface is in shadow by comparing it's distance to the light with the closest distance at that angle

How do we do step 1?

(getting the closest distance at each angle)


    1. Render a depth map onto a texture that shaders can then access

    2. Must create a projection and view matrix that define where the light is looking at

    3. Must create a framebuffer that allows opengl to draw onto the texture

Creating the texture and framebuffer
Placing the light and giving it a projection matrix
The shadow shader
all we care about is depth



vertex















fragment
How do we do step 2?
(deciding if a surface is in the shadow or not)



    1. Compute the distance between the 3D position of the fragment and the light

    2. Use the light's projection matrix to see where the 3D position of the fragments ends up on the depth texture

    3. Compare the computed distance to the one stored on the depth texture.

computed > depth texture => in shadow

More products