r.PathTracing.MISCompensation

r.PathTracing.MISCompensation

#Overview

name: r.PathTracing.MISCompensation

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.PathTracing.MISCompensation is to control the activation of Multiple Importance Sampling (MIS) compensation for skylight importance sampling in the path tracing rendering system of Unreal Engine 5.

This setting variable is primarily used by the path tracing subsystem within the Renderer module of Unreal Engine 5. It is specifically related to the rendering system, particularly the path tracing feature.

The value of this variable is set through a console variable (CVarPathTracingMISCompensation) with a default value of 1 (enabled). It can be changed at runtime using console commands or through engine configuration files.

This variable interacts closely with another setting, r.PathTracing.MISMode. The MIS compensation is only applied when r.PathTracing.MISMode is set to 2.

Developers must be aware that this setting only takes effect under specific conditions (when r.PathTracing.MISMode = 2). It’s important to understand the relationship between these two variables to properly configure the path tracing system.

Best practices when using this variable include:

  1. Ensure that r.PathTracing.MISMode is set to 2 if you want MIS compensation to be active.
  2. Be mindful of the performance implications of enabling MIS compensation, as it may impact rendering times.
  3. Test the visual quality and performance with this setting both enabled and disabled to determine the best configuration for your specific use case.

Regarding the associated variable CVarPathTracingMISCompensation:

The purpose of CVarPathTracingMISCompensation is to provide a programmatic interface for controlling the r.PathTracing.MISCompensation setting within the engine’s C++ code.

This variable is used within the Renderer module, specifically in the path tracing implementation.

The value of CVarPathTracingMISCompensation is set when the console variable is initialized, but it can be changed at runtime using console commands.

CVarPathTracingMISCompensation interacts directly with the Config.UseMISCompensation flag in the path tracing configuration.

Developers should be aware that this variable is of type TAutoConsoleVariable, which means it’s thread-safe and can be accessed from the render thread.

Best practices for using CVarPathTracingMISCompensation include:

  1. Use GetValueOnRenderThread() when accessing its value from render thread code.
  2. Be cautious when changing its value at runtime, as it may affect ongoing rendering processes.
  3. Consider exposing this setting through user interfaces if you want to allow users to toggle MIS compensation.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:124

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarPathTracingMISCompensation(
	TEXT("r.PathTracing.MISCompensation"),
	1,
	TEXT("Activates MIS compensation for skylight importance sampling. (default = 1 (enabled))\n")
	TEXT("This option only takes effect when r.PathTracing.MISMode = 2\n"),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:123

Scope: file

Source code excerpt:

);

TAutoConsoleVariable<int32> CVarPathTracingMISCompensation(
	TEXT("r.PathTracing.MISCompensation"),
	1,
	TEXT("Activates MIS compensation for skylight importance sampling. (default = 1 (enabled))\n")
	TEXT("This option only takes effect when r.PathTracing.MISMode = 2\n"),
	ECVF_RenderThreadSafe
);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:2509

Scope: file

Source code excerpt:


	Config.VisibleLights = CVarPathTracingVisibleLights.GetValueOnRenderThread() != 0;
	Config.UseMISCompensation = Config.PathTracingData.MISMode == 2 && CVarPathTracingMISCompensation.GetValueOnRenderThread() != 0;

	Config.ViewRect = View.ViewRect;

	Config.LightGridResolution = FMath::RoundUpToPowerOfTwo(CVarPathTracingLightGridResolution.GetValueOnRenderThread());
	Config.LightGridMaxCount = FMath::Clamp(CVarPathTracingLightGridMaxCount.GetValueOnRenderThread(), 1, RAY_TRACING_LIGHT_COUNT_MAXIMUM);