Weekly post
July 6, 2024 • 1 min
- Since SDF lighting was so laggy in large maps, tried another method, "polygon lighting", using boost::geometry to construct visibility polygons. It is slow on the CPU instead of GPU with this method. Performance was not good enough, so abandoned it. Left it working ok though.
- Added "ambient occlusion" for nanovg shape rendering. Really it's just a drop shadow around all shapes. Was very easy to add. Steps for my polygon lighting
- Make multipolygon out of all fixture shapes in the query region of a box around the light
- Make multipolygon by subtracting box by the multipolygon which is union of all polygons produced above
- Make segments from this multipolygon
- Find visibility polygon from these segments
- Triangulate visibility polygon What went well
- learned about a new form of lighting but it doesn't work well enough due to computational complexity and cpu usage. Learned about another form of lighting - deferred 2d lightning - which I could try implementing in the future: use a stencil buffer and just render quads for all the line segments on gpu into making the quads take out parts of the stencil and then render the lights to each quad using each light's stencil buffer. Since playtest is coming up in 14 days I will do it later.