How to generate God Rays?

Hi, God Rays effect is very beatiful, this example come from Maya, I found the Volumetric LightScattering post-process can achieve it, but it’s a pity, when mesh is off screen, Volumetric LightScattering disapear, I knew it need a camera. How can I use other methods to generate God Rays?
If Volumetric LightScattering can generate light when it is off screen, I think the thing will be simple.


Hm, I still see the effect even when mesh is offscreen. Two screenshots below - one with the mesh on screen and the other just slightly off. I do see more artifacts the further I move the mesh from the object around which the rays flow. Maybe you can make a Playground with the issue you’re facing?



1 Like

Thank for you help, I made two Playground, this is I want to achieve, it’s beatiful God Rays, but mesh is shown.

var camera = new BABYLON.ArcRotateCamera(“Camera”, -Math.PI/3, 1, 20, new BABYLON.Vector3(-9,-9,0), scene);

I hope mesh is off screen and the ligtht is maintained. However, the playground has nothing.

var camera = new BABYLON.ArcRotateCamera(“Camera”, -Math.PI/3, 1, 20, new BABYLON.Vector3(-13,-13), scene);

I expect effect is this.

1 Like

Here is one more example.

The mesh is hidden , the light disappear.

I think the normal situation should be like this.

1 Like

You will not be able to reproduce the exact same effect than a precomputed renderer like Arnold. BUT, as usual in realtime, you can fake it!

An old but/and efficient way is simply to model and texture the light effect, like in this example: Richard's Art Gallery - Audio Tour - Download Free 3D model by rlockett (@rlockett) - Sketchfab
Your FPS will love it.

Note that the effect you want may be named “volumetric fog” rather than “god rays”. Example through the Unreal doc’: Volumetric Fog | Unreal Engine Documentation (Note also that this was add to Unreal only on the 4.16 version, so it’s relatively new, and I’m not sure this effect will be availabled easily through webGL?).

1 Like

I don’t think you will be able to do what you want because the post process depends on the fact there are some pixels in the screen that corresponds to the mesh emitting the god rays.

For your first case, you could achieve what you want by drawing in a larger canvas and displaying a smaller part. But for the second case I don’t see any solution.

It seems very difficult to achieve it, I will use texture, thank you!

1 Like

Sometimes I am too idealistic, thank you!

Something like this, I just stopped sampling noise on my volume cube and set it to a base density value and we have volumetric fog and this seems to not be that intensive of a effect at all when not procedurally generating noise ^_^.

I am going to add other light support as well, right now it’s just directional lights but I know how to add spherical lights, and maybe area… but I have lots of other stuff on my plate right now.

Ill post the gitHub repo for the clouds/fog cube here but if you cant wait there is a topic here with a PG and a less refined version Struggling to Convert Global Position to Shadow Map position



Awesome! But my FPS is only 17. :joy:
That is unoptimized and using nosies, like I said when its not procedural and just returning a solid value for the density it makes little to no impact.

there would still need to be a bunch of tweeks to fix this, but yeah the idea is super doable.


'could be great to see this effect on a more complex scene, like the Sponza one.

1 Like

It’s what I’m looking for! Will it be more beautiful? :grinning:

I will study it.:+1:

I get a image from Richard’s Art Gallery.

It looks like the light effect use this image, now I try to achieve a light beam, the black background can’t be removed, I did not find a attribute, just like textureMask. Can you give me some advice?

If you hook up the Sponza Scene in a PG, ill hook up some volumetric fog.

after talking I really thought about it all and realized if we are doing it as a post effect from just the user perspective and toss out the whole container cube idea I could prolly really control the performance, and we could deploy fancy boy effects for little cost.

1 Like

You need to enable alpha blending:


That is AWESOME!

Technically beautiful. Gr8 work Pryme8 on volumetric fog.

Hot off the burner so cool.

Look forward to fx, ops, and other cool things.

:eagle: : )

thank you!