How long does it take for engine to rebuild lights?

Mastering Unreal Engine Lighting

28/02/2022

Rating: 4.68 (10586 votes)
Table

The Importance of Lighting in Game Development

In the realm of game development, lighting is not merely an aesthetic choice; it's a fundamental pillar that dictates atmosphere, guides player attention, and significantly impacts the overall visual quality of a game. Even the most meticulously crafted models can appear underwhelming if rendered with poor shadow resolution or if the right post-processing settings aren't leveraged. The Unreal Engine offers a robust suite of lighting, reflection, and post-process settings that, while powerful, can present a learning curve for newcomers. This guide aims to demystify some of the common challenges faced when diving into Unreal Engine's lighting and rendering systems, providing practical solutions and insights.

How do I rebuild a Visual Studio plugin?
Hi! Before rebuilding the plugin, open a project folder and right click on .uproject file. In dropdown menu choose Generate Visual Studio project files. After done, click on .sln and start VS. In VS in a Solution Explorer, right click on folder of your project and choos Rebuild.

Understanding the 'Lighting Needs to Be Rebuilt' Warning

The ubiquitous warning "Lighting needs to be rebuilt" appearing in the top-left corner of your viewport, especially when using Play-in-Editor (PIE), Simulate, or Standalone modes, is a clear indicator that your scene's lighting information is out of sync with the current state of your actors. This warning specifically pertains to Static and Stationary lighting. Dynamically lit scenes do not require a lighting build process. This discrepancy arises when you modify or move a light actor, invalidating the previously calculated lighting. To resolve this, a simple rebuild of the lighting via the 'Build' menu is necessary.

Troubleshooting the Warning

When the "Lighting needs to be rebuilt" warning persists despite rebuilding, or when you have a high number of unbuilt objects without a clear identification, several diagnostic tools can be employed:

1. Unbuilt Actors List

The Output Log window, accessible through Window > Developer Tools > Output Log, can be a lifesaver. By entering the command DumpUnbuiltLightInteractions in the console, you can generate a list of all actors whose lighting has been invalidated or not built. This can pinpoint issues such as a Blueprint actor set to 'Static' but containing a 'Movable' component, or actors placed via a construction script and then moved after a lighting build.

2. Statistics Window

The Statistics window (Window > Statistics) provides invaluable data about your lighting build process and all static meshes with lightmap resolutions. It can help identify which actors are contributing to prolonged build times, allowing for targeted optimization.

Common Lighting Issues and Solutions

Why Are My Shadows Black?

Deep, black shadows often signify a lack of fill light. In outdoor environments, a single directional light representing the sun might not provide sufficient ambient illumination. The Unreal Engine offers a Skylight, which provides world-effecting fill light and is crucial for realistic outdoor lighting.

Without SkylightWith Skylight

Invalid Lightmap Settings When Converting BSP to Static Mesh

Upon converting BSP geometry to a static mesh, you might encounter visual anomalies. This is often due to incorrect lightmap settings. Ensure the Lightmap Resolution is set to a power of two (e.g., 32, 64, 128). Crucially, set the Lightmap Coordinate Index to 1. This assigns the correct UV channel for lightmaps, which should ideally have no overlapping faces.

Disabling Lightmaps

For projects exclusively using dynamic (Movable) lighting, you can disable lightmaps entirely. This can be done project-wide via Edit > Project Settings > Rendering > Lighting by unchecking Allow Static Lighting, or level-specific by enabling Force No Precomputed Lighting in the World Settings. Remember to restart the editor after project-wide changes.

Two-Sided Lighting for Single-Sided Meshes

If you have thin meshes, like walls or planes, and light appears to pass through them, it's likely due to back-face culling. In your modeling software, ensure your meshes have correct face normals. Within Unreal Engine, you have two primary solutions:

  1. Light as if Two-Sided (Static Lighting Only): Enable this option in the asset's Details panel. This allows Lightmass to calculate lighting for both sides, impacting shadows and baked lightmaps. Note that this is not compatible with Movable/dynamic lights.
  2. Create a Two-Sided Material: In the material editor, enable the Two-sided option. This renders both sides of the mesh, allowing them to block light, and works with all light types (Static, Stationary, Movable). Be mindful that this increases draw calls.

Engine Scalability and Shadow Distances

Engine Scalability settings (Settings > Engine Scalability) can significantly impact visual quality, particularly shadow distances. Lowering these settings, especially 'Shadows', can reduce the distance at which dynamic shadows are rendered. This is often done automatically by the engine to maintain performance if FPS drops. You can disable this auto-scaling, but be aware of potential performance impacts.

The Red 'X' Over a Stationary Light

Stationary lights have a limitation: they can only overlap with a maximum of four other shadow-casting stationary lights. When a fifth overlaps, the problematic light will revert to a dynamic light, indicated by a red 'X'. This can negatively impact performance. To resolve this, ensure no more than four stationary lights overlap in a given area, or consider disabling shadow casting or adjusting light radii.

Poor Lightmap UV Layout

Effective lightmaps are crucial for good baked lighting. Ensure your lightmap UVs are properly laid out within the 0-1 space, with no overlapping faces. Overlapping UVs will result in "Lightmap Overlapping by XX%" warnings. Aim to maximize UV space utilization and maintain at least a 2-pixel spacing between UV islands to prevent light bleed.

Generating Lightmap UVs in the Editor

Since UE 4.5, lightmap UVs can be automatically generated. In the Static Mesh editor, under 'Build Settings', enable Generate Lightmap UVs. Select the appropriate Source Lightmap Index (usually your texture UV channel) and set the Destination Lightmap Index (typically channel 1). Remember to also set the Lightmap Resolution and Lightmap Coordinate Index in the 'Static Mesh Settings' tab.

What is Unreal engine troubleshooting?
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.

Controlling Global Illumination with Static Lighting

Global Illumination (GI) simulates how light bounces off surfaces. In Unreal Engine, you can control the number of indirect lighting bounces through the World Settings tab. The Num of Indirect Lighting Bounces setting, typically between 1 and 4, directly affects the quality and build time of your lighting. More bounces lead to more realistic indirect lighting but increase build times significantly.

Shadow Splotches and Dirty Lightmaps

Artifacts like splotches or "dirty" lightmaps are often a side effect of indirect lighting bounces. While increasing lightmap resolution can help, a more performance-friendly approach involves adjusting Lightmass settings in World Settings. Experiment with Indirect Lighting Quality (higher values increase build times) and Indirect Lighting Smoothness (values around 0.65-0.75 can reduce blotchiness). Additionally, consider reducing over-modularization of your levels to minimize seams and shading differences between adjacent meshes.

Lightmap Error Coloring

When using 'Preview' or 'Medium' lighting quality, enabling Use Error Coloring (under the 'Build' menu) helps identify specific lightmap issues:

  • Orange: Non-unique or overlapping UVs.
  • Green: Wrapping UVs or UVs outside the 0,1 space.
  • Yellow: Unmapped texels or insufficient lightmap resolution for BSPs.

Finding Objects Causing "Lighting needs to be rebuilt" Errors

To pinpoint actors causing the "Lighting needs to be rebuilt" warning, use the DumpUnbuiltLightInteractions command in the Output Log. This is particularly useful for identifying actors that have been moved after a lighting build or instanced meshes with high lightmap resolutions that may fail to build.

Lighting Quality Comparison: Production vs. Preview

The 'Build Lighting' options allow you to select a Lighting Quality level, ranging from 'Preview' (fastest, least accurate) to 'Production' (slowest, most accurate). For final builds, 'Production' quality is recommended to minimize light leaking and ensure accurate shadows. For iterative development, 'Preview' can save significant time.

Dynamic (Movable) Lighting Optimization

Dynamic lights, especially point lights, can sometimes exhibit unexpected behaviour at distances, such as shining through meshes. This is often due to the engine's optimization of scene depth. To mitigate this, adjust the Bounds Scale of the mesh in its Details panel. Incrementally increasing this value can prevent meshes from being occluded at a distance. Alternatively, consider using a spotlight or a stationary light for better performance and predictable results.

Cascaded Shadow Maps (Directional Lights)

For directional lights, Cascaded Shadow Maps are crucial for managing shadow quality over distance. Key settings include:

  • Dynamic Shadow Distance: Controls the range of shadows.
  • Num Dynamic Shadow Cascades: More cascades mean better shadow resolution but higher cost.
  • Cascade Distribution Exponent: Affects how cascades are distributed from the camera.
  • Cascade Transition Exponent: Controls the softness of the shadow transition between cascades.
  • Shadow Distance Fadeout Fraction: Manages how shadows fade at the distance limit.

Fine-tuning these settings is essential for balancing shadow accuracy and performance.

Shadow Bias and Filter Sharpness

Under the light's 'Details' panel, Shadow Bias controls shadow accuracy, with lower values potentially causing artifacts. Shadow Filter Sharpness influences shadow edge definition. Finding a balance between these settings is key to achieving clean, accurate shadows.

Static Mesh Lightmap Resolutions

The Lightmap Resolution of individual static meshes directly impacts the quality of baked shadows. Larger meshes or those requiring higher detail will necessitate higher resolutions. Remember to use powers of two. For BSPs, you may need to decrease the resolution value for better results. Landscapes use a multiplier for their lightmap resolution.

Conclusion

Mastering lighting in Unreal Engine is an ongoing process of understanding the interplay between different light types, shadow settings, and UV layouts. By systematically troubleshooting common issues and leveraging the engine's powerful tools, you can create visually stunning and performant environments. Always remember to test your lighting changes iteratively and consider the target platform's capabilities.

If you want to read more articles similar to Mastering Unreal Engine Lighting, you can visit the Automotive category.

Go up