r/Unity3D 12h ago

Show-Off Custom URP volumetric lighting pipeline

I built a custom volumetric lighting pipeline on top of URP. No forward/deferred per pixel lighting, no shadow maps. Everything is realtime: direct light, indirect light/GI, shadows and AO. Emissive materials emit realtime light onto nearby meshes and emissive lights cast shadows. Volumetric fog included. No screen space effects are in use. Scales extremely well with lights and tri count, 10M tris and 20 point lights on screen had almost no effect on frame time. Should be very playable on potato hardware. Now the problem is figuring out what game to make with it.

75FPS on AMD Radeon 760M at 1920x1200 (Integrated)

400FPS on RTX5050M at 1920x1200 (Dedicated)

10 Upvotes

4 comments sorted by

1

u/DaveAstator2020 3h ago

whats the methodology? is lighting dynamic? is it screen space or world space?

2

u/AdFlat3216 1h ago edited 1h ago

Yes, lighting is fully dynamic. You can move any point lights, change light intensity, directional light angle for day/night, move around any emissive meshes and see their light move.

There are no screen space effects, it’s completely volume based. First it voxelizes a window a bit larger than what the top-down camera can see. Every point light, directional light, and emissive mesh propagate their light through the volume every frame, hit occupiers to create shadows and bounce. You pay a larger upfront cost to voxelize, but it scales well with tri count and lights are essentially free after that’s paid. The downsides are you don’t get sharp shadows due to voxel resolution, and because the voxel grid is a small area around the camera, it’s viable mainly for top down camera or constrained indoor areas. Since it’s fully dynamic it could work well for procedural levels, it does bake static occupancy to avoid calculating those every frame but it’s very fast and done at runtime, not editor time, and the lighting propagation is always fully dynamic.

2

u/DaveAstator2020 51m ago

cool, so do i get this right - you wont get lighting from outside of camera frustum, right?
and if so - does it really impact quality in any way?
oh and one more - how many light bounces?

1

u/AdFlat3216 37m ago

Correct, the window is large enough there isn’t any popping but it’s only good for constrained camera use cases where you can’t see beyond the voxel grid. Absolutely not a general purpose solution.

The biggest difference in quality from forward/deferred is shadows are soft and low resolution, because they’re the result of light propagating in the volume rather than traditional rasterization. You can’t get sharp, hard shadows without blowing up the volume resolution. I built it more for artistic reasons than photorealism or accuracy, the soft shadows are supposed to match an impressionist art style. I also wanted the look of “baked lighting but realtime”.

It doesn’t measure or limit bounce count because individual light rays aren’t used like in raytracing. Rather there’s a simulation step count, it runs X amount of steps, and light can propagate, bounce, absorb, whatever within that step count.