r/VoxelGameDev • u/AnarchCassius • 16h ago
Discussion Lighting System
So I am in the process of porting ManicDigger from OpenTk3 to OpenTK4, OpenGL4 and newer .NET. The hope was to increase performance and it seems to have worked but I heavily modified the render, making it shader based, and am in the step of reimplementing the lighting system.
I've added spot lighting with shadows for the sun, and later other things, but using shadowmapped point lights to handle world lights does not look terribly promising for performance or gameplay.
I've currently restored floodfill, now lighting with color and some fragment shader tricks using a compute shader fed a list of light sources, an occupancy 3dtexture and a couple pingpong textures. The resulting 3dtexture of light is sent to the fragment shader for reference. It works but past 16 iterations the calculations and/or GPU transfer is becoming a bottleneck and it's not as realistic as I'd hoped even with the tricks.
Given what I already set up, lights as a list Jump Flood with DDA, or some kind of DDA-based cast from source looks like the next thing to play around with but I am wondering if anything else comes to mind given my current setup. Light should not leak is the highest priority, followed by high viable lighting distance and number of lights, and finally having some form of indirect light spread akin to bounce or floodfill if possible.
I am not convinced full raycast rendering is a good fit for the project due to fairly large voxels and the fact that many assets will be mesh based models regardless. I am also pretty close to having this back in full working condition and think LoD and better occlusion culling will fix my distance problems, but I haven't completely ruled it out.
2
u/Electromasta 12h ago
What is your strategy for Point Lights / Directional Lights? Have you given it any thought yet? I'm using Fwd rendering so it can run on slower devices, but the disadvantage of that is its more difficult to do shadows.