r.Water.WaterMesh.GPUQuadTree.JitterPattern

r.Water.WaterMesh.GPUQuadTree.JitterPattern

#Overview

name: r.Water.WaterMesh.GPUQuadTree.JitterPattern

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.Water.WaterMesh.GPUQuadTree.JitterPattern is to control the jitter pattern used when rasterizing water meshes into the GPU water quadtree. This setting is part of the water rendering system in Unreal Engine 5.

This setting variable is primarily used by the Experimental Water plugin, specifically within the water mesh rendering subsystem. It’s referenced in the WaterMeshSceneProxy.cpp file, which is part of the water rendering pipeline.

The value of this variable is set through a console variable (CVarWaterMeshGPUQuadTreeJitterPattern) with a default value of 1. It can be changed at runtime through console commands or programmatically.

This variable interacts closely with CVarWaterMeshGPUQuadTreeJitterSampleFootprint, which controls the pixel footprint of the jitter sample pattern. Together, these variables determine how the water mesh is rasterized into the GPU water quadtree.

Developers should be aware that this variable affects the quality and performance of water rendering. It offers two options: 0: Halton sequence jitter pattern 1: MSAA (Multisample Anti-Aliasing) jitter pattern (default)

Best practices when using this variable include:

  1. Consider the trade-offs between visual quality and performance when choosing between Halton and MSAA patterns.
  2. Test both options in various scenarios to determine which works best for your specific use case.
  3. Be aware that changing this setting might require adjustments to other water rendering parameters for optimal results.

Regarding the associated variable CVarWaterMeshGPUQuadTreeJitterPattern:

This is the actual console variable that stores and manages the r.Water.WaterMesh.GPUQuadTree.JitterPattern setting. It’s an integer variable that directly controls the jitter pattern selection.

The purpose of this variable is to provide a way to access and modify the jitter pattern setting at runtime. It’s used in the BuildGPUQuadTree function of the FWaterMeshSceneProxy class to determine whether to use the MSAA jitter pattern.

Developers should be aware that this variable is marked as ECVF_RenderThreadSafe, meaning it’s safe to access from the render thread. When modifying this value, ensure it’s done in a thread-safe manner, preferably using the appropriate Unreal Engine functions for changing console variables.

Best practices for using this variable include:

  1. Use the provided console command interface to change the value during development and debugging.
  2. If changing programmatically, use the appropriate Unreal Engine functions to ensure thread safety.
  3. Consider exposing this setting in your game’s graphics options menu to allow users to fine-tune water rendering quality.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:50

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTreeJitterPattern(
	TEXT("r.Water.WaterMesh.GPUQuadTree.JitterPattern"), 1,
	TEXT("Jitter pattern when using multiple jittered draw calls to rasterize water meshes into the GPU water quadtree. 0: Halton, 1: MSAA. Default 1"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarWaterMeshGPUQuadTreeJitterSampleFootprint(
	TEXT("r.Water.WaterMesh.GPUQuadTree.JitterSampleFootprint"), 1.5f,
	TEXT("Pixel footprint of the jitter sample pattern. Values greater than 1.0 can cause the water mesh to raster into neighboring pixels not normally covered by the mesh. Default: 1.5, Min 0.0"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:49

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTreeJitterPattern(
	TEXT("r.Water.WaterMesh.GPUQuadTree.JitterPattern"), 1,
	TEXT("Jitter pattern when using multiple jittered draw calls to rasterize water meshes into the GPU water quadtree. 0: Halton, 1: MSAA. Default 1"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarWaterMeshGPUQuadTreeJitterSampleFootprint(
	TEXT("r.Water.WaterMesh.GPUQuadTree.JitterSampleFootprint"), 1.5f,

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:1249

Scope (from outer to inner):

file
function     void FWaterMeshSceneProxy::BuildGPUQuadTree

Source code excerpt:

	Params.JitterSampleFootprint = FMath::Max(CVarWaterMeshGPUQuadTreeJitterSampleFootprint.GetValueOnRenderThread(), 0.0f);
	Params.CaptureDepthRange = WaterQuadTreeDepthRange;
	Params.bUseMSAAJitterPattern = CVarWaterMeshGPUQuadTreeJitterPattern.GetValueOnRenderThread() == 1;
	Params.bUseConservativeRasterization = bAllDrawsAreConservativeRasterCompatible && CVarWaterMeshGPUQuadTreeConservativeRasterization.GetValueOnRenderThread() != 0;

	QuadTreeGPU.Init(GraphBuilder, Params, Draws);
}