bUsePhotonDirectLightingInFinalGather
bUsePhotonDirectLightingInFinalGather
#Overview
name: bUsePhotonDirectLightingInFinalGather
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 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of bUsePhotonDirectLightingInFinalGather is to control the use of photon-based direct lighting in the final gather stage of the global illumination process in Unreal Engine’s Lightmass system.
This setting variable is primarily used in the Lightmass subsystem, which is responsible for precomputed lighting in Unreal Engine. It’s specifically part of the photon mapping settings within Lightmass.
The value of this variable is set in the Lightmass configuration file (GLightmassIni). It’s read from the “DevOptions.PhotonMapping” section of this configuration file.
Several other variables interact with bUsePhotonDirectLightingInFinalGather:
- bUseFinalGathering
- bVisualizeCachedApproximateDirectLighting
- bUseIrradiancePhotons
- bCacheIrradiancePhotonsOnSurfaces
Developers should be aware that:
- This setting affects the balance between quality and performance in lightmaps.
- When set to true, it uses photon-based direct lighting in the final gather, which can lead to light leaking but may be faster.
- When set to false, explicitly sampled direct lighting is used instead, which typically has less leaking but may be slower.
Best practices when using this variable include:
- Use it in conjunction with other photon mapping settings for optimal results.
- Test both true and false settings to find the best balance between quality and performance for your specific scene.
- Be aware of its impact on light leaking and adjust other settings accordingly.
- When debugging lighting issues, consider toggling this setting to isolate potential problems.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseLightmass.ini:168, section: [DevOptions.PhotonMapping]
- INI Section:
DevOptions.PhotonMapping
- Raw value:
False
- 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:2349
Scope (from outer to inner):
file
function void FLightmassExporter::WriteSceneSettings
Source code excerpt:
VERIFYLIGHTMASSINI(GConfig->GetBool(TEXT("DevOptions.PhotonMapping"), TEXT("bUseFinalGathering"), bConfigBool, GLightmassIni));
Scene.PhotonMappingSettings.bUseFinalGathering = bConfigBool;
VERIFYLIGHTMASSINI(GConfig->GetBool(TEXT("DevOptions.PhotonMapping"), TEXT("bUsePhotonDirectLightingInFinalGather"), bConfigBool, GLightmassIni));
Scene.PhotonMappingSettings.bUsePhotonDirectLightingInFinalGather = bConfigBool;
VERIFYLIGHTMASSINI(GConfig->GetBool(TEXT("DevOptions.PhotonMapping"), TEXT("bVisualizeCachedApproximateDirectLighting"), bConfigBool, GLightmassIni));
Scene.PhotonMappingSettings.bVisualizeCachedApproximateDirectLighting = bConfigBool;
VERIFYLIGHTMASSINI(GConfig->GetBool(TEXT("DevOptions.PhotonMapping"), TEXT("bUseIrradiancePhotons"), bConfigBool, GLightmassIni));
Scene.PhotonMappingSettings.bUseIrradiancePhotons = bConfigBool;
VERIFYLIGHTMASSINI(GConfig->GetBool(TEXT("DevOptions.PhotonMapping"), TEXT("bCacheIrradiancePhotonsOnSurfaces"), bConfigBool, GLightmassIni));
Scene.PhotonMappingSettings.bCacheIrradiancePhotonsOnSurfaces = bConfigBool;
#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/Lighting/PhotonMapping.cpp:304
Scope (from outer to inner):
file
namespace Lightmass
function void FStaticLightingSystem::EmitDirectPhotons
Source code excerpt:
}
if (PhotonMappingSettings.bUseIrradiancePhotons && PhotonMappingSettings.bUsePhotonDirectLightingInFinalGather)
{
for (int32 PhotonIndex = 0; PhotonIndex < CurrentOutput.IrradiancePhotons->Num(); PhotonIndex++)
{
// Add the irradiance photons to an octree
IrradiancePhotonMap.AddElement(FIrradiancePhotonElement(PhotonIndex, *CurrentOutput.IrradiancePhotons));
}
#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/Lighting/PhotonMapping.cpp:1516
Scope (from outer to inner):
file
namespace Lightmass
function void FStaticLightingSystem::CalculateIrradiancePhotonsWorkRange
Source code excerpt:
// Or if photon mapping is being used for direct lighting.
|| PhotonMappingSettings.bVisualizeCachedApproximateDirectLighting)
&& PhotonMappingSettings.bUsePhotonDirectLightingInFinalGather)
{
const FLinearColor DirectPhotonIrradiance = CalculatePhotonIrradiance(
DirectPhotonMap,
NumPhotonsEmittedDirect,
PhotonMappingSettings.NumIrradianceCalculationPhotons,
PhotonMappingSettings.DirectPhotonSearchDistance,
#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/Lighting/TextureMapping.cpp:2823
Scope (from outer to inner):
file
namespace Lightmass
function void FStaticLightingSystem::CalculateDirectLightingTextureMappingPhotonMap
Source code excerpt:
FLinearColor FinalLighting = PhotonIrradiance;
if (!PhotonMappingSettings.bUsePhotonDirectLightingInFinalGather)
{
FinalLighting += DirectLighting;
}
//@todo - can't visualize accurately using AmbientLight with directional lightmaps
//CurrentLightSample.AddWeighted(FGatheredLightSampleUtil::AmbientLight<2>(FinalLighting), 1.0f);
#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Public/SceneExport.h:576
Scope (from outer to inner):
file
namespace Lightmass
class class FPhotonMappingSettings
Source code excerpt:
* This is useful to visualize direct photons. When false, explicitly sampled direct lighting will be used instead, which has less leaking.
*/
bool bUsePhotonDirectLightingInFinalGather;
/**
* Debugging - whether to replace direct lighting with direct lighting as seen by the final gather.
* This will either be direct lighting from photons, or approximate explicitly sampled direct lighting, depending on bUsePhotonDirectLightingInFinalGather.
* This is mainly useful for debugging what the final gather rays see.
*/
bool bVisualizeCachedApproximateDirectLighting;
/** Debugging - whether to use the optimization of caching irradiance calculations in deposited photons (called Irradiance photons). */
bool bUseIrradiancePhotons;
/**
* Debugging - whether to cache the result of the search for the nearest irradiance photon on surfaces.
* This results in a constant time lookup at the end of each final gather ray instead of a photon map search.