MinUnoccludedFraction

MinUnoccludedFraction

#Overview

name: MinUnoccludedFraction

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 MinUnoccludedFraction is to determine whether a precomputed shadowmap should be kept or discarded based on the visibility of lighting samples. It is used in the static shadow generation system of Unreal Engine’s lightmass.

This setting variable is primarily used in the Lightmass subsystem, which is responsible for precomputing static lighting and shadows in Unreal Engine. It’s specifically used in the static shadow generation process.

The value of this variable is typically set in the Lightmass configuration files or through the engine’s configuration system. It’s read from the configuration in the FLightmassExporter::WriteSceneSettings function.

MinUnoccludedFraction interacts with other variables related to shadow mapping and visibility calculations, such as NumUnoccludedTexels and NumMappedTexels. It’s used in comparisons to determine if a shadowmap should be kept or discarded.

Developers should be aware that this variable directly affects the quality and performance of static shadow generation. A higher value will result in fewer shadowmaps being kept, potentially improving performance but potentially reducing shadow quality in some areas.

Best practices when using this variable include:

  1. Carefully balancing the value to achieve a good trade-off between shadow quality and performance.
  2. Testing different values in various scenes to find the optimal setting for your specific use case.
  3. Considering the types of environments and lighting scenarios in your game when setting this value.
  4. Being aware that changing this value will require regenerating lightmaps and shadowmaps.

#Setting Variables

#References In INI files

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

#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:2322

Scope (from outer to inner):

file
function     void FLightmassExporter::WriteSceneSettings

Source code excerpt:

		VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.StaticShadows"), TEXT("StaticShadowDepthMapSuperSampleFactor"), Scene.ShadowSettings.StaticShadowDepthMapSuperSampleFactor, GLightmassIni));
		VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.StaticShadows"), TEXT("StaticShadowDepthMapMaxSamples"), Scene.ShadowSettings.StaticShadowDepthMapMaxSamples, GLightmassIni));
		VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.StaticShadows"), TEXT("MinUnoccludedFraction"), Scene.ShadowSettings.MinUnoccludedFraction, GLightmassIni));
	}
	{
		VERIFYLIGHTMASSINI(GConfig->GetBool(TEXT("DevOptions.ImportanceTracing"), TEXT("bUseStratifiedSampling"), bConfigBool, GLightmassIni));
		Scene.ImportanceTracingSettings.bUseStratifiedSampling = bConfigBool;
		VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.ImportanceTracing"), TEXT("NumHemisphereSamples"), Scene.ImportanceTracingSettings.NumHemisphereSamples, GLightmassIni));
		VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.ImportanceTracing"), TEXT("NumAdaptiveRefinementLevels"), Scene.ImportanceTracingSettings.NumAdaptiveRefinementLevels, GLightmassIni));

#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/Lighting/TextureMapping.cpp:1726

Scope (from outer to inner):

file
namespace    Lightmass
function     void FStaticLightingSystem::CalculateDirectAreaLightingTextureMapping

Source code excerpt:

	}

	if (ShadowMapData && (bIsCompletelyOccluded || NumUnoccludedTexels < NumMappedTexels * ShadowSettings.MinUnoccludedFraction))
	{
		delete ShadowMapData;
		ShadowMapData = NULL;
	}
}

#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/Lighting/TextureMapping.cpp:2020

Scope (from outer to inner):

file
namespace    Lightmass
function     void FStaticLightingSystem::CalculateDirectSignedDistanceFieldLightingTextureMappingTextureSpace

Source code excerpt:

	FirstPassSourceTimer.Stop();

	if (!bIsCompletelyOccluded && NumUnoccludedTexels > NumMappedTexels * ShadowSettings.MinUnoccludedFraction)
	{
		LIGHTINGSTAT(FManualRDTSCTimer SecondPassSourceTimer(MappingContext.Stats.SignedDistanceFieldSourceSecondPassThreadTime));
		check(UpsampleFactor % 2 == 1 && UpsampleFactor >= 1);
		const int32 HighResolutionSignalSizeX = TextureMapping->CachedSizeX * UpsampleFactor;
		const int32 HighResolutionSignalSizeY = TextureMapping->CachedSizeY * UpsampleFactor;
		// Allocate the final distance field shadow map on the heap, since it will be passed out of this function

#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Public/SceneExport.h:497

Scope (from outer to inner):

file
namespace    Lightmass
class        class FStaticShadowSettings

Source code excerpt:


	/** Fraction of valid lighting samples (mapped texels or vertex samples) that must be unoccluded in a precomputed shadowmap for the shadowmap to be kept. */
	float MinUnoccludedFraction;
};

/** 
 * Settings related to solving the light transport equation by starting from the source of importance, 
 * as opposed to starting from the source of radiant power. 
 */