3-D PSRDnoise tutorial

Page 1 2 3 4 5 6 7

6: Bump mapping

Procedural 3-D texture mapping is eminently suited for bump mapping. When using a 2-D texture, there is considerable hassle to work out the relation between its gradient in texture space and the surface normals in object space. With a 3-D texture, texture space is object space, so there is no need to transform between the two, and the computations become really simple. Using the analytical gradient from "psrdnoise", it becomes even easier.

The computations in the shader below are explained in a separate document: "Bump mapping, procedural style" (PDF). Credit should be given to Morten Mikkelsen for pointing out the advantages in his dissertation in 2008.

Please note that we are "faking the lighting" in this shader by assuming that there is a simple directional light from the front upper right. In order to make the example as clear and simple as possible, we do not take into consideration any light sources defined in the Three.js scene.

		// Fragment shader code goes here