Practical 3: Advanced Shaders: shadow maps and noise

The deadline for giving back Practical 3 is: Friday, December 2nd (midnight, European Time)

There are two independent parts in this practical: Shadow mapping and Procedural textures with noise. You can do them in any order.

Shadow mapping

shadow map Shadow map

We render scenes with shadow maps in two steps:

You will have to add shadow mapping to a shader that already does local illumination, such as 2_phong:

Start by computing shadow mapping without any bias in the depth comparison. You should get a picture that looks like the top picture (maybe with even more stripes). In a second stap, add the bias to the depth comparison. There are several bias methods: add epsilon, multiply by (1 + epsilon), take the slope into account, etc. Experiment with them, keep the one that seems to be most efficient / working for your test scenes.

Question: what happens when you query the shadow map beyond its boundaries? How can you detect is? What should you do? What should you do when w is negative?

Procedural textures with noise

In the shader noiseAlone there is a function, perlinNoise. This function computes a Perlin noise, as a function of position.

It takes several parameters: the number of octaves, the amplitude, lacunarity and persistence. You can act on these parameters, depending on what you need.

Perlin Noise, low persistance Perlin Noise, high persistance
Low persistence High persistence

Your work is to write shaders using this noise function to compute procedural material textures. Start with unstructured materials, such as marble or jade:

Buddha, with procedural jade texture Buddha, with procedural marble
Procedural Jade texture Procedural Marble texture

For these materials, you just need a mapping from noise to a 1D colormap, with linear interpolation.

Next, try a structured material such as wood. Start by defining a line, and compute the distance to this line. Use this distance to access a 1D colormap, giving a regular wood structure. Then, perturb this function with Perlin noise, resulting in irregular wood structure.

Buddha, with procedural wood texture, no noise Buddha, with procedural wood, with noise
Procedural wood, without noise. with Perlin noise