skip to Main Content
How to set up "God Rays" in Unity with Volumetric Fog & Mist 2

How to set up “God Rays” in Unity with Volumetric Fog & Mist 2


There is something special about lighting that multiplies the visual effect on a game by thousands of times. It’s not lighting in particular what we want to cover in this article, but it has much to do with the real king of this story. One of the many different fog solutions that our “Volumetric Fog & Mist 2” Asset can do is a “God Rays” effect, something you can’t miss when creating your Unity project if you want it to be perfect in all the visual aspects.

What are “God Rays” or “Crepuscular Rays”?

First of all, let me explain briefly what the term “God Rays” actually means. Also known as “crepuscular rays” or “sun shafts” they are related to the concept of “Volumetric Lighting,” which, particularly in the last few years, has taken over the game development industry. There is no wonder why, as you can see in the image below, this effect is breathtaking (and yes, you guessed, the effect was done with Volumetric Fog & Mist Asset). This is a technique used in 3D computer graphics to add lighting effects to a rendered scene. The term seems to have been introduced from cinematography and is now widely applied to 3D modeling and rendering, especially in the development of 3D video games.

How to set up 'God Rays' in Unity with Volumetric Fog & Mist 2

How “God Rays” work with Volumetric Fog & Mist 2?

Our Volumetric Fog & Mist 2 asset contains two packages written from scratch for built-in and URP. They offer similar functionality and fog looks gorgeous in both asset although they also introduce certain differences in terms of feature set. For example, the URP version supports native directional, spotlight and point light shadows while the built-in version only supports directional light shadows. In both cases, the asset uses a raymarching technique to compute the fog accomulation and light dispersion through a volume. Shadowmaps are cast from the light source and sampled by the shader causing the effect of light occlusion seen in the image above. In both versions, for optimization purposes you can opt to render the effect to a reduced resolution. The asset will automatically upscale the result and use a edge-wise bilateral blur to preserve the sharpness of the geometry when blending the effect onto the scene color buffer.


How to set up “God Rays” in Unity with Volumetric Fog & Mist 2

Open your Unity scene in which you want to add this effect. Import the “Volumetric Fog & Mist 2” asset by going to the package manager. Make sure to keep the asset updated to have all the new features up to date. If that is the case for you, just hit the update button and import the package. Don’t worry about the pipeline with which you created your project. This effect works for Built-in and Universal Render Pipeline. 

Now that you have the asset imported, it’s time to add it to your scene. This process is slightly different to do, depending on the pipeline, as we mentioned before. 

• For Built-in

Select your main camera, and in the inspector panel, add the “Volumetric Fog & Mist” script

• For URP

In the Unity main menu, select Game Object > Effects > Volumetric Fog 2 > Fog Volume, to create a fog volume into your scene. You can also click the “plus” button on the hierarchy and follow the same process.

At this point, you already should see the fog on the scene. Play with the settings to match the desired fog effect. Now, this is where the God Rays part comes in. Select your Directional Light and make sure the shadows are enabled (we suggest soft shadows for HD visuals). Also, on the Culling Mask option, select the layer which is related to the objects that will occlude the light.

Back to the Volumetric Fog & Mist options, make sure the “Receive Shadows” option is enabled, and play with the intensity until you reach the expected result. For me, a value of 1 is what worked best.

By now, the “God Rays” should already be scattered around your scene, and it should have a fantastic look added to the visuals. Feel free to contact us on our social media or the email listed below if you have any doubt regarding our assets or any configuration you may have issues with. Also, don’t miss the opportunity to check the demo reel video of our God Rays result below!


Get Volumetric Fog & Mist 2:

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

My name is Sorin Predescu. A few years ago I started learning about the amazing world of creating games and got involved in Unity game development. This all lead to where I am now, working as a Community Manager at Kronnect, one of the biggest publishers on the Asset Store, sharing all my knowledge with the community and learning new and astonishing things every day.

Back To Top