Lighting Troubleshooting Guide
Contents About This Guide General Lighting Why Are My Shadows Black? Invalid Lightmap Settings When Converting BSP to Static Mesh What if I don’t want to have lightmaps at all or my game doesn’t ne...
Contents
- About This Guide
- General Lighting
- Why Are My Shadows Black?
- Invalid Lightmap Settings When Converting BSP to Static Mesh
- What if I don’t want to have lightmaps at all or my game doesn’t need them?
- Two-Sided Lighting for Single Sided Meshes, or Why does my light come through the roof?
- Why does this look nothing like it did before, or Engine Scalability and you
- Why is there a red “X” over my light?
- Dynamic (Movable) Lighting
- Shadow bleed or Incorrect Shadow Quality
- Directional Light ONLY: Cascaded Shadow Maps Settings:
- Adjusting Cascades for better Quality:
- All Dynamic Lights (Light Tab Settings):
- Why does my Movable light shine through my mesh at far distances?
- Static Lighting
- Lightmap Resolution / Shadow Quality
- What is this “Overlapping UV error” non-sense when I build lighting?
- How do I generate lightmap UVs in the editor?
- How to control Global Illumination with Static Lighting?, or The Wonderful Thing About Bounce
- Why is there shadow splotches on my static mesh?, or How to clean those dirty lightmaps?
- What is the “Lighting needs to be rebuilt” in the Top left corner error?
- Lighting Quality comparison, or Production > Preview
About This Guide
Often the difference between a good game and a great game can come down to light. Even the best model rendered with poor shadow resolution and not taking advantage of the right post process settings will look poor. In the Unreal Engine, it means digging in to our robust lighting, reflection and post process settings. This Troubleshooting guide attempts to cover some of the more common problems that people come across when they first dig into the lighting and rendering systems. This guide is by no means meant to be completely comprehensive but a living document as the engine changes so too can we add and alter advice presented here. The guide is meant to be a great first step for artist trying to get the most out of the engine's rendering system.
Common Lighting Documentation pages for reference:
Lightmass Global Illumination Lighting Basics Lighting the Environment Lighting Content Examples Lighting for Mobile Platforms Rendering & Graphics
General Lighting
Why Are My Shadows Black?
In lighting terms, deep black shadows usually mean you have no fill light. This can often happen when doing outdoor environments where a single directional light is meant to represent the sun. UE4 has a built in method to provide a world effecting fill light, we refer to it as a Sky Light. Want to know more about Sky Lights? - https://docs.unrealengine.com/en-US/Engine/Rendering/LightingAndShadows/LightTypes/SkyLight/index.html
[picture of doorway with and without a skylight]
Invalid Lightmap Settings When Converting BSP to Static Mesh
When you convert your BSP geometry to a static mesh, you will likely see the following result:
[picture of bsp cube with invalid lightmaps]
Don’t worry, this is normal! Since we’ve now converted our BSP to a Static mesh we need to make sure the right lightmap channel is assigned. To make things easier, when you convert the BSP it will automatically generate your lightmapping UVs for you. The only thing that is not setup is automatically is making sure the right channel and resolution are assigned.
- To do this, open the newly created Static Mesh. Look to the details panel on the right and locate the tab Static Mesh Settings.
- Here you’ll need to set the Lightmap Resolution. This should be any power of two increment (ie. 32, 64, 128, etc). This will be the resolution of your lightmap texture. Higher lightmap resolutions will result in better shadow quality baked into the texture, but it will also increase memory foot print and light build times.
- Next we’ll set the Lightmap Coordinate Index to 1 (This is the lightmap UV channel in most cases). This is the location of our lightmap UV that will have no overlapping faces.
- If you want to see what the lightmap UV looks like you can click the button for the UV in the toolbar and choose UV Channel 1 from the drop down to the right of the button.
[picture of Static Mesh Editor Details Panel]
What if I don’t want to have lightmaps at all or my game doesn’t need them?
There may be times where a game doesn’t need lightmaps at all, because it’s been opted to use only Movable (Dynamic) lighting. There is an option to disable lightmaps all together by opening the world settings and checking the option for “Force No Precomputed Lighting.” When lighting is rebuilt it will remove all lightmaps that have been previously cooked.
There are two methods to disable Static Lighting:
Project Settings, Rendering Tab, Lighting Tab Project Specific: Disable Static Lighting
- Menu > Edit > Project Settings
- Go to the Rendering Tab > Lighting Tab
- Uncheck the option for Allow Static Lighting
- To enable this option fully you will need to Restart the Editor
[picture of Project Settings, Rendering Tab, Lighting Tab]
Level Specific: Disable Static Lighting
World Settings 1. Open World Settings
Lightmass Settings 2. Go to the Lightmass Tab 3. Uncheck Force No Precomputed Lighting
Force No Precomputed Warning 4. You will get a warning. Click OK. 5. Build Lighting to wipe lighting data already stored.
Two-Sided Lighting for Single Sided Meshes, or Why does my light come through the roof?
Created Assets in 3DS Max So, you’ve had fun and created some awesome new assets for your game like I’ve done here.
In this image you’ll see I’ve made myself an awesome wall and a tube that when I turn on its side can be a creepy tunnel for me to walk through!
Created Assets in UE4 All seems well and good and I can see that I’ve got my awesome work and I can see both sides of my mesh in my modeling program of choice. However, when it’s imported into Unreal Engine 4 it’s messed up!
So, what gives, because this surely cannot be right?!
This is actually 100% normal. Even though the plane looks good the back face is not being rendered just like the closest faces of our tube mesh.
Wireframe of Created Assets in UE4 When you create your geometry in your modeling program by default the software has set it so that you can see both sides of your geometry.
In UE4 the the backface of a polygon is automatically culled to save on performance, because every little bit helps! It’s not always necessary to have extra polygons or render sides that may not be needed, otherwise there would be extra draw calls that could slow down your performance. with a few instances this probably wouldn’t matter much, but when you’re developing for specific platforms or have a lot going on every draw call starts to matter.
To also understand why we can only see one side we can open our mesh in the static mesh editor and tick the toolbar option for “Normals.” You will see Green lines that point in the direction the face of the polygon is directed. In the image below for our tube asset we can see that the faces where it’s invisible have the lines going towards the center of the mesh. This is the direction that the visible face can be seen.
Static Mesh Editor Pro Tip: While in UE4 if you have any meshes that have what appears to be invisible geometry or missing faces you can check the normals here before fixing the issue in your modeling software.
Now that we have all the boring stuff out of the way we can get right to fixing our invisible faces with some checkboxes and Materials.
1. (STATIC ONLY)Light as if Two-Sided
Enabled this option via the details panel for the selected asset in the Level Viewport. With this option selected, when lights are built lightmass will calculate that geometry into its bake. It will cast a shadow, even though we cannot see it from this angle, to bake into the lightmap texture. This will not work with a movable/dynamic light though since Unreal Engine 4 uses a deferred rendering pipeline.
Asset's Details Panel in Level Viewport
Final Results
2. Creating a Two-Sided Material
Open the material editor and in the details panel on the left select the option for “Two-sided”. Save and compile your material for this to take effect. This method can be used with Static/Stationary/Movable lighting. Since the material is now being rendered the faces of that were not visible before are no longer being culled and can block the light. Be aware though that this now renders both sides of the mesh adding to your draw calls. As mentioned earlier this won’t necessarily affect performance in smaller scenes or setups, but if you’re targeting hardware where every bit of performance counts this can affect that.
Material Attributes Details Panel
Final Results