Within my current project, I have implemented a ShaderMaterial to depict terrains. The positions of the vertices are adjusted in the vertex shader based on information from a height map texture:
vec4 mvPosition = modelViewMatrix * vec4( position + normal * heightMapScale, 1.0);
gl_Position = projectionMatrix * mvPosition;
The terrain itself appeared fine, but upon attempting to place objects onto it, I noticed some peculiarities with the shadows. It seemed like the vertices were unaware of their updated positions :(
If you're interested, please follow the links below for screenshots and a live demo (Apologies for being unable to post images due to reputation limitations)
Screenshot: https://i.sstatic.net/Xw3ZI.jpg
Live Demo: http://jsfiddle.net/b2bfm8q3/2/
Observe how the cube on the left side displays a correct shadow, while the one on the right does not due to a mismatch in the shader that shifts the face upwards.
Any thoughts on how to address this issue?
Thank you