bRebuildDirtyGeometryForLighting

bRebuildDirtyGeometryForLighting

#Overview

name: bRebuildDirtyGeometryForLighting

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bRebuildDirtyGeometryForLighting is to control whether the Unreal Engine should automatically rebuild geometry that has become “dirty” (i.e., modified in a way that affects lighting) before performing a lighting build.

This setting variable is primarily used in the static lighting system of Unreal Engine 5. It’s referenced in the FStaticLightingSystem class, which is part of the UnrealEd module responsible for managing static lighting calculations and builds.

The value of this variable is set from the Lightmass configuration file (GLightmassIni). It’s read using the GConfig->GetBool function, suggesting that it can be configured externally.

This variable interacts closely with other lighting-related variables and functions within the FStaticLightingSystem class. It’s used as a parameter in the GatherStaticLightingInfo function, which collects all static lighting information for processing.

Developers must be aware that when this variable is set to true, it can trigger an automatic rebuild of geometry that has been modified in ways that affect lighting. This can potentially increase the time required for lighting builds but ensures more accurate results.

Best practices when using this variable include:

  1. Ensure it’s set to true during final lighting builds to guarantee the most accurate results.
  2. Consider setting it to false during iterative development to speed up lighting previews, but be aware that this may lead to inaccuracies.
  3. Be mindful of performance implications, especially in large scenes with complex geometry.
  4. Use in conjunction with other lighting settings to achieve the desired balance between build speed and lighting quality.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseLightmass.ini:28, section: [DevOptions.StaticLighting]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/StaticLightingSystem/StaticLightingPrivate.h:338

Scope (from outer to inner):

file
class        class FStaticLightingSystem

Source code excerpt:


	/** Collects all static lighting info for processing */
	void GatherStaticLightingInfo(bool bRebuildDirtyGeometryForLighting, bool bForceNoPrecomputedLighting);
	
	/** After importing, textures need to be encoded to be used */
	void EncodeTextures(bool bLightingSuccessful);

	/** Pushes newly collected lightmaps on to the level */
	void ApplyNewLightingData(bool bSuccessful);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/StaticLightingSystem/StaticLightingSystem.cpp:511

Scope (from outer to inner):

file
function     bool FStaticLightingSystem::BeginLightmassProcess

Source code excerpt:

	CurrentBuildStage = FStaticLightingSystem::Startup;

	bool bRebuildDirtyGeometryForLighting = true;
	bool bForceNoPrecomputedLighting = false;

	GDebugStaticLightingInfo = FDebugLightingOutput();

	{
		FLightmassStatistics::FScopedGather StartupStatScope(LightmassStatistics.StartupTime);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/StaticLightingSystem/StaticLightingSystem.cpp:665

Scope (from outer to inner):

file
function     bool FStaticLightingSystem::BeginLightmassProcess

Source code excerpt:

		verify(GConfig->GetBool(TEXT("DevOptions.StaticLighting"), TEXT("bUseBilinearFilterLightmaps"), GUseBilinearLightmaps, GLightmassIni));
		verify(GConfig->GetBool(TEXT("DevOptions.StaticLighting"), TEXT("bAllowCropping"), GAllowLightmapCropping, GLightmassIni));
		verify(GConfig->GetBool(TEXT("DevOptions.StaticLighting"), TEXT("bRebuildDirtyGeometryForLighting"), bRebuildDirtyGeometryForLighting, GLightmassIni));
		verify(GConfig->GetBool(TEXT("DevOptions.StaticLighting"), TEXT("bCompressLightmaps"), GCompressLightmaps, GLightmassIni));

		GCompressLightmaps = GCompressLightmaps && World->GetWorldSettings()->LightmassSettings.bCompressLightmaps;

		GAllowLightmapPadding = true;
		FMemory::Memzero(&LightingMeshBounds, sizeof(FBox));

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/StaticLightingSystem/StaticLightingSystem.cpp:733

Scope (from outer to inner):

file
function     bool FStaticLightingSystem::BeginLightmassProcess

Source code excerpt:

			}
			
			GatherStaticLightingInfo(bRebuildDirtyGeometryForLighting, bForceNoPrecomputedLighting);
		}

		// Sort the mappings - and tag meshes if doing deterministic mapping
		if (GLightmassDebugOptions.bSortMappings)
		{
			struct FCompareNumTexels

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/StaticLightingSystem/StaticLightingSystem.cpp:934

Scope (from outer to inner):

file
function     void FStaticLightingSystem::GatherStaticLightingInfo

Source code excerpt:

}

void FStaticLightingSystem::GatherStaticLightingInfo(bool bRebuildDirtyGeometryForLighting, bool bForceNoPrecomputedLighting)
{
	uint32 ActorsInvalidated = 0;
	uint32 ActorsToInvalidate = 0;
	for( int32 LevelIndex=0; LevelIndex<World->GetNumLevels(); LevelIndex++ )
	{
		ActorsToInvalidate += World->GetLevel(LevelIndex)->Actors.Num();

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/StaticLightingSystem/StaticLightingSystem.cpp:963

Scope (from outer to inner):

file
function     void FStaticLightingSystem::GatherStaticLightingInfo

Source code excerpt:

		{
			UE_LOG(LogStaticLightingSystem, Warning, TEXT("WARNING: Lighting build detected that geometry needs to be rebuilt to avoid incorrect lighting (due to modifying a lighting property)."));
			if (bRebuildDirtyGeometryForLighting)
			{
				// This will go ahead and clean up lighting on all dirty levels (not just this one)
				UE_LOG(LogStaticLightingSystem, Warning, TEXT("WARNING: Lighting build automatically rebuilding geometry.") );
				GEditor->Exec(World, TEXT("MAP REBUILD ALLDIRTYFORLIGHTING"));
			}
		}