How to create light rays in Unreal Engine 4

Jul 07, 2020 at 10:00 am by nemirc

Creating light rays in Unreal Engine 4

Light cones are a nice visual effect that can improve the atmosphere of your game. You can easily add this effect in UE4 with a combination of fog and lights. 

The first thing you need to do is create your lighting for your scene. There's no specific requirement here, just add the lights you need so your scene looks the way you want. For my scene I've used a combination of one direct light to simulate lights coming from the exterior, and point lights to simulate light bulbs and candles.   

Next, go to your Place Actors tab and, in the Visual Effects category, look for the Exponential Height Fog actor, and drag it to your scene.  
This is how my scene looks after I add it. Please note I am using the “unlit” mode for the level, so you can see the geometry more clearly. 
And this is how the fog looks in game. This would be OK if we wanted to have a foggy interior, but this is not what we want. Not only that, we have a lot of fog in the house but no light rays at all (we would hope we could see some rays considering my character is standing right in front of the window). 
To fix this, we need to increase the density of the fog. However, if we just increase the density, we get this: 

We need to activate the Exponential Height Fog to fix this issue. After we do this, we get the nice rays we want. 

One thing to note is that the rays' density depend on the fog density but also the light intensity. This becomes even more important if you take into consideration the fact that every light will generate rays (there's no way to turn this off, as far as I have seen). For example, this “light bulb” here is also creating the rays (albeit it looks more like a volumetric light since rays are going in all directions). 

This is the part that requires most tweaking, since you need to find a good balance between your interior lights and the exterior light. In my case, I am using boxes, so there's no real details in the level. This means I will need to tweak lights again after I have finished the level, but this should give me a good starting point. 

While this is a good effect, you surely don't want your rays to be white/gray all the time. You can easily change the color of the rays by changing the color of the light. For example, this is how my rays look when I use a darker red.  

They are barely visible due to the setup of my light. However, I can make them more visible if I increase the intensity of the light. This is how they look with an intensity of 10 (previously I was using an intensity of 2.5).  

One last thing. A while ago, when light cones were added to engines (back then called “light shafts”) they were the lens flare of real time graphics, meaning that a lot of people were using them heavily (think J.J. Abrahams' Star Trek but with light cones instead of lens flares), since people have the tendency of over-using effects because they look cool. Many times, less is more: a subtle light cone can make your scene look a lot better than a very dense one, and a subtle volume around a light can look way better than an over-exposed volume around every light in your level.  

Get Unreal Engine: https://www.unrealengine.com/en-US/get-now 






Sign up for our newsletter

This website uses cookies to ensure you get the best experience possible More Info
Got it!