ShowFlag.OverrideDiffuseAndSpecular

ShowFlag.OverrideDiffuseAndSpecular

#Overview

name: ShowFlag.OverrideDiffuseAndSpecular

This variable is created as a Console Variable (cvar).

It is referenced in 9 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.OverrideDiffuseAndSpecular is to enable the Detail Lighting viewmode in Unreal Engine 5. This setting is used to override material diffuse and specular properties with constant values, providing a simplified lighting visualization for debugging and analysis purposes.

This setting variable is primarily used by the rendering system in Unreal Engine 5. It is utilized in various subsystems and modules, including:

  1. The core Engine module
  2. The Renderer module
  3. The UnrealEd module (for editor functionality)
  4. The MovieRenderPipeline plugin
  5. The nDisplay plugin (for multi-display setups)

The value of this variable is typically set through the engine’s show flags system, which allows developers to toggle various rendering features on and off. It is often controlled via the viewport or rendering settings in the Unreal Editor.

The OverrideDiffuseAndSpecular variable interacts with several other variables and systems:

  1. It works in conjunction with LightingOnlyOverride and ReflectionOverride to provide different visualization modes.
  2. When enabled, it affects the DiffuseOverrideParameter and SpecularOverrideParameter of the view, setting them to specific constant values.
  3. It influences the ViewMode selection in the rendering pipeline.

Developers should be aware of the following when using this variable:

  1. This setting is primarily intended for debugging and analysis purposes, not for final rendering in shipping builds.
  2. It can significantly alter the appearance of materials in the scene, which may not represent the final look of the game.
  3. The setting is fixed in shipping builds, meaning it cannot be toggled in released games.

Best practices for using this variable include:

  1. Use it in conjunction with other debug visualization tools to get a comprehensive understanding of lighting issues.
  2. Be cautious when using it for final visual adjustments, as it doesn’t represent the actual material properties.
  3. Remember to disable it when not needed, as it can impact performance and visual fidelity.

Regarding the associated variable OverrideDiffuseAndSpecular:

This is the actual variable that stores the state of the show flag. It is used in various parts of the engine to determine whether the diffuse and specular override should be applied. The purpose and usage are essentially the same as described for ShowFlag.OverrideDiffuseAndSpecular. It’s used in rendering-related code to apply the override when enabled, affecting how materials are rendered in the viewport or final output.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:57

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(OnScreenDebug, SFG_Developer, NSLOCTEXT("UnrealEd", "OnScreenDebugSF", "On Screen Debug"))
/** needed for VMI_Lit_DetailLighting, Whether to override material diffuse and specular with constants, used by the Detail Lighting viewmode. */
SHOWFLAG_FIXED_IN_SHIPPING(0, OverrideDiffuseAndSpecular, SFG_Hidden, NSLOCTEXT("UnrealEd", "OverrideDiffuseAndSpecularSF", "Override Diffuse And Specular"))
/** needed for VMI_LightingOnly, Whether to override material diffuse with constants, used by the Lighting Only viewmode. */
SHOWFLAG_FIXED_IN_SHIPPING(0, LightingOnlyOverride, SFG_Hidden, NSLOCTEXT("UnrealEd", "LightingOnlyOverrideSF", "Lighting Only"))
/** needed for VMI_ReflectionOverride, Whether to override all materials to be smooth, mirror reflections. */
SHOWFLAG_FIXED_IN_SHIPPING(0, ReflectionOverride, SFG_Hidden, NSLOCTEXT("UnrealEd", "ReflectionOverrideSF", "Reflections"))
/** needed for VMI_VisualizeBuffer, Whether to enable the buffer visualization mode. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeBuffer, SFG_Hidden, NSLOCTEXT("UnrealEd", "VisualizeBufferSF", "Buffer Visualization"))

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineRenderPasses/Private/MoviePipelineImagePassBase.cpp:417

Scope (from outer to inner):

file
function     void UMoviePipelineImagePassBase::SetupViewForViewModeOverride

Source code excerpt:

		View->SpecularOverrideParameter = FVector4f(0.f, 0.f, 0.f, 0.f);
	}
	else if (View->Family->EngineShowFlags.OverrideDiffuseAndSpecular)
	{
		View->DiffuseOverrideParameter = FVector4f(GEngine->LightingOnlyBrightness.R, GEngine->LightingOnlyBrightness.G, GEngine->LightingOnlyBrightness.B, 0.0f);
		View->SpecularOverrideParameter = FVector4f(.1f, .1f, .1f, 0.0f);
	}
	else if (View->Family->EngineShowFlags.LightingOnlyOverride)
	{

#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayCluster/Private/Game/EngineClasses/Basics/DisplayClusterViewportClient.cpp:604

Scope (from outer to inner):

file
function     void UDisplayClusterViewportClient::Draw

Source code excerpt:

						View->SpecularOverrideParameter = FVector4f(0.f, 0.f, 0.f, 0.f);
					}
					else if (View->Family->EngineShowFlags.OverrideDiffuseAndSpecular)
					{
						View->DiffuseOverrideParameter = FVector4f(GEngine->LightingOnlyBrightness.R, GEngine->LightingOnlyBrightness.G, GEngine->LightingOnlyBrightness.B, 0.0f);
						View->SpecularOverrideParameter = FVector4f(.1f, .1f, .1f, 0.0f);
					}
					else if (View->Family->EngineShowFlags.LightingOnlyOverride)
					{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:4026

Scope (from outer to inner):

file
function     void FEditorViewportClient::SetupViewForRendering

Source code excerpt:

		View.SpecularOverrideParameter = FVector4f(0.f, 0.f, 0.f, 0.f);
	}
	else if (ViewFamily.EngineShowFlags.OverrideDiffuseAndSpecular)
	{
		View.DiffuseOverrideParameter = FVector4f(GEngine->LightingOnlyBrightness.R, GEngine->LightingOnlyBrightness.G, GEngine->LightingOnlyBrightness.B, 0.0f);
		View.SpecularOverrideParameter = FVector4f(.1f, .1f, .1f, 0.0f);
	}
	else if (ViewFamily.EngineShowFlags.LightingOnlyOverride)
	{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:1618

Scope (from outer to inner):

file
function     void UGameViewportClient::Draw

Source code excerpt:

						View->SpecularOverrideParameter = FVector4f(0.f, 0.f, 0.f, 0.f);
					}
					else if (View->Family->EngineShowFlags.OverrideDiffuseAndSpecular)
					{
						View->DiffuseOverrideParameter = FVector4f(GEngine->LightingOnlyBrightness.R, GEngine->LightingOnlyBrightness.G, GEngine->LightingOnlyBrightness.B, 0.0f);
						View->SpecularOverrideParameter = FVector4f(.1f, .1f, .1f, 0.0f);
					}
					else if (View->Family->EngineShowFlags.LightingOnlyOverride)
					{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShowFlags.cpp:775

Scope: file

Source code excerpt:

		}
	}
	else if (EngineShowFlags.OverrideDiffuseAndSpecular)
	{
		return VMI_Lit_DetailLighting;
	}
	else if (EngineShowFlags.LightingOnlyOverride)
	{
		return VMI_LightingOnly;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:57

Scope: file

Source code excerpt:

SHOWFLAG_ALWAYS_ACCESSIBLE(OnScreenDebug, SFG_Developer, NSLOCTEXT("UnrealEd", "OnScreenDebugSF", "On Screen Debug"))
/** needed for VMI_Lit_DetailLighting, Whether to override material diffuse and specular with constants, used by the Detail Lighting viewmode. */
SHOWFLAG_FIXED_IN_SHIPPING(0, OverrideDiffuseAndSpecular, SFG_Hidden, NSLOCTEXT("UnrealEd", "OverrideDiffuseAndSpecularSF", "Override Diffuse And Specular"))
/** needed for VMI_LightingOnly, Whether to override material diffuse with constants, used by the Lighting Only viewmode. */
SHOWFLAG_FIXED_IN_SHIPPING(0, LightingOnlyOverride, SFG_Hidden, NSLOCTEXT("UnrealEd", "LightingOnlyOverrideSF", "Lighting Only"))
/** needed for VMI_ReflectionOverride, Whether to override all materials to be smooth, mirror reflections. */
SHOWFLAG_FIXED_IN_SHIPPING(0, ReflectionOverride, SFG_Hidden, NSLOCTEXT("UnrealEd", "ReflectionOverrideSF", "Reflections"))
/** needed for VMI_VisualizeBuffer, Whether to enable the buffer visualization mode. */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisualizeBuffer, SFG_Hidden, NSLOCTEXT("UnrealEd", "VisualizeBufferSF", "Buffer Visualization"))

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:683

Scope (from outer to inner):

file
function     static void PreparePathTracingData

Source code excerpt:

	PathTracingData.ApplyDiffuseSpecularOverrides =
		ShowFlags.LightingOnlyOverride       != 0 ||
		ShowFlags.OverrideDiffuseAndSpecular != 0 ||
		ShowFlags.ReflectionOverride         != 0;

	PathTracingData.EnabledDirectLightingContributions = 0;
	if (ShowFlags.DirectLighting != 0)
	{
		PathTracingData.EnabledDirectLightingContributions |= (PPV.PathTracingIncludeEmissive != 0                           ) ? PATHTRACER_CONTRIBUTION_EMISSIVE : 0;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/PathTracing.cpp:2496

Scope: file

Source code excerpt:

	Config.LightShowFlags |= View.Family->EngineShowFlags.Diffuse                    ? 1 << 8 : 0;
	Config.LightShowFlags |= View.Family->EngineShowFlags.Specular                   ? 1 << 9 : 0;
	Config.LightShowFlags |= View.Family->EngineShowFlags.OverrideDiffuseAndSpecular ? 1 << 10 : 0;
	Config.LightShowFlags |= View.Family->EngineShowFlags.LightingOnlyOverride       ? 1 << 11 : 0;
	Config.LightShowFlags |= View.Family->EngineShowFlags.ReflectionOverride         ? 1 << 12 : 0;
	Config.LightShowFlags |= View.Family->EngineShowFlags.SubsurfaceScattering       ? 1 << 13 : 0;
	// the following affects which material shaders get used and therefore change the image
	if (Substrate::IsSubstrateEnabled() && CVarPathTracingSubstrateCompileSimplifiedMaterial.GetValueOnRenderThread() != 0)
	{