r.Lumen.TranslucencyVolume.GridPixelSize

r.Lumen.TranslucencyVolume.GridPixelSize

#Overview

name: r.Lumen.TranslucencyVolume.GridPixelSize

The value of this variable can be defined or overridden in .ini config files. 3 .ini config files referencing this setting variable.

This variable is created as a Console Variable (cvar).

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Lumen.TranslucencyVolume.GridPixelSize is to control the size of cells in the translucency grid for Lumen’s translucency volume lighting system. This setting is crucial for the rendering system, specifically for handling translucent objects in scenes using Lumen global illumination.

This setting variable is primarily used in the Lumen subsystem of Unreal Engine’s rendering module. It’s specifically involved in the translucency volume lighting calculations, which are part of Lumen’s global illumination solution.

The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 32 pixels and can be modified at runtime.

The associated variable GTranslucencyFroxelGridPixelSize directly interacts with r.Lumen.TranslucencyVolume.GridPixelSize. They share the same value, and GTranslucencyFroxelGridPixelSize is used throughout the C++ code to reference this setting.

Developers must be aware that changing this value affects the performance and quality of translucency lighting. A smaller grid size (lower value) will result in higher quality lighting but at the cost of performance, while a larger grid size (higher value) will improve performance but may reduce lighting quality for translucent objects.

Best practices when using this variable include:

  1. Balancing between quality and performance based on the specific needs of the project.
  2. Testing different values to find the optimal setting for your scene.
  3. Consider adjusting this value dynamically based on the scene complexity or distance from the camera.

Regarding the associated variable GTranslucencyFroxelGridPixelSize:

The purpose of GTranslucencyFroxelGridPixelSize is to provide a C++ accessible version of the r.Lumen.TranslucencyVolume.GridPixelSize console variable. It’s used internally in the rendering code to determine the size of the translucency grid cells.

This variable is used in various calculations within the Lumen translucency volume lighting system, including determining grid sizes, calculating parameters for shaders, and setting up the translucency lighting volume.

The value of GTranslucencyFroxelGridPixelSize is set by the console variable system when r.Lumen.TranslucencyVolume.GridPixelSize is modified.

Developers should be aware that this variable is used in performance-critical rendering code, and its value can significantly impact both the quality of translucent lighting and the performance of the rendering system.

Best practices for using GTranslucencyFroxelGridPixelSize include:

  1. Avoid modifying it directly in C++ code; instead, use the console variable r.Lumen.TranslucencyVolume.GridPixelSize to ensure consistency.
  2. When optimizing rendering performance, consider the impact of this variable on your specific scenes and adjust accordingly.
  3. Be cautious when changing this value, as it can affect the balance between lighting quality and performance.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseScalability.ini:287, section: [GlobalIlluminationQuality@2]

Location: <Workspace>/Engine/Config/BaseScalability.ini:310, section: [GlobalIlluminationQuality@3]

Location: <Workspace>/Engine/Config/BaseScalability.ini:334, section: [GlobalIlluminationQuality@Cine]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:36

Scope: file

Source code excerpt:

int32 GTranslucencyFroxelGridPixelSize = 32;
FAutoConsoleVariableRef CVarTranslucencyFroxelGridPixelSize(
	TEXT("r.Lumen.TranslucencyVolume.GridPixelSize"),
	GTranslucencyFroxelGridPixelSize,
	TEXT("Size of a cell in the translucency grid, in pixels."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GTranslucencyGridDistributionLogZScale = .01f;

#Associated Variable and Callsites

This variable is associated with another variable named GTranslucencyFroxelGridPixelSize. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:34

Scope: file

Source code excerpt:

);

int32 GTranslucencyFroxelGridPixelSize = 32;
FAutoConsoleVariableRef CVarTranslucencyFroxelGridPixelSize(
	TEXT("r.Lumen.TranslucencyVolume.GridPixelSize"),
	GTranslucencyFroxelGridPixelSize,
	TEXT("Size of a cell in the translucency grid, in pixels."),
	ECVF_Scalability | ECVF_RenderThreadSafe
);

float GTranslucencyGridDistributionLogZScale = .01f;
FAutoConsoleVariableRef CVarTranslucencyGridDistributionLogZScale(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:577

Scope (from outer to inner):

file
function     FLumenTranslucencyLightingVolumeParameters GetTranslucencyLightingVolumeParameters

Source code excerpt:

FLumenTranslucencyLightingVolumeParameters GetTranslucencyLightingVolumeParameters(const FViewInfo& View)
{
	const FIntPoint GridSizeXY = FIntPoint::DivideAndRoundUp(View.ViewRect.Size(), GTranslucencyFroxelGridPixelSize);
	const float FarPlane = LumenTranslucencyVolume::GetEndDistanceFromCamera(View);

	FVector ZParams;
	int32 GridSizeZ;
	GetTranslucencyGridZParams(View.NearClippingDistance, FarPlane, ZParams, GridSizeZ);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:588

Scope (from outer to inner):

file
function     FLumenTranslucencyLightingVolumeParameters GetTranslucencyLightingVolumeParameters

Source code excerpt:

	FLumenTranslucencyLightingVolumeParameters Parameters;
	Parameters.TranslucencyGIGridZParams = (FVector3f)ZParams;
	Parameters.TranslucencyGIGridPixelSizeShift = FMath::FloorLog2(GTranslucencyFroxelGridPixelSize);
	Parameters.TranslucencyGIGridSize = TranslucencyGridSize;

	Parameters.UseJitter = GTranslucencyVolumeJitter;
	Parameters.FrameJitterOffset = (FVector3f)TranslucencyVolumeTemporalRandom(View.ViewState ? View.ViewState->GetFrameIndex() : 0);
	Parameters.UnjitteredClipToTranslatedWorld = FMatrix44f(View.ViewMatrices.ComputeInvProjectionNoAAMatrix() * View.ViewMatrices.GetTranslatedViewMatrix().GetTransposed());		// LWC_TODO: Precision loss?
	Parameters.GridCenterOffsetFromDepthBuffer = GTranslucencyVolumeGridCenterOffsetFromDepthBuffer;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:602

Scope (from outer to inner):

file
function     FLumenTranslucencyLightingVolumeParameters GetTranslucencyLightingVolumeParameters

Source code excerpt:

	
	Parameters.FurthestHZBTexture = View.HZB;
	Parameters.HZBMipLevel = FMath::Max<float>((int32)FMath::FloorLog2(GTranslucencyFroxelGridPixelSize) - 1, 0.0f);
	Parameters.ViewportUVToHZBBufferUV = FVector2f(
		float(View.ViewRect.Width()) / float(2 * View.HZBMipmap0Size.X),
		float(View.ViewRect.Height()) / float(2 * View.HZBMipmap0Size.Y));

	return Parameters;
}

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenTranslucencyVolumeLighting.cpp:929

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::ComputeLumenTranslucencyGIVolume

Source code excerpt:


			View.GetOwnLumenTranslucencyGIVolume().GridZParams = (FVector)VolumeParameters.TranslucencyGIGridZParams;
			View.GetOwnLumenTranslucencyGIVolume().GridPixelSizeShift = FMath::FloorLog2(GTranslucencyFroxelGridPixelSize);
			View.GetOwnLumenTranslucencyGIVolume().GridSize = TranslucencyGridSize;
		}
	}
}