three.js-normal-map-0 icon indicating copy to clipboard operation
three.js-normal-map-0 copied to clipboard

The continuing saga of displacement and normals in three.js

three.js-normal-map-0

A demo of a normal map in three.js, showing some problems and solutions:

Getting normals to work

I asked: "Why do these normals look twisted?" http://stackoverflow.com/questions/17453298/twisted-normals-with-the-three-js-normal-shader-r-58

Adding a displacement map

I asked: "Can normals be recalculated post-displacement?" http://stackoverflow.com/questions/17528878/compute-normals-from-displacement-map-in-three-js-r-58

Getting specular right

Getting normals from displacement map

  • Displacement map used as a bump map - using pieces of the normalmap and phong shaders, showing noisy but correct normals. This uses Morten Mikkelsen's method of taking the derivative of the heightmap: http://mmikkelsen3d.blogspot.sk/2011/07/derivative-maps.html

Getting specular right 2