One of the biggest drawbacks of vertex displacement mapping is that faces normals and then those of vertices are damaged since they are valid for
the un-deformed mesh. As we are inside a vertex shader, we can not access to the two other vertices that form the current processed face and then
we can not recalculate the normal...
But there are two manners to come out of this tricky problem. The first one is simply to not use... the normals! With static lighting
(like the lightmapping), the normal is useless since the lighting comes from the light-map.
The second manner is to provide the normal to the pixel shader. A simple method is to create a normal-map from the displacement map.
The normal-map holds normal vectors that are orientated to simulate the displacement map relief. This technique works quite well if we
forget some little imperfections like some areas that should not be lit...
The following picture shows the result of a BumpDisplacementMapping shader. Both displacement and normal maps have been created
from the base map (texture of stone). This project is available in the downloadable archive.
Fig. 5 - DEMO_bump_displacement_mapping.xml