r.HairStrands.LightFunction
r.HairStrands.LightFunction
#Overview
name: r.HairStrands.LightFunction
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables Light function on hair
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.HairStrands.LightFunction is to enable or disable light functions on hair strands in Unreal Engine’s rendering system. This setting is specifically related to the hair rendering and lighting subsystem within Unreal Engine 5.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the part responsible for light rendering and hair strand rendering. This can be seen from the file location “LightRendering.cpp” where the variable is defined and used.
The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, meaning light functions on hair are enabled by default. Developers can change this value at runtime using console commands or through project settings.
This variable interacts closely with its associated variable CVarAppliedLightFunctionOnHair. They share the same value and purpose, with CVarAppliedLightFunctionOnHair being the actual console variable that controls the behavior.
Developers must be aware that this setting affects the performance and visual quality of hair rendering in the engine. Enabling light functions on hair (value > 0) may increase rendering complexity and potentially impact performance, especially in scenes with complex hair and lighting setups.
Best practices when using this variable include:
- Consider the performance implications of enabling light functions on hair, especially for performance-critical applications or on lower-end hardware.
- Test the visual difference with this setting enabled and disabled to determine if the visual improvement justifies any potential performance cost.
- Use this in conjunction with other hair rendering settings for optimal results.
Regarding the associated variable CVarAppliedLightFunctionOnHair:
The purpose of CVarAppliedLightFunctionOnHair is the same as r.HairStrands.LightFunction - to control whether light functions are applied to hair strands in the rendering process.
This console variable is defined in the Renderer module and is used directly in the light rendering process. It’s checked in the RenderLights function of the FDeferredShadingSceneRenderer class.
The value of this variable is set when it’s defined, with a default of 1 (enabled). It can be changed at runtime through console commands.
CVarAppliedLightFunctionOnHair interacts directly with the light rendering process. When its value is greater than 0 and a light function has been rendered, it triggers the rendering of the light function for hair strands.
Developers should be aware that this variable is checked on the render thread, so changes to it will affect rendering in real-time.
Best practices for using CVarAppliedLightFunctionOnHair include:
- Use it in conjunction with other hair and lighting settings for optimal visual results.
- Profile the performance impact of enabling this feature in your specific use case.
- Consider exposing this setting to artists or in game settings if fine control over hair lighting is needed.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:134
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarAppliedLightFunctionOnHair(
TEXT("r.HairStrands.LightFunction"),
1,
TEXT("Enables Light function on hair"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarOnePassProjectionSkipScreenShadowMask(
TEXT("r.Shadow.Virtual.OnePassProjection.SkipScreenShadowMask"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarAppliedLightFunctionOnHair
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:133
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarAppliedLightFunctionOnHair(
TEXT("r.HairStrands.LightFunction"),
1,
TEXT("Enables Light function on hair"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarOnePassProjectionSkipScreenShadowMask(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightRendering.cpp:2050
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderLights
Source code excerpt:
bUsedShadowMaskTexture |= bLightFunctionRendered;
if (CVarAppliedLightFunctionOnHair.GetValueOnRenderThread() > 0 && bLightFunctionRendered && ScreenShadowMaskSubPixelTexture)
{
RenderLightFunction(GraphBuilder, SceneTextures, &LightSceneInfo, ScreenShadowMaskSubPixelTexture, bDrawShadows, false, true);
}
}
if (bDrawPreviewIndicator)