r.VolumetricRenderTarget.UpsamplingMode

r.VolumetricRenderTarget.UpsamplingMode

#Overview

name: r.VolumetricRenderTarget.UpsamplingMode

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.VolumetricRenderTarget.UpsamplingMode is to control the upsampling technique used when compositing volumetric render targets over the scene. This setting is primarily used in the rendering system, specifically for volumetric effects such as clouds.

This setting variable is relied upon by the Unreal Engine’s Renderer module, as evidenced by its location in the VolumetricRenderTarget.cpp file within the Runtime/Renderer/Private directory.

The value of this variable is set through a console variable (CVarVolumetricRenderTargetUpsamplingMode) with a default value of 4. It can be changed at runtime through console commands or programmatically.

The variable interacts closely with other volumetric rendering settings, particularly CVarVolumetricRenderTargetMode, as seen in the InitVolumetricRenderTargetForViews function.

Developers must be aware that this variable affects the quality and performance of volumetric effects. The different modes (0 to 4) offer a trade-off between visual quality and performance:

  1. Bilinear
  2. Bilinear + jitter
  3. Nearest + depth test
  4. Bilinear + jitter + keep closest
  5. Bilateral upsampling (default)

Best practices when using this variable include:

  1. Testing different modes to find the best balance between visual quality and performance for your specific use case.
  2. Consider lowering the upsampling mode on lower-end hardware for better performance.
  3. Be aware that changing this setting may require adjustments to other volumetric rendering settings for optimal results.

The associated variable CVarVolumetricRenderTargetUpsamplingMode is the actual console variable that controls this setting. It’s defined with the same default value (4) and description as r.VolumetricRenderTarget.UpsamplingMode. This variable is used directly in the code to retrieve the current upsampling mode value, as seen in the InitVolumetricRenderTargetForViews function.

When working with CVarVolumetricRenderTargetUpsamplingMode, developers should:

  1. Use GetValueOnRenderThread() or GetValueOnAnyThread() to safely access its value, depending on the context.
  2. Be aware that changes to this variable will affect rendering in real-time, which can be useful for debugging but should be used cautiously in shipping builds.
  3. Consider exposing this setting in user-facing graphics options if fine-tuning volumetric effects is important for your game’s performance or visual style.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricRenderTarget.cpp:32

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarVolumetricRenderTargetUpsamplingMode(
	TEXT("r.VolumetricRenderTarget.UpsamplingMode"), 4,
	TEXT("Used in compositing volumetric RT over the scene. [0] bilinear [1] bilinear + jitter [2] nearest + depth test [3] bilinear + jitter + keep closest [4] bilaterial upsampling"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricRenderTargetPreferAsyncCompute(
	TEXT("r.VolumetricRenderTarget.PreferAsyncCompute"), 0,
	TEXT("Whether to prefer using async compute to generate volumetric cloud render targets."),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricRenderTarget.cpp:31

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricRenderTargetUpsamplingMode(
	TEXT("r.VolumetricRenderTarget.UpsamplingMode"), 4,
	TEXT("Used in compositing volumetric RT over the scene. [0] bilinear [1] bilinear + jitter [2] nearest + depth test [3] bilinear + jitter + keep closest [4] bilaterial upsampling"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<int32> CVarVolumetricRenderTargetPreferAsyncCompute(
	TEXT("r.VolumetricRenderTarget.PreferAsyncCompute"), 0,

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricRenderTarget.cpp:445

Scope (from outer to inner):

file
function     void InitVolumetricRenderTargetForViews

Source code excerpt:

			ViewRect,
			CVarVolumetricRenderTargetMode.GetValueOnRenderThread(),
			CVarVolumetricRenderTargetUpsamplingMode.GetValueOnAnyThread(),
			bCameraCut);

		FViewUniformShaderParameters ViewVolumetricCloudRTParameters = *ViewInfo.CachedViewUniformShaderParameters;
		{
			const FIntPoint& VolumetricReconstructResolution = VolumetricCloudRT.GetCurrentVolumetricReconstructRTResolution();
			const FIntPoint& VolumetricTracingResolution = VolumetricCloudRT.GetCurrentVolumetricTracingRTResolution();