r.NormalCurvatureToRoughnessBias

r.NormalCurvatureToRoughnessBias

#Overview

name: r.NormalCurvatureToRoughnessBias

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.NormalCurvatureToRoughnessBias is to bias the roughness resulting from screen space normal changes for materials with NormalCurvatureToRoughness enabled. This setting variable is part of the rendering system in Unreal Engine 5, specifically dealing with material properties and how they interact with lighting.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evidenced by its location in the SceneRendering.cpp file within the Runtime/Renderer/Private directory.

The value of this variable is set through the console variable system (CVarNormalCurvatureToRoughnessBias). It has a default value of 0.0f and can be changed at runtime.

This variable interacts with two other variables:

  1. CVarNormalCurvatureToRoughnessScale
  2. CVarNormalCurvatureToRoughnessExponent

These three variables together form a vector (NormalCurvatureToRoughnessScaleBias) used in the view uniform shader parameters.

Developers must be aware that:

  1. The valid range for this variable is [-1, 1].
  2. It’s a render thread safe and scalability-related variable (ECVF_RenderThreadSafe | ECVF_Scalability).
  3. Changes to this variable will affect the appearance of materials that use the NormalCurvatureToRoughness feature.

Best practices when using this variable include:

  1. Use it in conjunction with the other related variables (Scale and Exponent) for fine-tuning material appearance.
  2. Be cautious when adjusting it, as it can significantly impact the visual quality of materials.
  3. Test changes across different lighting conditions and material types to ensure desired results.

Regarding the associated variable CVarNormalCurvatureToRoughnessBias: This is the actual console variable that stores and manages the r.NormalCurvatureToRoughnessBias value. It’s defined using TAutoConsoleVariable, which allows for runtime modification. The variable is used in the SetupUniformBufferParameters function to set the Y component of the NormalCurvatureToRoughnessScaleBias vector in the view uniform shader parameters. When using this variable, developers should ensure they’re accessing it through the appropriate Unreal Engine console variable interfaces and be aware of its impact on shader parameters.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:319

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarNormalCurvatureToRoughnessBias(
	TEXT("r.NormalCurvatureToRoughnessBias"),
	0.0f,
	TEXT("Biases the roughness resulting from screen space normal changes for materials with NormalCurvatureToRoughness enabled.  Valid range [-1, 1]"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarNormalCurvatureToRoughnessExponent(
	TEXT("r.NormalCurvatureToRoughnessExponent"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:318

Scope: file

Source code excerpt:

	);

static TAutoConsoleVariable<float> CVarNormalCurvatureToRoughnessBias(
	TEXT("r.NormalCurvatureToRoughnessBias"),
	0.0f,
	TEXT("Biases the roughness resulting from screen space normal changes for materials with NormalCurvatureToRoughness enabled.  Valid range [-1, 1]"),
	ECVF_RenderThreadSafe | ECVF_Scalability);

static TAutoConsoleVariable<float> CVarNormalCurvatureToRoughnessExponent(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:1810

Scope (from outer to inner):

file
function     void FViewInfo::SetupUniformBufferParameters

Source code excerpt:


	ViewUniformShaderParameters.NormalCurvatureToRoughnessScaleBias.X = FMath::Clamp(CVarNormalCurvatureToRoughnessScale.GetValueOnAnyThread(), 0.0f, 2.0f);
	ViewUniformShaderParameters.NormalCurvatureToRoughnessScaleBias.Y = FMath::Clamp(CVarNormalCurvatureToRoughnessBias.GetValueOnAnyThread(), -1.0f, 1.0f);
	ViewUniformShaderParameters.NormalCurvatureToRoughnessScaleBias.Z = FMath::Clamp(CVarNormalCurvatureToRoughnessExponent.GetValueOnAnyThread(), .05f, 20.0f);

	ViewUniformShaderParameters.RenderingReflectionCaptureMask = bIsReflectionCapture ? 1.0f : 0.0f;
	ViewUniformShaderParameters.RealTimeReflectionCapture = 0.0f;
	ViewUniformShaderParameters.RealTimeReflectionCapturePreExposure = 1.0f; // This must be 1 for now. If changed, we need to update the SkyLight AverageExposure and take it into account when sampling sky specular and diffuse irradiance.