UNREAL ENGINE LIGHTING BREAKDOWN

Since the release of Blow, my ArchViz project in Unreal Engine 4, many people have asked me for my lighting settings. 
Lighting in Unreal is very dependant on a lot of factors and so simply sharing some settings wouldn't necessarily translate well to your project, so instead I decided to breakdown lighting in Unreal Engine 4 and explain how I go about lighting a scene so you can do the same for yours.

 

To start off, I put together a small scene using my ArchViz asset pack.

 

For this breakdown I am using Unreal Engine 4.11.2 simply because it is the most recent version of the engine. Epic Games added some nice lightmass improvements that speed up rendering times in 4.11 so it makes for the best version to use at the moment for this sort of lighting.

At the moment there are no lights in the scene, and the sky sphere is simply a white colour plugged into the emissive channel to give me a nice clean white outside. I could always use an HDR image here instead.

The first thing I am going to do is go into the post processing settings and change the minimum and maximum brightness values in my Auto Exposure to 1. The reason for this is because I don't want, at this stage, for the auto exposure to affect the results of my lighting or what I see. By default, if my lighting is dark, the auto exposure will brighten everything up so I won't get a fair representation of what my scene actually looks like.

 

I'll also look at removing nearly all of the ambient occlusion. I don't like the fake shadows it makes and think that I can achieve a more accurate representation of shadowing myself.

 

I'll also turn the bloom down to 0.5, again because I want to be able to see properly what I am achieving with my lighting. I also think 1 is, more often than not, too high.

 

Following this, I will add a box reflection capture that encompasses the entire room, and several sphere reflection captures around anything I want to have a nice reflection on (mostly metals or shiny surfaces). In this scene I'll put these near the fruit bowl, the red vases, the lamp and the metal sculpt. Anything else that will have a more matte reflection, like the floor and the table, will be taken care of by the box reflection capture.

 

Before I've even put any lights in my scene it's already looking like it's reflecting the environment properly

Now I'm going to add a light, and the first thing I'll start with is a skylight. I'm aiming to replecate real-life lighting as much as possible so where better to start than the sun?

I'll give the sun a very light blue colour and I'll plug in a cubemap. If I was using an HDR image in my skybox I'd probably plug that HDR texture in here too. As I'm using a white skybox I'm going to use a white cubemap, in this case I'll be using one I downloaded from UE4 Arch. You can download it too, here.                      I'll also set the light type to static to give me static baked lighting.

I'll set the value of my skylight to around 2 or 3. I want a nice blanket of light to cover everything at this point. I'll make sure I don't go any higher than this with my skylight; any more will start to wash everything out and it won't look realistic. Using these settings, after building the lighting for the first time on preview quality, I've get some pretty nice results.

Now I'm going to add a directional light. This is what is going to give me some really crisp shadows and give my sunlight some direction and strength. After I've added my light, and set it up in a direction that I like,

I'll take a look at some of the settings. First I'll change the light to a static light.

After that, I'll look at the intensity. I want to make sure is that I don't turn this

directional light up too high. I might be tempted to whack this right up and that

might look great in an outdoor scene perhaps, but for me I want to make sure

it's there, but not dominating. This isn't because it'll look necessarily bad, but

when I start looking at altering the auto exposure, having a super bright 

sunlight will cause my post process volume to darken the whole scene, when 

trying to level out the over exposed directional lighting.

So I'll set my directional light to have a value of 2, and give it a slightly warm colour to compliment the slight blue in the skylight. I like to add an extra level of indirect lighting intensity here, however this varies from project to project and in some instances may look better left on the default value of 1. Again I'll build my level with preview lighting.

I can start looking at my auto exposure settings again now, too. A lot of this really is just seeing what looks good to my eye but I find the best way to find my min and max brightness settings are as follows; 

I'll navigate to the darkest area of my map; an area that isn't receiving much light, and then turn my minimum brightness setting to 0. This will cause the auto exposure to start increasing the exposure of my screen which, at this point, is to something that is far too bright for this dark area of the map. Then I'll start dialing up that minimum brightness until I find a level that I'm happy for those dark areas to be. In this case, I found that 0.15 was the sweet spot, but this varies from project to project. Then I'll navigate to the brightest area of my map, and reduce my maximum brightness to 0, this turns my screen entirely white. Again I'll dial that value up until I find a setting I'm happy with to be the maximum my level will be exposed, in this case, that's at 2. Preparing my auto exposure this way means that I'll never get areas that are too dark or too bright since I've set the extremes of each value to the extremes of dark and light in my level.

I'll increase the speed up to 4 here, just so when I go from somewhere very dark to very light, the auto exposure will work faster. I think a value of 4 simulates the human eye pretty well. The exposure bias setting will increase, or decrease the entire exposure. I think that my level is a very tiny bit on the dark side here so I'll turn this setting up to 0.154. Realistically I don't want to be changing this value very much. If I have to start increasing this by a large margin it's much better to go back and look at my lighting setup. Changing this too much will start to wash areas out and start to look unrealistic.

 

Before I move on to anything else I'm going to take a look at my

lightmaps. At the moment, every mesh has a default lightmap with a

resolution of 64x64. For small assets with large UV islands this value is

great, but I'm working with large meshes here and I want a large

lightmap resolution for a well detailed shadow. So I'll go through each

asset, and navigate to the static mesh settings and increase the light

map resolution of my mesh. For ArchViz projects I can look at using

values of up to 2048x2048 (however too many of these will consume all

of my ram - my blow project took about 23gb of ram during building). 

For a game I'd look at something much lower, probably 256x256 to 512x512 for a sofa like this. For this example I'm going with 1024x1024. I'll then go through all the rest of my meshes and set appropriate lightmap sizes for those too. NOTE: I'm not changing the "minimum lightmap resolution" setting under build settings, but the "light map resolution" under static mesh settings.

 

The aim of this lighting setup is to simulate real-life light as accurately as possible. Therefore, I have to treat my level as though it is real life. If somewhere in my real-life home is too dark, I don't start increasing the exposure of my eyes, or increase the brightness of the sun. Instead, I go and open a curtain to let more natural light in, or I'll turn on an artificial light, and this is exactly what I need to do in Unreal Engine 4. Adding another window, increasing the size of my window or opening my curtains more in engine, for example, will let more light in and will brighten up my room. Increasing the brightness of my skylight or directional light isn't the right step here. In this case, my level looks pretty good, except it's a little bit dark on the left hand side, so I'll turn on my lamp. I'll also add a couple of lights above my painting to show that off a little better. Again I'll set my lights to static, and then build at preview quality.

This is what my level is looking like so far, and overall I'm pleased with the results. I might look at adding some more reflection captures around the base of the chair or in front of the doors but on the whole the lighting looks good. If my level was too bright here I'd look at working with my auto exposure again, and if it was too dark I'd look at adding more artificial lights, or more ways for natural light to enter, for example, by opening one of the doors.

I'm ready to get into the meat and bones of this lighting now. I'm happy with my set-up and I'm happy with the results I'm getting out of my default, preview quality build. Now I'm going to look at lightmass in Unreal Engine 4 and see what results I can get out of changing some values in there. 

I'm going to start by going into my world settings. By default this is the tab next to the "details" tab, on the right hand side. If I don't see the world settings tab, I'll navigate to the 'window' menu in the top left and make sure 'world settings' is ticked.

The first thing I'll look at is the "static lighting level scale". This value will set the scale of my level in relation to real world scale. By default the value is 1, so 1m in engine is 1m in the real world. In a very large level I'll set this value to 2 or 3 to decrease my render times, but in this case I'm going to look at decreasing it. The lower I go with this value the better my end lighting solution will become but the longer my render times will be. Anything lower than 0.15 isn't worth the render times, but a value of 0.2 to 0.4 will give me some solid results. Because my scene is very small and it doesn't take long to render, I'll set this value to 0.2. 

The number of indirect lighting bounces refers to the number of times a photon will bounce off an object. The higher I set this number the more bounces but the improvement in results becomes less and less each time. The difference between 3 and 5 for example is very large, but then the difference between 50 and 100 is tiny. I'll set this value at 50.

Increasing the indirect lighting quality will increase the global illumination solver count, essentially the higher the better. Changing this really increases the render times of your scene however, again, as my scene is small, I'll set this value to 10.

 

After building on preview quality, and waiting about 5 minutes for the lighting to build, I can see some really great results here. The shadows look realistic and I'm getting that subtle edge shadowing that would have otherwise been faked by the ambient occlusion I turned off earlier, had I not built my level this way.

From here I can call this scene done, I can re-render on production quality and be quite happy with the results. However, I can in fact go one step further.

I'm going to start looking into the files that control Unreal Engine and more specifically the lightmass funtionality. After saving and closing my Unreal Engine project, I'm going to head to my program files and find my Epic Games install folder. From here I'll go inside the 4.11 folder, as that's the version I'm using, then I'll head into the Engine folder, and then into the Config folder inside of that. Once here I'll locate a file called "BaseLightmass.ini", and this is the file I'm going to edit. 

After first making a backup of the original BaseLightmass.ini, I'll open up the file and take a look inside. There are an abundance of settings in here which all control variious parts of lightmass, however I'm interested in just three of them, located under the

"[DevOptions.PhotonMapping]" section. Towards the bottom of this section I'll find "IndirectPhotonDensity", "IndirectIrradiancePhotonDensity" and "IndirectPhotonSearchDistance". The larger I make these first two settings, and the smaller I make this last setting the better quality shadows I'm going to get overall. I'll set IndirectPhotonDensity to 2000, IndirectIrradiancePhotonDensity to 1000 and IndirectPhotonSearchDistance to 180. These values seem to work well. Changing this .ini file will again increase my render times and may not always be worth it, but for archviz projects, or a smaller scene that builds fast, these are some really great settings. 

After saving BaseLightmass.ini and reopening my project I'm going to build for the final time. This time I'm going to look at increasing the lighting quality from preview. Had I not changed these .ini files or tuned my lightmass settings as much, I'd build on production quality. However, after making all of the changes I've made to lightmass and the .ini file, I can achieve far greater results by building on just medium quality. I could build on high or production if I wanted to, but the exponential increase in render times really isn't worth the extremely marginal increase in quality I would see. After building for the final time, in a build that took approximately 10 minutes, I'm faced with the final results; an incredibly realistic looking baked lighting solution.

It's worth noting that each environment is different, and what looks good for my scene perhaps might not look good for yours so consider this a starting point to experiment with. 

Also bear in mind the increase in ram usage, and render times, improving each little thing will make. 'Blow', my ArchViz environment, needed 24gb of ram to build, due to my large lightmap resolutions. Building the scene took over 5 hours on a 6 core intel processor.

However, if you follow this guide and find the settings that work well with your scene, you'll end up with an incredibly realistic lighting solution too.

 

Good luck and thank you for reading,

Murray

© 2015 by Murray Bateman

HighresScreenshot00005.png