r.SSR.MaxRoughness

r.SSR.MaxRoughness

#Overview

name: r.SSR.MaxRoughness

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.SSR.MaxRoughness is to control the maximum roughness value for screen space reflections (SSR) in Unreal Engine’s rendering system. It allows developers to override the post-process setting ScreenSpaceReflectionMaxRoughness, which defines the roughness threshold at which screen space reflections are faded out.

This setting variable is primarily used by Unreal Engine’s rendering subsystem, specifically the post-processing and screen space reflection components. It’s directly referenced in the SceneView.cpp file, which is part of the Engine module.

The value of this variable is set through the console variable system (CVarSSRMaxRoughness). It can be modified at runtime using console commands or through code.

The associated variable CVarSSRMaxRoughness interacts directly with r.SSR.MaxRoughness. They share the same value and purpose.

Developers must be aware of the following when using this variable:

  1. The valid range is 0 to 1, where 0 means no roughness (perfect reflection) and 1 means maximum roughness.
  2. Setting the value to -1 means no override, allowing the post-process volume settings to take effect.
  3. This setting is primarily for testing purposes and is not intended for scalability or project settings.

Best practices when using this variable include:

  1. Use it sparingly and primarily for testing or debugging purposes.
  2. Be aware that lower values (e.g., 0.8) can improve performance but may reduce the quality of reflections on rougher surfaces.
  3. For production, rely on post-process volume settings rather than this override.
  4. When using it, consider the impact on both visual quality and performance.

Regarding the associated variable CVarSSRMaxRoughness:

The purpose of CVarSSRMaxRoughness is to provide a programmatic interface to the r.SSR.MaxRoughness setting. It’s an implementation detail that allows the engine to interact with the console variable system.

This variable is used in the Engine module, specifically in the SceneView component of the rendering system.

The value of CVarSSRMaxRoughness is set when the console variable r.SSR.MaxRoughness is modified, either through console commands or code.

CVarSSRMaxRoughness interacts directly with the FinalPostProcessSettings.ScreenSpaceReflectionMaxRoughness property, applying the override when a valid value is set.

Developers should be aware that modifying CVarSSRMaxRoughness directly is not recommended. Instead, they should use the r.SSR.MaxRoughness console variable or appropriate engine APIs to modify this setting.

Best practices for CVarSSRMaxRoughness align with those of r.SSR.MaxRoughness, emphasizing its use for testing and debugging rather than as a primary means of controlling screen space reflections in production environments.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:45

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarSSRMaxRoughness(
	TEXT("r.SSR.MaxRoughness"),
	-1.0f,
	TEXT("Allows to override the post process setting ScreenSpaceReflectionMaxRoughness.\n")
	TEXT("It defines until what roughness we fade the screen space reflections, 0.8 works well, smaller can run faster.\n")
	TEXT("(Useful for testing, no scalability or project setting)\n")
	TEXT(" 0..1: use specified max roughness (overrride PostprocessVolume setting)\n")
	TEXT(" -1: no override (default)"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:44

Scope: file

Source code excerpt:

IMPLEMENT_GLOBAL_SHADER_PARAMETER_STRUCT(FMobileDirectionalLightShaderParameters, "MobileDirectionalLight");

static TAutoConsoleVariable<float> CVarSSRMaxRoughness(
	TEXT("r.SSR.MaxRoughness"),
	-1.0f,
	TEXT("Allows to override the post process setting ScreenSpaceReflectionMaxRoughness.\n")
	TEXT("It defines until what roughness we fade the screen space reflections, 0.8 works well, smaller can run faster.\n")
	TEXT("(Useful for testing, no scalability or project setting)\n")
	TEXT(" 0..1: use specified max roughness (overrride PostprocessVolume setting)\n")

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:2182

Scope (from outer to inner):

file
function     void FSceneView::EndFinalPostprocessSettings

Source code excerpt:


	{
		float Value = CVarSSRMaxRoughness.GetValueOnGameThread();

		if(Value >= 0.0f)
		{
			FinalPostProcessSettings.ScreenSpaceReflectionMaxRoughness = Value;
		}
	}