Download

Custom volumetric light shader?

Hi,

i often read about the discussion how to implement volumetric lights and the only answer (if any) seamed to be a custom shader.
I read through a few documents and found some code snippets and algorithms, but I have honestly no idea, how to develop a shader that needs direct access to light sources. Simple post-processing won’t do the trick, I guess.

Has actually anybody ever done something like this? This problem is anything but new.

Cheers

Yes! I made stuff like this for my 2115 project! It was a mesh/material-based system, not post-process, though. I placed a single mesh with a bunch of ray beams shooting down in the water. Then I used my own custom code to map a texture to it, pan, and shift the UVs so all the godrays don’t appear to be the same object. But be warned, this method involves the use of a ton of translucency, which is quite expensive unless you have the hardware for it.

You can use the fresnel, pixel depth, and depth fade material nodes to make a material like this: fresnel makes the cones brighter in the center than at the edges, pixel depth can make it fade out as it is positioned further away, and depth fade can blend the light into any clipping planes with a smooth falloff. Once you have the material, map it to any model of a cone (preferably one with smoothing groups), and it will behave accordingly. Place those models as you would anything else, just make sure the material’s additive and the models are set to not cast or receive shadows. I would also use static lights to model the cone in lightmass so you have correct light bouncing. It’s not a perfect solution, and it’s expensive, but if you can get it working properly (especially once combined with particle effects), it’s beautiful.

Nice, I’ll keep that in mind for the godrays!

But the bigger problem is, that I primarily need dynamic volumetric lights, wich are able to cast shadows and change their shape accordingly. Though, it doesn’t necessarily need to be hyper-realistic.
Another (maybe easier) approach would be to create a big fog volume for the entire area, but I guess this would be to expensive. On the other hand… the room will be filled with 50+ independent light-sources, so maybe this could even be more efficient.

Btw… We’re about to use it in a showlight-simulation, so proper hardware will be available. These guys don’t care if this software needs a AAA PC. (but I hope it won’t ;))

It’s not really something that can be done with a shader, it would have to be a feature added to the lights. It’s something I’d like to have but I think we’ll have to wait until Epic adds it in. It’s one of the next-gen type features that games are getting now.

I’m working on a solution for light shafts and god rays. Similar technique to what I have going here…

Should be a day or two until I have a demo video.

https://www.youtube.com/watch?v=x_N1MpElRQY

You can build some easy-cheesy volumetric light with special materials. You can find examples of this technique in Strategic Game example and Blueprint feature sample

That’d be very exciting for many people.

The “easy-cheesy” approach uses static meshes, so they can’t cast shadows.

Hey dokipen, your volumetric tests are really cool! I can imagine you WETA folks don’t have that much spare time available :wink: yet I’m curious, are you still working on the solution for light shafts?

You’re right, time is precious to us Weta peeps. I did do a quick test of light shafts for stained glass windows using the particle method. It wasn’t too successful because of the random particle placement not giving a uniform look. I’m currently working on a procedural geometry slicing technique so that you get regular even slices that aim along the half vector between the camera and the directional light vector. I’m almost there. I’ve done the math to calc the slice angle, just need to do the geometry generation. This involves some edge/plane intersection stuff. But I know it’s going to look much better because I’m used to this rendering technique on a day to day basis. Will post updates when I can. Probably a week or two.