r.Substrate.Glints
r.Substrate.Glints
#Overview
name: r.Substrate.Glints
The value of this variable can be defined or overridden in .ini config files. 2
.ini config files referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable Glint support for Substrate slabs. If changed, shaders needs to be recompiled.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Substrate.Glints is to enable or disable Glint support for Substrate slabs in Unreal Engine’s rendering system. This setting is specifically related to the Substrate material model, which is part of the engine’s advanced rendering capabilities.
This setting variable is primarily used by the rendering subsystem of Unreal Engine, particularly in the RenderCore module. It’s also referenced in the Engine module, specifically in material-related classes.
The value of this variable is set through a console variable (CVar) system. It’s defined with a default value of 1 (enabled) and can be changed at runtime, although it’s marked as read-only and render thread safe, suggesting that changes might require shader recompilation.
The r.Substrate.Glints variable interacts with several other components:
- It’s used in conjunction with the IsSubstrateEnabled() function to determine if glints should be rendered.
- It’s associated with material expressions, particularly UMaterialExpressionSubstrateSlabBSDF, where it affects the usage of GlintValue and GlintUV properties.
- It’s used in shader compilation decisions, as indicated by the comment that shader recompilation is needed if changed.
Developers should be aware of the following when using this variable:
- Changing its value requires shader recompilation, which can be a time-consuming process.
- It’s part of an advanced rendering feature (Substrate), so its effects might not be immediately visible without proper material setup.
- It’s read-only at runtime, suggesting that it’s intended to be a project-wide setting rather than something frequently toggled.
Best practices for using this variable include:
- Set it at the project level and avoid frequent changes to prevent unnecessary shader recompilations.
- Ensure that materials using Substrate slabs are properly set up to take advantage of glints when this feature is enabled.
- Be aware of the performance implications of enabling glints, especially on lower-end hardware.
Regarding the associated variable CVarSubstrateGlints: This is the actual console variable that stores the value of r.Substrate.Glints. It’s used internally by the engine to query the current state of the glint feature. The IsGlintEnabled() function checks this variable to determine if glints should be rendered. Developers should generally interact with r.Substrate.Glints rather than CVarSubstrateGlints directly, as the former is the intended interface for this setting.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/Android/AndroidEngine.ini:100, section: [/Script/Engine.RendererSettings]
- INI Section:
/Script/Engine.RendererSettings
- Raw value:
0
- Is Array:
False
Location: <Workspace>/Engine/Config/IOS/BaseIOSEngine.ini:18, section: [/Script/Engine.RendererSettings]
- INI Section:
/Script/Engine.RendererSettings
- Raw value:
0
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:1795
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarSubstrateGlints(
TEXT("r.Substrate.Glints"),
1,
TEXT("Enable Glint support for Substrate slabs. If changed, shaders needs to be recompiled."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarSubstrateGlintsLUT(
TEXT("r.Substrate.Glints.LUT"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Materials/MaterialExpressionSubstrate.h:296
Scope (from outer to inner):
file
class class UMaterialExpressionSubstrateSlabBSDF : public UMaterialExpressionSubstrateBSDF
Source code excerpt:
/**
* This represent the logarithm of the micro facet density. Only used when `r.Substrate.Glints=1`. Defaults to 0.
*/
UPROPERTY()
FExpressionInput GlintValue;
/**
* The parameterization of the surface required to position glints on a surface. Only used when `r.Substrate.Glints=1`. Defaults to (0,0).
*/
UPROPERTY()
FExpressionInput GlintUV;
/** SubsurfaceProfile, for Screen Space Subsurface Scattering. The profile needs to be set up on both the Substrate diffuse node, and the material node at the moment. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Material, meta = (DisplayName = "Subsurface Profile"))
TObjectPtr<class USubsurfaceProfile> SubsurfaceProfile;
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:1931
Scope (from outer to inner):
file
namespace Substrate
function bool IsGlintEnabled
Source code excerpt:
bool IsGlintEnabled(EShaderPlatform InPlatform)
{
static FShaderPlatformCachedIniValue<int32> CVar(TEXT("r.Substrate.Glints"));
return IsSubstrateEnabled() && CVar.Get(InPlatform);
}
uint32 GlintLUTIndex()
{
return CVarSubstrateGlintsLUT.GetValueOnAnyThread()<= 0 ? 0u : 1u;
#Associated Variable and Callsites
This variable is associated with another variable named CVarSubstrateGlints
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:1794
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarSubstrateGlints(
TEXT("r.Substrate.Glints"),
1,
TEXT("Enable Glint support for Substrate slabs. If changed, shaders needs to be recompiled."),
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarSubstrateGlintsLUT(
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderUtils.cpp:1926
Scope (from outer to inner):
file
namespace Substrate
function bool IsGlintEnabled
Source code excerpt:
bool IsGlintEnabled()
{
return IsSubstrateEnabled() && CVarSubstrateGlints.GetValueOnAnyThread() > 0;
}
bool IsGlintEnabled(EShaderPlatform InPlatform)
{
static FShaderPlatformCachedIniValue<int32> CVar(TEXT("r.Substrate.Glints"));
return IsSubstrateEnabled() && CVar.Get(InPlatform);