MinMeshSamples

MinMeshSamples

#Overview

name: MinMeshSamples

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 MinMeshSamples is to set the minimum number of samples on a mesh for each cell-mesh query in Unreal Engine’s precomputed visibility system. This variable is part of the precomputed visibility settings, which are used to optimize rendering performance by determining which objects are visible from different viewpoints in the game world.

This setting variable is primarily used in the Lightmass subsystem, which is responsible for precalculating lighting and visibility information. Specifically, it’s used in the UnrealLightmass program, which is a separate application that processes lighting data for Unreal Engine projects.

The value of this variable is typically set in the Lightmass configuration file (Lightmass.ini) under the [DevOptions.PrecomputedVisibility] section. It’s read by the FLightmassExporter::WriteSceneSettings function in the Lightmass.cpp file.

MinMeshSamples interacts with MaxMeshSamples to determine the actual number of samples used for visibility calculations. The number of samples is calculated based on the size and distance of the mesh relative to the cell being queried, and is clamped between MinMeshSamples and MaxMeshSamples.

Developers should be aware that:

  1. Increasing MinMeshSamples can improve accuracy for small or distant meshes but at the cost of increased computation time.
  2. This setting affects the balance between performance and accuracy in precomputed visibility calculations.

Best practices when using this variable include:

  1. Adjusting it in conjunction with MaxMeshSamples to find the optimal balance between performance and visibility accuracy.
  2. Testing different values to see their impact on both build times and in-game performance.
  3. Considering the typical size and complexity of meshes in your game when setting this value.

#Setting Variables

#References In INI files

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

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

Scope (from outer to inner):

file
function     void FLightmassExporter::WriteSceneSettings

Source code excerpt:

		VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.PrecomputedVisibility"), TEXT("PlayAreaHeight"), Scene.PrecomputedVisibilitySettings.PlayAreaHeight, GLightmassIni));
		VERIFYLIGHTMASSINI(GConfig->GetFloat(TEXT("DevOptions.PrecomputedVisibility"), TEXT("MeshBoundsScale"), Scene.PrecomputedVisibilitySettings.MeshBoundsScale, GLightmassIni));
		VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.PrecomputedVisibility"), TEXT("MinMeshSamples"), Scene.PrecomputedVisibilitySettings.MinMeshSamples, GLightmassIni));
		VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.PrecomputedVisibility"), TEXT("MaxMeshSamples"), Scene.PrecomputedVisibilitySettings.MaxMeshSamples, GLightmassIni));
		VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.PrecomputedVisibility"), TEXT("NumCellSamples"), Scene.PrecomputedVisibilitySettings.NumCellSamples, GLightmassIni));
		VERIFYLIGHTMASSINI(GConfig->GetInt(TEXT("DevOptions.PrecomputedVisibility"), TEXT("NumImportanceSamples"), Scene.PrecomputedVisibilitySettings.NumImportanceSamples, GLightmassIni));
	}
	if (World->GetWorldSettings()->VisibilityAggressiveness != VIS_LeastAggressive)
	{

#Loc: <Workspace>/Engine/Source/Programs/UnrealLightmass/Private/Lighting/PrecomputedVisibility.cpp:783

Scope (from outer to inner):

file
namespace    Lightmass
function     bool ComputeBoxVisibility

Source code excerpt:

	const float MeshSize = MeshBox.GetExtent().Size();
	const float SizeRatio = MeshSize / Distance;
	// Use MaxMeshSamples for meshes with a large projected angle, and MinMeshSamples for meshes with a small projected angle
	// Meshes with a large projected angle require more samples to determine visibility accurately
	const int32 NumMeshSamples = FMath::Clamp(FMath::TruncToInt(SizeRatio * PrecomputedVisibilitySettings.MaxMeshSamples), PrecomputedVisibilitySettings.MinMeshSamples, PrecomputedVisibilitySettings.MaxMeshSamples);

	// Treat meshes whose projected angle is greater than 90 degrees as visible, since it becomes overly costly to determine if these are visible
	// (consider a large close mesh that only has a tiny part visible)
	bool bVisible = SizeRatio > 1.0f;

	if (bVisible)

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

Scope (from outer to inner):

file
namespace    Lightmass
class        class FPrecomputedVisibilitySettings

Source code excerpt:


	/** Minimum number of samples on the mesh for each cell - mesh query.  Small meshes use less samples. */
	int32 MinMeshSamples;

	/** Maximum number of samples on the mesh for each cell - mesh query.  Small meshes use less samples. */
	int32 MaxMeshSamples;

	/** Number of samples on each cell for each cell - mesh query. */
	int32 NumCellSamples;