r.DemosaicVposOffset
r.DemosaicVposOffset
#Overview
name: r.DemosaicVposOffset
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
This offset is added to the rasterized position used for demosaic in the mobile tonemapping shader. It exists to workaround driver bugs on some Android devices that have a half-pixel offset.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DemosaicVposOffset is to add an offset to the rasterized position used for demosaic in the mobile tonemapping shader. It is specifically designed to address driver bugs on certain Android devices that exhibit a half-pixel offset.
This setting variable is primarily used in the rendering system of Unreal Engine 5, particularly in the mobile rendering pipeline. Based on the callsites, it appears to be utilized within the Renderer module, specifically in the scene rendering process.
The value of this variable is set through the console variable system in Unreal Engine. It is defined as a TAutoConsoleVariable with a default value of 0.0f, which can be modified at runtime.
The associated variable CVarDemosaicVposOffset interacts directly with r.DemosaicVposOffset. They share the same value, and CVarDemosaicVposOffset is used to retrieve the current value of the setting in the render thread.
Developers must be aware that this variable is specifically targeted at mobile platforms, particularly Android devices with known driver issues. It should be used cautiously and only when necessary to address the half-pixel offset problem on affected devices.
Best practices when using this variable include:
- Only modify it when encountering specific rendering artifacts on Android devices related to demosaicing.
- Test thoroughly on various Android devices to ensure the offset doesn’t negatively impact rendering on unaffected devices.
- Document any changes made to this variable, including the specific devices and scenarios where it was necessary.
- Consider creating a device-specific override rather than applying it globally if only certain devices require the offset.
Regarding the associated variable CVarDemosaicVposOffset:
The purpose of CVarDemosaicVposOffset is to provide a programmatic interface to access and modify the r.DemosaicVposOffset value within the engine’s C++ code.
This variable is used in the Renderer module, specifically in the scene rendering process. It allows the engine to retrieve the current value of the demosaic offset in a thread-safe manner.
The value of CVarDemosaicVposOffset is set automatically by the console variable system when r.DemosaicVposOffset is modified. It directly reflects the value of r.DemosaicVposOffset.
CVarDemosaicVposOffset interacts with the ViewUniformShaderParameters struct, specifically setting the DemosaicVposOffset member variable used in shader uniforms.
Developers should be aware that CVarDemosaicVposOffset should be accessed using the GetValueOnRenderThread() method to ensure thread-safety when used in rendering code.
Best practices for using CVarDemosaicVposOffset include:
- Always access it using GetValueOnRenderThread() in render thread code.
- Avoid caching its value; instead, retrieve it when needed to ensure the most up-to-date setting is used.
- Consider the performance implications of frequently accessing this variable in performance-critical rendering code.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:190
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarDemosaicVposOffset(
TEXT("r.DemosaicVposOffset"),
0.0f,
TEXT("This offset is added to the rasterized position used for demosaic in the mobile tonemapping shader. It exists to workaround driver bugs on some Android devices that have a half-pixel offset."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarDecalDepthBias(
TEXT("r.DecalDepthBias"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarDemosaicVposOffset
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:189
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarDemosaicVposOffset(
TEXT("r.DemosaicVposOffset"),
0.0f,
TEXT("This offset is added to the rasterized position used for demosaic in the mobile tonemapping shader. It exists to workaround driver bugs on some Android devices that have a half-pixel offset."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarDecalDepthBias(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:1782
Scope (from outer to inner):
file
function void FViewInfo::SetupUniformBufferParameters
Source code excerpt:
ViewUniformShaderParameters.DemosaicVposOffset = 0.0f;
{
ViewUniformShaderParameters.DemosaicVposOffset = CVarDemosaicVposOffset.GetValueOnRenderThread();
}
ViewUniformShaderParameters.DecalDepthBias = CVarDecalDepthBias.GetValueOnRenderThread();
ViewUniformShaderParameters.IndirectLightingColorScale = FVector3f(FinalPostProcessSettings.IndirectLightingColor.R * FinalPostProcessSettings.IndirectLightingIntensity,
FinalPostProcessSettings.IndirectLightingColor.G * FinalPostProcessSettings.IndirectLightingIntensity,