MeshAreaLightSimplifyCornerDistanceThreshold

MeshAreaLightSimplifyCornerDistanceThreshold

#Overview

name: MeshAreaLightSimplifyCornerDistanceThreshold

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 MeshAreaLightSimplifyCornerDistanceThreshold is to control the simplification process of mesh area lights in Unreal Engine’s lighting system. It sets the maximum distance allowed between corners of mesh area light primitives that can be merged into a single simplified primitive.

This setting variable is primarily used in the Lightmass subsystem, which is responsible for global illumination and static lighting calculations in Unreal Engine. It’s specifically utilized in the mesh area lights functionality, which is part of the advanced lighting features.

The value of this variable is set in the Lightmass configuration file (GLightmassIni). It’s read from the “DevOptions.MeshAreaLights” section of the config file using the GConfig system.

MeshAreaLightSimplifyCornerDistanceThreshold interacts with other mesh area light settings, such as MeshAreaLightSimplifyNormalAngleThreshold and MeshAreaLightSimplifyMeshBoundingRadiusFractionThreshold. Together, these variables control different aspects of the mesh area light simplification process.

Developers should be aware that this variable directly affects the level of detail in mesh area light calculations. A higher value will result in more aggressive simplification, potentially improving performance but reducing lighting accuracy. Conversely, a lower value will preserve more detail but may increase computation time.

Best practices when using this variable include:

  1. Balancing performance and visual quality by carefully adjusting the threshold.
  2. Testing different values in various lighting scenarios to find the optimal setting for your specific use case.
  3. Considering the scale of your scene when setting this value, as it’s multiplied by the StaticLightingLevelScale.
  4. Using it in conjunction with other mesh area light settings for comprehensive control over the simplification process.
  5. Documenting any custom values used in your project for consistency across the development team.

#Setting Variables

#References In INI files

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

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

Scope (from outer to inner):

file
function     void FLightmassExporter::WriteSceneSettings

Source code excerpt:

		VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.MeshAreaLights"), TEXT("MeshAreaLightSimplifyNormalAngleThreshold"), MeshAreaLightSimplifyNormalAngleThreshold, GLightmassIni));
		Scene.MeshAreaLightSettings.MeshAreaLightSimplifyNormalCosAngleThreshold = FMath::Cos(FMath::Clamp(MeshAreaLightSimplifyNormalAngleThreshold, 0.0f, 90.0f) * (float)PI / 180.0f);
		VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.MeshAreaLights"), TEXT("MeshAreaLightSimplifyCornerDistanceThreshold"), Scene.MeshAreaLightSettings.MeshAreaLightSimplifyCornerDistanceThreshold, GLightmassIni));
		VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.MeshAreaLights"), TEXT("MeshAreaLightSimplifyMeshBoundingRadiusFractionThreshold"), Scene.MeshAreaLightSettings.MeshAreaLightSimplifyMeshBoundingRadiusFractionThreshold, GLightmassIni));
		VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.MeshAreaLights"), TEXT("MeshAreaLightGeneratedDynamicLightSurfaceOffset"), Scene.MeshAreaLightSettings.MeshAreaLightGeneratedDynamicLightSurfaceOffset, GLightmassIni));
	}
	{
		Scene.AmbientOcclusionSettings.bUseAmbientOcclusion = LevelSettings.bUseAmbientOcclusion;
		Scene.AmbientOcclusionSettings.bGenerateAmbientOcclusionMaterialMask = LevelSettings.bGenerateAmbientOcclusionMaterialMask;

#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/ImportExport/LightmassScene.cpp:514

Scope (from outer to inner):

file
namespace    Lightmass
function     void FScene::ApplyStaticLightingScale

Source code excerpt:

	SceneConstants.VisibilityNormalOffsetDistance *= SceneConstants.StaticLightingLevelScale;
	SceneConstants.SmallestTexelRadius *= SceneConstants.StaticLightingLevelScale;
	MeshAreaLightSettings.MeshAreaLightSimplifyCornerDistanceThreshold *= SceneConstants.StaticLightingLevelScale;
	MeshAreaLightSettings.MeshAreaLightGeneratedDynamicLightSurfaceOffset *= SceneConstants.StaticLightingLevelScale;
	DynamicObjectSettings.FirstSurfaceSampleLayerHeight *= SceneConstants.StaticLightingLevelScale;
	DynamicObjectSettings.SurfaceLightSampleSpacing *= SceneConstants.StaticLightingLevelScale;
	DynamicObjectSettings.SurfaceSampleLayerHeightSpacing *= SceneConstants.StaticLightingLevelScale;
	DynamicObjectSettings.DetailVolumeSampleSpacing *= SceneConstants.StaticLightingLevelScale;
	DynamicObjectSettings.VolumeLightSampleSpacing *= SceneConstants.StaticLightingLevelScale;

#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/Lighting/LightingMesh.cpp:772

Scope (from outer to inner):

file
function     void FStaticLightingMesh::AddPrimitiveTexel

Source code excerpt:

					for (int32 OtherCornerIndex = 0; OtherCornerIndex < NumTexelCorners; OtherCornerIndex++)
					{
						if ((CurrentPosition - ComparisonTexel.Corners[OtherCornerIndex].WorldPosition).SizeSquared3() < FMath::Square(Scene.MeshAreaLightSettings.MeshAreaLightSimplifyCornerDistanceThreshold))
						{
							bAnyCornersMatch = true;
							break;
						}
					}
				}

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

Scope (from outer to inner):

file
namespace    Lightmass

Source code excerpt:


	/** Maximum distance allowed between any mesh area light primitive corners that get merged into the same simplified primitive. */
	float MeshAreaLightSimplifyCornerDistanceThreshold;

	/** Fraction of a mesh's bounds that an emissive texel can be from a simplified primitive and still get merged into that primitive. */
	float MeshAreaLightSimplifyMeshBoundingRadiusFractionThreshold;

	/** Distance along the average normal from the bounds origin of the mesh area light to place a light to handle influencing dynamic objects. */
	float MeshAreaLightGeneratedDynamicLightSurfaceOffset;