LightGridSize
LightGridSize
#Overview
name: LightGridSize
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 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of LightGridSize is to control the size of the grid used for accelerating light sampling in static lighting calculations within Unreal Engine 5. This setting is part of the static lighting system and affects the performance and accuracy of lightmass calculations.
The LightGridSize variable is primarily used in the Lightmass subsystem, which is responsible for precomputing static lighting in Unreal Engine. It is referenced in the UnrealEd module and the UnrealLightmass program, indicating its importance in both the editor and the lightmass computation process.
The value of this variable is set in the Lightmass configuration file (GLightmassIni). It is read from the “DevOptions.StaticLightingSceneConstants” section with the key “LightGridSize” and stored in the Scene.SceneConstants structure.
LightGridSize interacts with other lighting-related variables, such as DirectPhotonDensity and OutsideImportanceVolumeDensityScale, as seen in the FStaticLightingSystem constructor.
Developers must be aware that increasing the LightGridSize value will result in longer precomputation times for static lighting. However, it can lead to more accurate and faster light sampling during runtime. The trade-off between precomputation time and runtime performance should be carefully considered.
Best practices when using this variable include:
- Experiment with different values to find the optimal balance between precomputation time and lighting quality for your specific project.
- Consider using smaller grid sizes for faster iteration during development and larger sizes for final builds.
- Document the chosen value and the reasoning behind it for future reference and team communication.
- Be mindful of the impact on memory usage, as larger grid sizes will require more memory during lightmass calculations.
- Regularly review and adjust this setting as the project evolves, especially when making significant changes to the lighting setup or scene complexity.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseLightmass.ini:47, section: [DevOptions.StaticLightingSceneConstants]
- INI Section:
DevOptions.StaticLightingSceneConstants
- Raw value:
100
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Lightmass/Lightmass.cpp:2186
Scope (from outer to inner):
file
function void FLightmassExporter::WriteSceneSettings
Source code excerpt:
VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.StaticLightingSceneConstants"), TEXT("VisibilityTangentOffsetSampleRadiusScale"), Scene.SceneConstants.VisibilityTangentOffsetSampleRadiusScale, GLightmassIni));
VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.StaticLightingSceneConstants"), TEXT("SmallestTexelRadius"), Scene.SceneConstants.SmallestTexelRadius, GLightmassIni));
VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.StaticLightingSceneConstants"), TEXT("LightGridSize"), Scene.SceneConstants.LightGridSize, GLightmassIni));
}
{
VERIFYLIGHTMASSINI(GConfig->GetBool(TEXT("DevOptions.StaticLightingMaterial"), TEXT("bUseDebugMaterial"), bConfigBool, GLightmassIni));
Scene.MaterialSettings.bUseDebugMaterial = bConfigBool;
FString ShowMaterialAttributeName;
VERIFYLIGHTMASSINI(GConfig->GetString(TEXT("DevOptions.StaticLightingMaterial"), TEXT("ShowMaterialAttribute"), ShowMaterialAttributeName, GLightmassIni));
#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/Lighting/LightingSystem.cpp:495
Scope (from outer to inner):
file
namespace Lightmass
function FStaticLightingSystem::FStaticLightingSystem
Source code excerpt:
ImportanceBounds,
Scene.PhotonMappingSettings.IndirectPhotonEmitDiskRadius,
Scene.SceneConstants.LightGridSize,
Scene.PhotonMappingSettings.DirectPhotonDensity,
Scene.PhotonMappingSettings.DirectPhotonDensity * Scene.PhotonMappingSettings.OutsideImportanceVolumeDensityScale);
Lights.Add(&InScene.DirectionalLights[LightIndex]);
}
#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Public/SceneExport.h:175
Scope (from outer to inner):
file
namespace Lightmass
class class FStaticLightingSceneConstants
Source code excerpt:
* Larger grids take longer to precompute, but result in accelerated light sampling.
*/
int32 LightGridSize;
};
/** Settings for which material attribute to visualize */
enum EViewMaterialAttribute
{
VMA_None,