InputColor

InputColor

#Overview

name: InputColor

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 10 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of InputColor is primarily for rendering and color management in various parts of Unreal Engine 5. It serves different roles depending on the context in which it’s used:

  1. In the AjaMedia plugin, it’s used to handle HDMI color space information for input signals.

  2. In the DistCurveEditor, it’s used to represent and manipulate color values in distribution curves.

  3. In the Console subsystem, it’s used to set the color of user input text in the game console.

  4. In the Renderer module, particularly in Lumen reflection tracing and screen space ray tracing, it’s used to handle scene color information for various rendering techniques.

The Unreal Engine subsystems that rely on this variable include the Rendering system, the Console system, and certain media plugins like AjaMedia. It’s also used in editor tools like the Distribution Curve Editor.

The value of this variable is set in different ways depending on the context:

  1. In the AjaMedia plugin, it’s set based on the HDMI input color.
  2. In the DistCurveEditor, it’s derived from key values in the distribution curve.
  3. In the Console settings, it’s likely set through project configuration.
  4. In the Renderer, it’s often assigned based on the current scene color or various history buffers.

This variable often interacts with other color-related variables and textures, such as SceneColor, TemporalAAHistory, and various color space conversion variables.

Developers should be aware that the meaning and usage of InputColor can vary significantly depending on the context. It’s crucial to understand the specific module and function where it’s being used.

Best practices when using this variable include:

  1. Ensuring correct color space conversions when necessary.
  2. Being mindful of performance implications, especially in rendering contexts.
  3. Properly handling cases where the input color might be in a different format or resolution than expected.
  4. In rendering contexts, considering how it interacts with other parts of the rendering pipeline, such as post-processing effects or HDR settings.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseInput.ini:251, section: [/Script/EngineSettings.ConsoleSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Media/AjaMedia/Source/Aja/Private/Helpers.cpp:766

Scope (from outer to inner):

file
namespace    AJA
namespace    Private
function     void Helpers::RouteHdmiSignal

Source code excerpt:

			AJA_CHECK(bIsHDMI);

			NTV2LHIHDMIColorSpace InputColor = NTV2_LHIHDMIColorSpaceYCbCr;
			if (bIsInput)
			{
				AJA_CHECK(InCard->GetHDMIInputColor(InputColor, InChannel));
			}
			else
			{
				const NTV2HDMIColorSpace OutColorSpace = bIsRGB ? NTV2_HDMIColorSpaceRGB : NTV2_HDMIColorSpaceYCbCr;
				AJA_CHECK(InCard->SetHDMIOutColorSpace(OutColorSpace));
			}

			const bool bIsInputRGB = InputColor == NTV2_LHIHDMIColorSpaceRGB;
			const bool bUseCscRouting = bIsRGB != bIsInputRGB;

			if (bIsInput)
			{
				if (InTransportType == ETransportType::TT_Hdmi)
				{

#Loc: <Workspace>/Engine/Source/Editor/DistCurveEditor/Private/SDistributionCurveEditor.cpp:630

Scope (from outer to inner):

file
function     void SDistributionCurveEditor::OnSetColor

Source code excerpt:


	// Get current value of curve as a colour.
	FColor InputColor;
	if (Entry.bFloatingPointColorCurve)
	{
		float Value;

		Value	= EdInterface->GetKeyOut(0, SelKey.KeyIndex) * 255.f;
		InputColor.R = FMath::RoundToInt(Value);
		Value	= EdInterface->GetKeyOut(1, SelKey.KeyIndex) * 255.f;
		InputColor.G = FMath::RoundToInt(Value);
		Value	= EdInterface->GetKeyOut(2, SelKey.KeyIndex) * 255.f;
		InputColor.B = FMath::RoundToInt(Value);
	}
	else
	{
		InputColor.R = FMath::RoundToInt(FMath::Clamp<float>(EdInterface->GetKeyOut(0, SelKey.KeyIndex), 0.f, 255.f));
		InputColor.G = FMath::RoundToInt(FMath::Clamp<float>(EdInterface->GetKeyOut(1, SelKey.KeyIndex), 0.f, 255.f));
		InputColor.B = FMath::RoundToInt(FMath::Clamp<float>(EdInterface->GetKeyOut(2, SelKey.KeyIndex), 0.f, 255.f));
	}

	//since the data isn't stored in standard colors, a temp color is used
	FLinearColor TempColor = InputColor;
	FColorPickerArgs PickerArgs = FColorPickerArgs(InputColor, FOnLinearColorValueChanged::CreateLambda([&TempColor](FLinearColor NewValue){ TempColor = NewValue.ToFColorSRGB(); }));
	PickerArgs.bIsModal = true;
	PickerArgs.bClampValue = true;
	PickerArgs.DisplayGamma = TAttribute<float>::Create( TAttribute<float>::FGetter::CreateUObject(GEngine, &UEngine::GetDisplayGamma) );

	if (OpenColorPicker(PickerArgs))
	{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/Console.cpp:1352

Scope (from outer to inner):

file
function     void UConsole::PostRender_Console_Open

Source code excerpt:

	if (Scrollback.Num())
	{
		FCanvasTextItem ConsoleText(FVector2D(LeftPos, TopPos + Height - 5 - yl), FText::FromString(TEXT("")), GEngine->GetLargeFont(), ConsoleSettings->InputColor);
		// change the text color to white
		ConsoleText.SetColor(FLinearColor::White);

		// while we have enough room to draw another line and there are more lines to draw
		while (y > -yl && idx >= 0)
		{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/Console.cpp:1519

Scope (from outer to inner):

file
function     void UConsole::PostRender_InputLine

Source code excerpt:

	// Currently typed string
	FText Str = FText::FromString(TypedInputText);
	FCanvasTextItem ConsoleText(FVector2D(UserInputLinePos.X, UserInputLinePos.Y - 3 - yl), Str, GEngine->GetLargeFont(), ConsoleSettings->InputColor);
	ConsoleText.EnableShadow(FLinearColor::Black);
	Canvas->DrawItem(ConsoleText);

	// Precompleted remainder of the typed string (faded out)
	if (!PrecompletedInputText.IsEmpty())
	{

#Loc: <Workspace>/Engine/Source/Runtime/EngineSettings/Classes/ConsoleSettings.h:88

Scope (from outer to inner):

file
class        class UConsoleSettings : public UObject

Source code excerpt:

	/** The color used for text input. */
	UPROPERTY(config, EditAnywhere, Category=Colors)
	FColor InputColor;

	/** The color used for the previously typed commands history. */
	UPROPERTY(config, EditAnywhere, Category=Colors)
	FColor HistoryColor;

	/** The autocomplete color used for executable commands. */

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflectionTracing.cpp:767

Scope (from outer to inner):

file
function     FLumenHZBScreenTraceParameters SetupHZBScreenTraceParameters

Source code excerpt:

	FRDGTextureRef CurrentSceneColor = SceneTextures.Color.Resolve;

	FRDGTextureRef InputColor = CurrentSceneColor;
	FIntPoint ViewportOffset = View.ViewRect.Min;
	FIntPoint ViewportExtent = View.ViewRect.Size();
	FIntPoint PrevColorBufferSize = SceneTextures.Config.Extent;

	if (View.PrevViewInfo.CustomSSRInput.IsValid())
	{
		InputColor = GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.CustomSSRInput.RT[0]);
		ViewportOffset = View.PrevViewInfo.CustomSSRInput.ViewportRect.Min;
		ViewportExtent = View.PrevViewInfo.CustomSSRInput.ViewportRect.Size();
		PrevColorBufferSize = InputColor->Desc.Extent;
	}
	else if (View.PrevViewInfo.ScreenSpaceRayTracingInput.IsValid())
	{
		InputColor = GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.ScreenSpaceRayTracingInput);
		ViewportOffset = View.PrevViewInfo.ViewRect.Min;
		ViewportExtent = View.PrevViewInfo.ViewRect.Size();
		PrevColorBufferSize = InputColor->Desc.Extent;
	}

	FLumenHZBScreenTraceParameters Parameters;
	{
		const FVector2D HZBUvFactor(
			float(View.ViewRect.Width()) / float(2 * View.HZBMipmap0Size.X),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Lumen/LumenReflectionTracing.cpp:827

Scope (from outer to inner):

file
function     FLumenHZBScreenTraceParameters SetupHZBScreenTraceParameters

Source code excerpt:

	}

	FScreenPassTextureViewportParameters PrevSceneColorParameters = GetScreenPassTextureViewportParameters(FScreenPassTextureViewport(InputColor, FIntRect(ViewportOffset, ViewportOffset + ViewportExtent)));
	Parameters.PrevSceneColorBilinearUVMin = PrevSceneColorParameters.UVViewportBilinearMin;
	Parameters.PrevSceneColorBilinearUVMax = PrevSceneColorParameters.UVViewportBilinearMax;

	Parameters.PrevSceneColorPreExposureCorrection = InputColor != CurrentSceneColor ? View.PreExposure / View.PrevViewInfo.SceneColorPreExposure : 1.0f;

	Parameters.PrevSceneColorTexture = InputColor;
	Parameters.HistorySceneDepth = bBindLumenHistory && View.ViewState->Lumen.DepthHistoryRT ? GraphBuilder.RegisterExternalTexture(View.ViewState->Lumen.DepthHistoryRT) : SceneTextures.Depth.Target;

	checkf(View.ClosestHZB, TEXT("Lumen screen tracing: ClosestHZB was not setup, should have been setup by FDeferredShadingSceneRenderer::RenderHzb"));
	Parameters.ClosestHZBTexture = View.ClosestHZB;
	Parameters.HZBBaseTexelSize = FVector2f(1.0f / View.ClosestHZB->Desc.Extent.X, 1.0f / View.ClosestHZB->Desc.Extent.Y);

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:997

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     void RenderScreenSpaceReflections

Source code excerpt:

	FTiledReflection* TiledScreenSpaceReflection)
{
	FRDGTextureSRVRef InputColor = GraphBuilder.CreateSRV(FRDGTextureSRVDesc(CurrentSceneColor));
	if (SSRQuality != ESSRQuality::VisualizeSSR)
	{
		if (View.PrevViewInfo.CustomSSRInput.IsValid())
		{
			InputColor = GraphBuilder.CreateSRV(FRDGTextureSRVDesc(
				GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.CustomSSRInput.RT[0])));
		}
		else if (GSSRHalfResSceneColor && View.PrevViewInfo.HalfResTemporalAAHistory.IsValid())
		{
			FRDGTextureRef HalfResTemporalAAHistory = GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.HalfResTemporalAAHistory);

			if (HalfResTemporalAAHistory->Desc.Dimension == ETextureDimension::Texture2DArray)
			{
				InputColor = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::CreateForSlice(HalfResTemporalAAHistory, /* SliceIndex = */ 0));
			}
			else
			{
				InputColor = GraphBuilder.CreateSRV(FRDGTextureSRVDesc(HalfResTemporalAAHistory));
			}
		}
		else if (View.PrevViewInfo.TemporalAAHistory.IsValid())
		{
			FRDGTextureRef TemporalAAHistoryTexture = GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.TemporalAAHistory.RT[0]);
			InputColor = GraphBuilder.CreateSRV(TemporalAAHistoryTexture->Desc.IsTextureArray()
				? FRDGTextureSRVDesc::CreateForSlice(TemporalAAHistoryTexture, View.PrevViewInfo.TemporalAAHistory.OutputSliceIndex)
				: FRDGTextureSRVDesc(TemporalAAHistoryTexture));
		}
	}

	const bool SSRStencilPrePass = CVarSSRStencil.GetValueOnRenderThread() != 0 && SSRQuality != ESSRQuality::VisualizeSSR && TiledScreenSpaceReflection == nullptr;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:1055

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     void RenderScreenSpaceReflections

Source code excerpt:

	CommonParameters.SceneTextures = SceneTextures;
	// Pipe down a mid grey texture when not using TAA's history to avoid wrongly reprojecting current scene color as if previous frame's TAA history.
	if (InputColor->Desc.Texture == CurrentSceneColor || !CommonParameters.SceneTextures.GBufferVelocityTexture)
	{
		// Technically should be 32767.0f / 65535.0f to perfectly null out DecodeVelocityFromTexture(), but 0.5f is good enough.
		CommonParameters.SceneTextures.GBufferVelocityTexture = GraphBuilder.RegisterExternalTexture(GSystemTextures.MidGreyDummy);
	}
	
	FRenderTargetBindingSlots RenderTargets;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ScreenSpaceRayTracing.cpp:1157

Scope (from outer to inner):

file
namespace    ScreenSpaceRayTracing
function     void RenderScreenSpaceReflections
lambda-function

Source code excerpt:

			PassParameters->ScreenSpaceRayTracingDebugOutput = CreateScreenSpaceRayTracingDebugUAV(GraphBuilder, DenoiserInputs->Color->Desc, TEXT("DebugSSR"), true);
		}
		PassParameters->PrevSceneColorPreExposureCorrection = InputColor->Desc.Texture != CurrentSceneColor ? View.PreExposure / View.PrevViewInfo.SceneColorPreExposure : 1.0f;
		PassParameters->ShouldReflectOnlyWater = bSingleLayerWater ? 1u : 0u;
		
		PassParameters->SceneColor = InputColor;
		PassParameters->SceneColorSampler = GSSRHalfResSceneColor ? TStaticSamplerState<SF_Bilinear>::GetRHI() : TStaticSamplerState<SF_Point>::GetRHI();
		
		PassParameters->HZB = View.HZB;
		PassParameters->HZBSampler = TStaticSamplerState<SF_Point>::GetRHI();
	};