r.GeneralPurposeTweak2
r.GeneralPurposeTweak2
#Overview
name: r.GeneralPurposeTweak2
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Useful for low level shader development to get quick iteration time without having to change any c++ code.\nValue maps to Frame.GeneralPurposeTweak2 inside the shaders.\nExample usage: Multiplier on some value to tweak, toggle to switch between different algorithms (Default: 1.0)\nDON\'T USE THIS FOR ANYTHING THAT IS CHECKED IN. Compiled out in SHIPPING to make cheating a bit harder.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.GeneralPurposeTweak2 is to provide a quick iteration tool for low-level shader development without requiring C++ code changes. It’s primarily used in the rendering system of Unreal Engine 5.
This setting variable is mainly relied upon by the Renderer module of Unreal Engine, as evidenced by its location in the SceneRendering.cpp file.
The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 1.0f but can be changed at runtime through console commands.
r.GeneralPurposeTweak2 interacts directly with its associated variable CVarGeneralPurposeTweak2. They share the same value, with CVarGeneralPurposeTweak2 being the actual console variable object that stores and manages the value.
Developers must be aware of several important points when using this variable:
- It’s intended for quick iterations during development and should not be used for any checked-in code.
- The value is mapped to Frame.GeneralPurposeTweak2 inside shaders.
- It’s compiled out in SHIPPING builds to make cheating more difficult.
- It’s render thread safe, meaning it can be safely accessed from the render thread.
Best practices for using this variable include:
- Use it only for temporary tweaks during development.
- Reset it to its default value (1.0) when not actively using it.
- Never rely on it for shipping code or permanent features.
- Document its usage clearly in shader code to avoid confusion.
Regarding the associated variable CVarGeneralPurposeTweak2:
The purpose of CVarGeneralPurposeTweak2 is to serve as the actual console variable object for r.GeneralPurposeTweak2. It provides the interface for getting and setting the value of r.GeneralPurposeTweak2.
This variable is part of the Renderer module and is used in the same contexts as r.GeneralPurposeTweak2.
The value of CVarGeneralPurposeTweak2 is set when it’s initialized and can be changed through console commands that target r.GeneralPurposeTweak2.
CVarGeneralPurposeTweak2 interacts directly with r.GeneralPurposeTweak2, essentially being the backend for that console variable.
Developers should be aware that CVarGeneralPurposeTweak2 is the actual object they interact with when getting the value of r.GeneralPurposeTweak2 in C++ code, as seen in the SetupUniformBufferParameters function.
Best practices for CVarGeneralPurposeTweak2 are the same as for r.GeneralPurposeTweak2, with the addition that developers should use the GetValueOnRenderThread() method when accessing its value from the render thread for thread-safety.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:289
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarGeneralPurposeTweak2(
TEXT("r.GeneralPurposeTweak2"),
1.0f,
TEXT("Useful for low level shader development to get quick iteration time without having to change any c++ code.\n")
TEXT("Value maps to Frame.GeneralPurposeTweak2 inside the shaders.\n")
TEXT("Example usage: Multiplier on some value to tweak, toggle to switch between different algorithms (Default: 1.0)\n")
TEXT("DON'T USE THIS FOR ANYTHING THAT IS CHECKED IN. Compiled out in SHIPPING to make cheating a bit harder."),
ECVF_RenderThreadSafe);
#Associated Variable and Callsites
This variable is associated with another variable named CVarGeneralPurposeTweak2
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:288
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarGeneralPurposeTweak2(
TEXT("r.GeneralPurposeTweak2"),
1.0f,
TEXT("Useful for low level shader development to get quick iteration time without having to change any c++ code.\n")
TEXT("Value maps to Frame.GeneralPurposeTweak2 inside the shaders.\n")
TEXT("Example usage: Multiplier on some value to tweak, toggle to switch between different algorithms (Default: 1.0)\n")
TEXT("DON'T USE THIS FOR ANYTHING THAT IS CHECKED IN. Compiled out in SHIPPING to make cheating a bit harder."),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:1773
Scope (from outer to inner):
file
function void FViewInfo::SetupUniformBufferParameters
Source code excerpt:
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
Value = CVarGeneralPurposeTweak.GetValueOnRenderThread();
Value2 = CVarGeneralPurposeTweak2.GetValueOnRenderThread();
#endif
ViewUniformShaderParameters.GeneralPurposeTweak = Value;
ViewUniformShaderParameters.GeneralPurposeTweak2 = Value2;
}