r.VolumetricFog.GridPixelSize
r.VolumetricFog.GridPixelSize
#Overview
name: r.VolumetricFog.GridPixelSize
The value of this variable can be defined or overridden in .ini config files. 3
.ini config files referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
XY Size of a cell in the voxel grid, in pixels.
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.VolumetricFog.GridPixelSize is to control the XY size of a cell in the voxel grid for volumetric fog rendering, measured in pixels. This setting is primarily used in the rendering system, specifically for volumetric fog calculations.
Unreal Engine’s rendering module relies on this setting variable, particularly in the volumetric fog subsystem. The main files that reference this variable are VolumetricFog.cpp and FogRendering.cpp, which are part of the renderer’s implementation.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 16 and can be changed at runtime using the console command “r.VolumetricFog.GridPixelSize”.
This variable interacts closely with GVolumetricFogGridPixelSize, which is an associated variable that shares the same value. They are used interchangeably in different parts of the code.
Developers must be aware that this variable directly affects the resolution and performance of volumetric fog rendering. A smaller value will result in higher quality but more expensive fog calculations, while a larger value will be more performance-friendly but may reduce visual quality.
Best practices when using this variable include:
- Balancing quality and performance by adjusting the value based on the target hardware.
- Consider scaling this value dynamically based on performance metrics or quality settings.
- Test thoroughly with different values to ensure visual consistency across various scenes.
Regarding the associated variable GVolumetricFogGridPixelSize:
The purpose of GVolumetricFogGridPixelSize is the same as r.VolumetricFog.GridPixelSize, serving as an internal representation of the console variable.
It’s used in various calculations within the volumetric fog rendering system, such as determining the fog grid size and calculating upsample jitter.
The value of this variable is set by the console variable system and is used throughout the rendering code where direct access to the grid pixel size is needed.
GVolumetricFogGridPixelSize interacts with other variables in the volumetric fog system, such as GVolumetricFogGridSizeZ, which controls the Z dimension of the fog grid.
Developers should be aware that modifying GVolumetricFogGridPixelSize directly in code is not recommended, as it may be overwritten by the console variable system. Instead, they should use the r.VolumetricFog.GridPixelSize console variable to change this value.
Best practices for GVolumetricFogGridPixelSize include:
- Always access it through the GetVolumetricFogGridPixelSize() function to ensure a valid, non-zero value.
- Consider the performance implications when using this value in rendering calculations.
- Be aware of its relationship with other volumetric fog settings for consistent results.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseScalability.ini:187, section: [ShadowQuality@2]
- INI Section:
ShadowQuality@2
- Raw value:
16
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseScalability.ini:214, section: [ShadowQuality@3]
- INI Section:
ShadowQuality@3
- Raw value:
8
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseScalability.ini:241, section: [ShadowQuality@Cine]
- INI Section:
ShadowQuality@Cine
- Raw value:
4
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:57
Scope: file
Source code excerpt:
int32 GVolumetricFogGridPixelSize = 16;
FAutoConsoleVariableRef CVarVolumetricFogGridPixelSize(
TEXT("r.VolumetricFog.GridPixelSize"),
GVolumetricFogGridPixelSize,
TEXT("XY Size of a cell in the voxel grid, in pixels."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
int32 GVolumetricFogGridSizeZ = 64;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:1199
Scope (from outer to inner):
file
function FVector2f GetVolumetricFogFroxelToScreenSVPosRatio
Source code excerpt:
// Calculate how much the Fog froxel volume "overhangs" the actual view frustum to the right and bottom.
// This needs to be applied on SVPos because froxel pixel size (see r.VolumetricFog.GridPixelSize) does not align perfectly with view rect.
int32 VolumetricFogGridPixelSize;
const FIntVector VolumetricFogGridSize = GetVolumetricFogViewGridSize(View, VolumetricFogGridPixelSize);
const FVector2f FogPhysicalSize = FVector2f(VolumetricFogGridSize.X, VolumetricFogGridSize.Y) * VolumetricFogGridPixelSize;
const FVector2f ClipRatio = FogPhysicalSize / FVector2f(ViewRectSize);
return ClipRatio;
}
#Associated Variable and Callsites
This variable is associated with another variable named GVolumetricFogGridPixelSize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:269
Scope: file
Source code excerpt:
const FScreenPassTextureViewportParameters& LightShaftParameters)
{
extern int32 GVolumetricFogGridPixelSize;
FFogPassParameters* PassParameters = GraphBuilder.AllocParameters<FFogPassParameters>();
PassParameters->SceneTextures = SceneTexturesUniformbuffer;
PassParameters->VS.ViewUniformBuffer = GetShaderBinding(View.ViewUniformBuffer);
PassParameters->PS.ViewUniformBuffer = GetShaderBinding(View.ViewUniformBuffer);
PassParameters->PS.FogUniformBuffer = FogUniformBuffer;
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/FogRendering.cpp:283
Scope: file
Source code excerpt:
PassParameters->PS.OcclusionTextureMinMaxUV = FVector4f(LightShaftParameters.UVViewportBilinearMin, LightShaftParameters.UVViewportBilinearMax);
PassParameters->PS.WaterDepthTextureMinMaxUV = FVector4f::Zero();
PassParameters->PS.UpsampleJitterMultiplier = CVarUpsampleJitterMultiplier.GetValueOnRenderThread() * GVolumetricFogGridPixelSize;
PassParameters->PS.bOnlyOnRenderedOpaque = View.bFogOnlyOnRenderedOpaque;
PassParameters->PS.bUseWaterDepthTexture = false;
PassParameters->PS.SrcCloudDepthTexture = GSystemTextures.GetWhiteDummy(GraphBuilder);
PassParameters->PS.SrcCloudDepthSampler = TStaticSamplerState<SF_Point, AM_Clamp, AM_Clamp, AM_Clamp>::GetRHI();
PassParameters->PS.SrcCloudViewTexture = GSystemTextures.GetWhiteDummy(GraphBuilder);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:55
Scope: file
Source code excerpt:
);
int32 GVolumetricFogGridPixelSize = 16;
FAutoConsoleVariableRef CVarVolumetricFogGridPixelSize(
TEXT("r.VolumetricFog.GridPixelSize"),
GVolumetricFogGridPixelSize,
TEXT("XY Size of a cell in the voxel grid, in pixels."),
ECVF_Scalability | ECVF_RenderThreadSafe
);
int32 GVolumetricFogGridSizeZ = 64;
FAutoConsoleVariableRef CVarVolumetricFogGridSizeZ(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VolumetricFog.cpp:154
Scope (from outer to inner):
file
function static int32 GetVolumetricFogGridPixelSize
Source code excerpt:
static int32 GetVolumetricFogGridPixelSize()
{
return FMath::Max(1, GVolumetricFogGridPixelSize);
}
static int32 GetVolumetricFogGridSizeZ()
{
return FMath::Max(1, GVolumetricFogGridSizeZ);
}