r.Refraction.Blur

r.Refraction.Blur

#Overview

name: r.Refraction.Blur

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 is to enable rough refractions, which involves blurring the background in refraction effects. This setting is primarily used in the rendering system of Unreal Engine 5.

This setting variable is relied upon by the Renderer module, specifically in the distortion rendering subsystem. It’s used to determine whether rough refractions should be applied during the rendering process.

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

The associated variable CVarRefractionBlur interacts directly with r.Refraction.Blur. They share the same value and purpose.

Developers must be aware that this variable affects the quality and performance of refraction effects in the game. Enabling it (value > 0) will result in more realistic but potentially more computationally expensive refractions.

Best practices when using this variable include:

  1. Consider the performance impact of enabling rough refractions, especially on lower-end hardware.
  2. Use it in conjunction with other refraction-related settings for optimal results.
  3. Test the visual impact and performance with different values to find the best balance for your game.

Regarding the associated variable CVarRefractionBlur:

The purpose of CVarRefractionBlur is to provide a programmatic way to control the r.Refraction.Blur setting. It’s an auto console variable that directly corresponds to the r.Refraction.Blur setting.

This variable is used in the Renderer module, specifically in the DistortionRendering.cpp file. It’s part of the distortion rendering system.

The value of CVarRefractionBlur is set when the variable is initialized, with a default value of 1. It can be changed at runtime through console commands or programmatically.

CVarRefractionBlur interacts with the GetUseRoughRefraction() function, which checks if the Substrate rendering system is enabled and if CVarRefractionBlur is greater than 0.

Developers should be aware that this variable is thread-safe and can be accessed from any thread, as indicated by the ECVF_RenderThreadSafe flag.

Best practices for using CVarRefractionBlur include:

  1. Use it to programmatically control rough refractions in your rendering code.
  2. Be mindful of threading when accessing or modifying this variable, even though it’s thread-safe.
  3. Consider exposing this setting in your game’s graphics options to allow players to adjust refraction quality.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRefractionBlur(
	TEXT("r.Refraction.Blur"),
	1,
	TEXT("Enables rough refractions, i.e. blurring of the background."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRefractionOffsetQuality(
	TEXT("r.Refraction.OffsetQuality"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_Default);

static TAutoConsoleVariable<int32> CVarRefractionBlur(
	TEXT("r.Refraction.Blur"),
	1,
	TEXT("Enables rough refractions, i.e. blurring of the background."),
	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRefractionOffsetQuality(

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

Scope (from outer to inner):

file
function     static bool GetUseRoughRefraction

Source code excerpt:

static bool GetUseRoughRefraction()
{
	return Substrate::IsSubstrateEnabled() && CVarRefractionBlur.GetValueOnAnyThread() > 0; // Any thread since it can be called when creating the PassProcessor
}

class FDistortionScreenPS : public FGlobalShader
{
public:
	class FUseMSAADim : SHADER_PERMUTATION_BOOL("USE_MSAA");