r.Roughness.Max
r.Roughness.Max
#Overview
name: r.Roughness.Max
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows quick material test by remapping the roughness at 1 to a new value (0..1), Only for non shipping built!\n1: (default)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Roughness.Max is to allow quick material testing by remapping the maximum roughness value in materials. It is primarily used for the rendering system in Unreal Engine 5.
This setting variable is utilized by the rendering subsystem of Unreal Engine, specifically in the scene view setup process. It’s part of the Engine module, as evidenced by its location in the SceneView.cpp file within the Engine source directory.
The value of this variable is set through a console variable (CVarRoughnessMax) with a default value of 1.0f. It can be changed at runtime using console commands or through code.
The r.Roughness.Max variable interacts with another variable called r.Roughness.Min (represented by CVarRoughnessMin in the code). Together, they define the range for roughness remapping in materials.
Developers must be aware that this variable is intended for non-shipping builds only, as indicated by the ECVF_Cheat flag in its declaration. It’s meant for quick material testing and debugging purposes, not for use in final, released versions of a game.
Best practices when using this variable include:
- Only use it for testing and debugging materials during development.
- Be cautious when adjusting this value, as it can significantly affect the appearance of materials in the scene.
- Remember to reset it to the default value (1.0) before building for release.
Regarding the associated variable CVarRoughnessMax:
The purpose of CVarRoughnessMax is to serve as the actual console variable that stores and manages the r.Roughness.Max setting. It’s the programmatic representation of the r.Roughness.Max console command.
This variable is part of the Engine module and is used in the rendering system, specifically in the FSceneView setup process.
The value of CVarRoughnessMax is set when the console variable is declared, with a default value of 1.0f. It can be modified at runtime using console commands or through C++ code.
CVarRoughnessMax interacts directly with CVarRoughnessMin to define the roughness remapping range for materials.
Developers should be aware that this variable is marked with ECVF_Cheat and ECVF_RenderThreadSafe flags. The former indicates it’s for development/debugging use only, while the latter means it’s safe to access from the render thread.
Best practices for using CVarRoughnessMax include:
- Access its value using GetValueOnRenderThread() when in render thread context.
- Use it in conjunction with CVarRoughnessMin for a complete control over roughness remapping.
- Remember that changes to this variable will affect all materials in the scene, so use it judiciously.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:302
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarRoughnessMax(
TEXT("r.Roughness.Max"),
1.0f,
TEXT("Allows quick material test by remapping the roughness at 1 to a new value (0..1), Only for non shipping built!\n")
TEXT("1: (default)"),
ECVF_Cheat | ECVF_RenderThreadSafe
);
#Associated Variable and Callsites
This variable is associated with another variable named CVarRoughnessMax
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:301
Scope: file
Source code excerpt:
ECVF_Cheat | ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<float> CVarRoughnessMax(
TEXT("r.Roughness.Max"),
1.0f,
TEXT("Allows quick material test by remapping the roughness at 1 to a new value (0..1), Only for non shipping built!\n")
TEXT("1: (default)"),
ECVF_Cheat | ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SceneView.cpp:2589
Scope (from outer to inner):
file
function void FSceneView::SetupCommonViewUniformBufferParameters
Source code excerpt:
float NewMinValue = FMath::Max(MinValue, CVarRoughnessMin.GetValueOnRenderThread());
float NewMaxValue = FMath::Min(MaxValue, CVarRoughnessMax.GetValueOnRenderThread());
LocalRoughnessOverrideParameter.X = NewMinValue;
LocalRoughnessOverrideParameter.Y = NewMaxValue - NewMinValue;
}
#endif