Shadow for instances

I think we’ve got it! Thanks guys!

I took my first Pen and tempered a bit with it to see what does and what does not help to get those shadows. Let’s summerize all findings:

  1. When using Directional Light, you do need a customDepthMaterial
  2. When using PointLight, you do need a customDistanceMaterial
  3. It does not matter if you modify a material using onBeforeCompile, or take the shaders from THREE.ShaderLib, modify them and feed them to ShaderMaterial.
  4. The light.shadow settings are very important and can break your shadows.

Here is the pen I used to test some combinations: https://codepen.io/fedorvaneldijk/pen/OYYNow

One more question remains: the cubes now cast shadows, but they are not receiving shadows. To me this is a lesser issue, but while we are at it… any ideas?