r.SubsurfaceScattering

r.SubsurfaceScattering

#Overview

name: r.SubsurfaceScattering

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.SubsurfaceScattering is to control the subsurface scattering feature in Unreal Engine’s rendering system. Subsurface scattering is a lighting effect that simulates how light penetrates and scatters within translucent materials, such as skin, wax, or marble.

This setting variable is primarily used by the rendering subsystem of Unreal Engine, specifically in the post-processing stage. It is referenced in the PostProcessSubsurface.cpp file, which is part of the Renderer module.

The value of this variable is set through a console variable (CVarSubsurfaceScattering) with two possible states: 0: disabled 1: enabled (default)

The associated variable CVarSubsurfaceScattering interacts directly with r.SubsurfaceScattering. It’s defined as a TAutoConsoleVariable, which allows it to be changed at runtime through console commands or configuration files.

Developers should be aware that:

  1. This variable affects rendering performance and visual quality.
  2. It’s marked with ECVF_RenderThreadSafe and ECVF_Scalability flags, indicating it’s safe to change on the render thread and can be used for scalability settings.
  3. The actual effect of subsurface scattering also depends on the CVarSSSScale variable, which controls the scale of the effect.

Best practices when using this variable include:

  1. Consider performance implications when enabling subsurface scattering, especially on lower-end hardware.
  2. Use it in conjunction with proper material setup for objects that should exhibit subsurface scattering properties.
  3. Test the visual impact and performance with both enabled and disabled states to determine the best setting for your project.

Regarding the associated variable CVarSubsurfaceScattering:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessSubsurface.cpp:27

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	// Subsurface common parameters
	TAutoConsoleVariable<int32> CVarSubsurfaceScattering(
		TEXT("r.SubsurfaceScattering"),
		1,
		TEXT(" 0: disabled\n")
		TEXT(" 1: enabled (default)"),
		ECVF_RenderThreadSafe | ECVF_Scalability);

	TAutoConsoleVariable<float> CVarSSSScale(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessSubsurface.cpp:26

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

{
	// Subsurface common parameters
	TAutoConsoleVariable<int32> CVarSubsurfaceScattering(
		TEXT("r.SubsurfaceScattering"),
		1,
		TEXT(" 0: disabled\n")
		TEXT(" 1: enabled (default)"),
		ECVF_RenderThreadSafe | ECVF_Scalability);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessSubsurface.cpp:283

Scope (from outer to inner):

file
function     bool IsSubsurfaceEnabled

Source code excerpt:

bool IsSubsurfaceEnabled()
{
	const bool bEnabled = CVarSubsurfaceScattering.GetValueOnAnyThread() != 0;
	const bool bHasScale = CVarSSSScale.GetValueOnAnyThread() > 0.0f;
	return (bEnabled && bHasScale);
}

bool IsSubsurfaceRequiredForView(const FViewInfo& View)
{