Download

First Pass Realtime Volumetric Light Scattering

EXPERIMENTAL Volumetric Light Scattering Effect - right now should only be used in a testing environment – will update when it’s considered production ready.

The “graphicsdemos” project contains the project I used to make the forest v2 demo.

Github(Experimental Feature)
https://github.com/jmarshall23/UnrealEngine

Known Bugs:

  • Performance - VLS Render pass runs at 2.2 ms
  • Quality - Need to get in the bilateral upsample filter, for now you can sacrifice performance for quality by decreasing r.CVarVolumetricLightScatterDownSample
  • Having more then one VLS in a scene can cause issues - workaround turn off VLS lights when they are out of view with a trigger.
  • Only been tested with Spot Lights
  • Spot Light is doing a sphere intersection test to determine wether or not the ray should get drawn - this makes the VLS look kind of wierd - will get fixed when I switch it over to a cone intersection test.
  • VLS Gets brightner sometimes depending on how close you are to the camera.
  • Toggling on and off VLS doesn’t work right.

Current VLS Light Options:
VLSEnable.png

  • Enable Volumetric Light Scatter - Toggles VLS on or off for a given light.
  • Num VLSRay Steps - This is how many raymarches to do for the VLS highering this number can fix banding, lowering it can cause more banding but will speed up the shader.

Forest Demo v2 and Fan

Looks Cool I would love to see where it goes.

Just updated the video on the first post that shows a better use case, I fixed some bugs, made VLS respect light color.

Lookin good man!

Very nice.

This is looking awesome!, how is the performance hit?

VLS isn’t free, it should not be a replacement for cheaper ways of doing god rays. Were VLS really works well is were the light is moving so the rays are moving, or a lot of objects(or one big object) is casting a whole bunch of rays. On NV 600 series cards or higher you should be able to get 1 or 2 VLS lights in a scene going at once and still get around 50-60ms. This shader is very memory bound(as it has to sample from the shadow map for each ray march that is inside of the spot light cone), but I have gotten VLS in under 5 or 6 ms on console hardware.

Some good use cases on games I’ve shipped with VLS enabled:

     1) A VLS light is shining down or coming from the floor going up to the ceiling and have a big boss spawn and flex it's muscles and do a bunch of scarey stuff. The VLS amplifies the mood.
     2) VLS shinning through tress in a forest were the leafs are moving.
     3) AI Flashlights(NOT PLAYER FLASHLIGHTS).
     4) A big fan with a VLS light behind it.

An example of when to not use VLS would be god rays shinning through a church window that’s high up were the player never would get inside of the ray.

That’s very cool—I’ve been wanting this type of feature for a while.

This is awesome jmarshall23, keep up the good work!

Hey this is nice, i think i see this in Tesseract, probably you can check the code http://tesseract.gg/ to have more references there are too Realtime GI.

Added a new image shaved off 10ms off the shader, and added attenuation to the rays.

Can you try it with a tree instead of bars ?

Good work by the way. :wink:

I’d love to see some more images through different materials as well!

Updated video with the VLS through trees.

This particular situation would be great for a UFO flying over a forest or light from the moon.

Redid the forest demo and added a giant fan demo after it.

Looks great! Good job.

Very impressive.

What would really make me happy, and probably involve throwing money at my screen - is if the volumetric scatter can be modified via a volume texture (say a 3D noise to simulate light passing through varying densities of atmospherics)

That is a great idea but the VLS pass is very memory bound as it is, I feel that adding another sampler during the raymarch might not be worth it. Basically during the VLS pass were doing a bunch of random reads into the shadow map texture, so the L2 cache on the GPU is constantly pulling from VRAM, causing whatever wavefront is processing that part of the shader to basically stall, while it waits for data. I do plan on adding VLS “cookie” textures which would just be a alphed texture that would get copied on to the shadow map that would help people carve out various rays without having to make a bunch of geo for it.

There are a couple ideas that would be cheaper; we can calculate 3d noise of the fly based on various parameters, or we can have a VLS only shadow pass that would render all the same geo as the regular shadow pass but would have VLS only geo inside of it. I don’t know if particles currently cast shadows in UE4, but we can maybe get something to work that would get you close to what your looking for.

VLS isn’t ALU intensive so doing 3d noise on the fly might be a viable option.

It doesn’t necessarily need to work with particles. Just being able to multiply the final colour of the VLS with a 3D fractal will suffice.

Yeah I was just trying to come up with a way to get the same effect without sampling from a pre-generated 3d fractal noise texture during the VLS pass. Rendering geo is way cheaper and might give you what your looking for(if not I can always get something in and we can measure the performance).