I’m trying to make shadows work on InstancedBufferGeometry
mesh. I created the mesh and applied extended standard material to it. I modified vertex shader to offset each instance of geometry by random vector. Unfortunately it did not work as I was expecting. Mesh receives same shadow for all geometry instances. Later I learned that I need to apply customDepthMaterial
for shadows to work properly. So I crated new depth material that applies same vertex offsets as standard material. Sadly made no difference, all geometry instaces still receive same shadow.
Here’s my code: https://codepen.io/upgreidas/pen/VwVqMRK?editors=0010
You will notice that all grass blades darkens at the same time as shadow passes position of original geometry (0, 0, 0).
Relevant functions are:
setupGrass
- creates InstancedBufferGeometry mesh
overrideVertexPosition
- vertex shader modifications
Could anyone tell me what I’m missing for shadows to work? Thank you