r.Refraction.Blur.MaxStandardDeviationInScreenRatio

r.Refraction.Blur.MaxStandardDeviationInScreenRatio

#Overview

name: r.Refraction.Blur.MaxStandardDeviationInScreenRatio

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.Refraction.Blur.MaxStandardDeviationInScreenRatio is to control the maximum refraction blur radius on the screen for the rendering system, specifically for distortion rendering.

This setting variable is primarily used in the Renderer module of Unreal Engine, particularly in the distortion rendering subsystem. It’s referenced in the DistortionRendering.cpp file, which handles the rendering of refractive and distorted materials.

The value of this variable is set as a console variable (CVar) with a default value of 5.0f. It can be modified at runtime through the console or configuration files.

This variable interacts closely with its associated variable CVarRefractionBlurMaxStandardDeviationInScreenPercent, which shares the same value and purpose. It’s used in calculations to determine the maximum mip level for refraction blur.

Developers should be aware that this variable directly affects the visual quality and performance of refraction effects. A higher value allows for more pronounced refraction blur but may impact performance, while a lower value limits the blur effect but could improve performance.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your project’s visual style and performance requirements.
  2. Testing different values to find the right balance between visual quality and performance.
  3. Considering the target hardware when setting this value, as lower-end devices may benefit from a lower setting.

Regarding the associated variable CVarRefractionBlurMaxStandardDeviationInScreenPercent:

The purpose of CVarRefractionBlurMaxStandardDeviationInScreenPercent is identical to r.Refraction.Blur.MaxStandardDeviationInScreenRatio. It’s used internally by the engine to store and access the value set by the console variable.

This variable is used in the same Renderer module and distortion rendering subsystem. It’s directly accessed in the lambda function GetViewRefractionMaxMipLevel within the RenderDistortion function of the FDeferredShadingSceneRenderer class.

The value of this variable is set by the console variable r.Refraction.Blur.MaxStandardDeviationInScreenRatio. It’s not typically set directly but rather accessed through the GetValueOnRenderThread() method.

It interacts with the View object to calculate the maximum mip level for refraction blur based on the view’s dimensions.

Developers should be aware that this variable is used in render thread calculations and should not be modified directly. Instead, they should use the r.Refraction.Blur.MaxStandardDeviationInScreenRatio console variable to adjust the refraction blur effect.

Best practices for this variable are the same as for r.Refraction.Blur.MaxStandardDeviationInScreenRatio, as they represent the same value and purpose within the engine.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistortionRendering.cpp:41

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarRefractionBlurMaxStandardDeviationInScreenPercent(
	TEXT("r.Refraction.Blur.MaxStandardDeviationInScreenRatio"),
	5.0f,
	TEXT("This will clamp the maximum refraction blur radius on screen."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRefractionBlurTemporalAA(
	TEXT("r.Refraction.Blur.TemporalAA"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistortionRendering.cpp:40

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarRefractionBlurMaxStandardDeviationInScreenPercent(
	TEXT("r.Refraction.Blur.MaxStandardDeviationInScreenRatio"),
	5.0f,
	TEXT("This will clamp the maximum refraction blur radius on screen."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRefractionBlurTemporalAA(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DistortionRendering.cpp:835

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderDistortion
lambda-function

Source code excerpt:

	auto GetViewRefractionMaxMipLevel = [](const FViewInfo& View, float StandardDevInPixelForMip0)
	{
		float MaxStandardDeviationInScreenRatio = FMath::Clamp(CVarRefractionBlurMaxStandardDeviationInScreenPercent.GetValueOnRenderThread() / 100.0f, 0.0f, 1.0f);
		float MaxStandardDevInPixel = MaxStandardDeviationInScreenRatio * View.ViewRect.Width();
		float MaxMipLevel = FMath::Loge(MaxStandardDevInPixel / StandardDevInPixelForMip0) / FMath::Loge(2.0f); // This formula is explained in DistortApplyScreenPS.usf.
		return MaxMipLevel;
	};

	// Apply distortion and store off-screen.