maybe this helps,
this was the topic i opened about it: How can i "bake" a shadow onto a planeGeometry? very informative tips by @gkjohnson that helped a lot
and the new lightmap class, drei/AccumulativeShadows.tsx at 9baf3d86168f14d0a3a4754a037dc5ced00d7fe3 · pmndrs/drei · GitHub
- removed potpack
- removed uv2, changed shader into diffuse
- new uvmat shader discards all pixels
- removed attach logic, it takes a plane mesh and the regular scene
- will finally “bake” results when frames run out
it has new methods:
- clear() clears buffers and collects lights and meshes
- configure(object) set the plane
- prepare() sets all lights to 0, all meshes to a new uvmat
- finish() sets back all lights and meshes to normal
you use it like this:
- configure(yourPlane) once
- clear() once the scene has loaded fully
now the loop:
// Switch rando lights on
lights.visible = true
// Shut down all scene lights, all meshes get discard-uv-mat
plm.prepare()
// Jiggle rando lights
lights.children.forEach((light) => light.update())
// Let the LM render
plm.update(camera, 100)
// Switch lights off
lights.visible = false
// Restore scene
plm.finish()