r.NormalCurvatureToRoughnessExponent
r.NormalCurvatureToRoughnessExponent
#Overview
name: r.NormalCurvatureToRoughnessExponent
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Exponent on the roughness resulting from screen space normal changes for materials with NormalCurvatureToRoughness enabled.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.NormalCurvatureToRoughnessExponent is to control the exponent applied to the roughness resulting from screen space normal changes for materials with NormalCurvatureToRoughness enabled. This setting is part of the rendering system in Unreal Engine 5, specifically related to material shading and roughness calculations.
The Unreal Engine rendering subsystem relies on this setting variable, as evidenced by its use in the SceneRendering.cpp file, which is a core part of the rendering pipeline.
The value of this variable is set using a TAutoConsoleVariable, which means it can be adjusted at runtime through the console or configuration files. The default value is 0.333f.
This variable interacts with other related variables, such as CVarNormalCurvatureToRoughnessScale and CVarNormalCurvatureToRoughnessBias, which together form a set of parameters for controlling the normal curvature to roughness conversion.
Developers must be aware that this variable affects the visual appearance of materials with NormalCurvatureToRoughness enabled. Changing this value will impact the perceived roughness of surfaces based on their normal map details.
Best practices when using this variable include:
- Keeping the value within a reasonable range (the code clamps it between 0.05f and 20.0f)
- Testing the visual impact of changes in different lighting conditions
- Considering the interaction with other related variables (scale and bias)
- Using it in conjunction with material settings that enable NormalCurvatureToRoughness
The associated variable CVarNormalCurvatureToRoughnessExponent is the actual console variable object that stores and manages the r.NormalCurvatureToRoughnessExponent value. It’s defined as a static TAutoConsoleVariable
The purpose of CVarNormalCurvatureToRoughnessExponent is to provide a programmatic interface for accessing and modifying the r.NormalCurvatureToRoughnessExponent value within the engine’s C++ code.
This variable is used in the FViewInfo::SetupUniformBufferParameters function to set the Z component of the NormalCurvatureToRoughnessScaleBias vector in the ViewUniformShaderParameters struct. This suggests that the value is passed to shaders for use in rendering calculations.
Developers should be aware that this variable is marked with ECVF_RenderThreadSafe and ECVF_Scalability flags, indicating that it’s safe to modify on the render thread and that it’s considered a scalability option.
Best practices for using CVarNormalCurvatureToRoughnessExponent include:
- Using the GetValueOnAnyThread() method to safely retrieve the current value
- Respecting the thread safety implications when modifying the value
- Considering the performance impact of frequent changes, as this affects 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:325
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarNormalCurvatureToRoughnessExponent(
TEXT("r.NormalCurvatureToRoughnessExponent"),
0.333f,
TEXT("Exponent on the roughness resulting from screen space normal changes for materials with NormalCurvatureToRoughness enabled."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarNormalCurvatureToRoughnessScale(
TEXT("r.NormalCurvatureToRoughnessScale"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarNormalCurvatureToRoughnessExponent
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:324
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarNormalCurvatureToRoughnessExponent(
TEXT("r.NormalCurvatureToRoughnessExponent"),
0.333f,
TEXT("Exponent on the roughness resulting from screen space normal changes for materials with NormalCurvatureToRoughness enabled."),
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<float> CVarNormalCurvatureToRoughnessScale(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:1811
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.
ViewUniformShaderParameters.AmbientCubemapTint = FinalPostProcessSettings.AmbientCubemapTint;