Transcribed from Slack:
- Shadows in elm-3d-scene are implemented using shadow volumes: the basic idea is that you take the faces pointing away from the light and 'push' them away from the light, keep the faces pointing toward the light in the same place, and add connecting faces between the two (via some magic in the vertex shader)
- This shape is then a 'shadow volume', and you can check whether a spot on a surface is in shadow by checking whether it is inside that volume (via some magic with the stencil buffer)
- Initially I was just using a huge default offset value of
1.0e9
to push back the 'back' faces, but it turns out that's too big for the default precision float value used on iOS - So the first fix (that I'd been planning to do at some point anyways) was to figure out a more reasonable offset value by calculating a bounding box for the entire scene, and using the diameter of that bounding box as the offset value
- Adding that logic in meant that I could also do something else that I'd been planni