VolumeLightSampleSpacing
VolumeLightSampleSpacing
#Overview
name: VolumeLightSampleSpacing
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 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of VolumeLightSampleSpacing is to control the distance between light samples placed in a 3D uniform grid inside the importance volume for dynamic object lighting. This setting is part of the precomputed lighting system in Unreal Engine 5, specifically for dynamic objects.
This setting variable is primarily used by the Lightmass subsystem, which is responsible for precomputed lighting calculations in Unreal Engine. It is referenced in both the editor-side code (UnrealEd module) and the Lightmass program itself.
The value of this variable is typically set in the engine configuration files, specifically in the Lightmass.ini file. It is read using the GConfig->GetFloat() function in the Lightmass exporter.
VolumeLightSampleSpacing interacts with several other variables:
- LevelSettings.VolumeLightSamplePlacementScale: This scales the VolumeLightSampleSpacing.
- SceneConstants.StaticLightingLevelScale: This also scales the VolumeLightSampleSpacing.
- DynamicObjectSettings.MaxVolumeSamples: This limits the total number of volume samples, potentially affecting the effective spacing.
Developers should be aware that:
- Increasing this value will result in fewer, more spread-out samples, potentially reducing quality but improving performance.
- Decreasing this value will increase the density of samples, potentially improving quality but at the cost of increased memory usage and computation time.
- The actual spacing might be adjusted based on the MaxVolumeSamples setting to limit memory usage.
Best practices when using this variable include:
- Balancing quality and performance by adjusting this value in conjunction with MaxVolumeSamples.
- Consider the scale of your level when setting this value, as it’s directly affected by the StaticLightingLevelScale.
- Test different values to find the optimal balance between lighting quality and build times for your specific project.
- Be mindful of memory usage, especially when decreasing this value, as it can significantly increase the number of samples generated.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseLightmass.ini:84, section: [DevOptions.PrecomputedDynamicObjectLighting]
- INI Section:
DevOptions.PrecomputedDynamicObjectLighting
- Raw value:
3000
- 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:2261
Scope (from outer to inner):
file
function void FLightmassExporter::WriteSceneSettings
Source code excerpt:
VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.PrecomputedDynamicObjectLighting"), TEXT("NumSurfaceSampleLayers"), Scene.DynamicObjectSettings.NumSurfaceSampleLayers, GLightmassIni));
VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.PrecomputedDynamicObjectLighting"), TEXT("DetailVolumeSampleSpacing"), Scene.DynamicObjectSettings.DetailVolumeSampleSpacing, GLightmassIni));
VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.PrecomputedDynamicObjectLighting"), TEXT("VolumeLightSampleSpacing"), Scene.DynamicObjectSettings.VolumeLightSampleSpacing, GLightmassIni));
VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.PrecomputedDynamicObjectLighting"), TEXT("MaxVolumeSamples"), Scene.DynamicObjectSettings.MaxVolumeSamples, GLightmassIni));
VERIFYLIGHTMASSINI(GConfig->GetBool(TEXT("DevOptions.PrecomputedDynamicObjectLighting"), TEXT("bUseMaxSurfaceSampleNum"), bConfigBool, GLightmassIni));
Scene.DynamicObjectSettings.bUseMaxSurfaceSampleNum = bConfigBool;
VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.PrecomputedDynamicObjectLighting"), TEXT("MaxSurfaceLightSamples"), Scene.DynamicObjectSettings.MaxSurfaceLightSamples, GLightmassIni));
Scene.DynamicObjectSettings.SurfaceLightSampleSpacing *= LevelSettings.VolumeLightSamplePlacementScale;
Scene.DynamicObjectSettings.VolumeLightSampleSpacing *= LevelSettings.VolumeLightSamplePlacementScale;
Scene.DynamicObjectSettings.DetailVolumeSampleSpacing *= LevelSettings.VolumeLightSamplePlacementScale;
}
{
SetVolumetricLightmapSettings(Scene.VolumetricLightmapSettings);
}
{
#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/ImportExport/LightmassScene.cpp:520
Scope (from outer to inner):
file
namespace Lightmass
function void FScene::ApplyStaticLightingScale
Source code excerpt:
DynamicObjectSettings.SurfaceSampleLayerHeightSpacing *= SceneConstants.StaticLightingLevelScale;
DynamicObjectSettings.DetailVolumeSampleSpacing *= SceneConstants.StaticLightingLevelScale;
DynamicObjectSettings.VolumeLightSampleSpacing *= SceneConstants.StaticLightingLevelScale;
VolumeDistanceFieldSettings.VoxelSize *= SceneConstants.StaticLightingLevelScale;
VolumeDistanceFieldSettings.VolumeMaxDistance *= SceneConstants.StaticLightingLevelScale;
ShadowSettings.MaxTransitionDistanceWorldSpace *= SceneConstants.StaticLightingLevelScale;
ShadowSettings.StaticShadowDepthMapTransitionSampleDistanceX *= SceneConstants.StaticLightingLevelScale;
ShadowSettings.StaticShadowDepthMapTransitionSampleDistanceY *= SceneConstants.StaticLightingLevelScale;
IrradianceCachingSettings.RecordRadiusScale *= SceneConstants.StaticLightingLevelScale;
#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/Lighting/SampleVolume.cpp:454
Scope (from outer to inner):
file
namespace Lightmass
function void FStaticLightingSystem::BeginCalculateVolumeSamples
Source code excerpt:
}
const float VolumeSpacingCubed = DynamicObjectSettings.VolumeLightSampleSpacing * DynamicObjectSettings.VolumeLightSampleSpacing * DynamicObjectSettings.VolumeLightSampleSpacing;
int32 RequestedVolumeSamples = FMath::TruncToInt(8.0f * VolumeBounds.BoxExtent.X * VolumeBounds.BoxExtent.Y * VolumeBounds.BoxExtent.Z / VolumeSpacingCubed);
RequestedVolumeSamples = RequestedVolumeSamples == appTruncErrorCode ? INT_MAX : RequestedVolumeSamples;
float EffectiveVolumeSpacing = DynamicObjectSettings.VolumeLightSampleSpacing;
// Clamp the number of volume samples generated to DynamicObjectSettings.MaxVolumeSamples if necessary by resizing EffectiveVolumeSpacing
if (RequestedVolumeSamples > DynamicObjectSettings.MaxVolumeSamples)
{
EffectiveVolumeSpacing = FMath::Pow(8.0f * float(VolumeBounds.BoxExtent.X * VolumeBounds.BoxExtent.Y * VolumeBounds.BoxExtent.Z / DynamicObjectSettings.MaxVolumeSamples), .3333333f); // LWC_TODO: Precision loss - float cast
}
#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Public/SceneExport.h:322
Scope (from outer to inner):
file
namespace Lightmass
class class FDynamicObjectSettings
Source code excerpt:
float DetailVolumeSampleSpacing;
/** Distance between samples placed in a 3d uniform grid inside the importance volume. */
float VolumeLightSampleSpacing;
/** Maximum samples placed in the 3d volume, used to limit memory usage. */
int32 MaxVolumeSamples;
/** Use Maximum number restriction for Surface Light Sample. */
bool bUseMaxSurfaceSampleNum;
/** Maximum samples placed in the surface light sample(only for Landscape currently), used to limit memory usage. */
int32 MaxSurfaceLightSamples;