r.Water.WaterMesh.GPUQuadTree.MultiSampling

r.Water.WaterMesh.GPUQuadTree.MultiSampling

#Overview

name: r.Water.WaterMesh.GPUQuadTree.MultiSampling

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.MultiSampling is to control the multi-sampling of the water mesh rendering into the GPU water quadtree. It is used to reduce missing water tile artifacts near the edges of water bodies.

This setting variable is part of the water rendering system in Unreal Engine 5, specifically within the Experimental Water plugin. It is primarily used in the WaterMeshSceneProxy module, which handles the rendering of water meshes.

The value of this variable is set through a console variable (CVarWaterMeshGPUQuadTreeMultiSampling) with a default value of 1. It can be adjusted at runtime, with a minimum value of 1 and a maximum value of 8.

This variable interacts closely with other water rendering settings, particularly:

  1. CVarWaterMeshGPUQuadTreeNumJitterSamples
  2. CVarWaterMeshGPUQuadTreeSuperSampling
  3. CVarWaterMeshGPUQuadTreeJitterSampleFootprint
  4. CVarWaterMeshGPUQuadTreeJitterPattern
  5. CVarWaterMeshGPUQuadTreeConservativeRasterization

Developers should be aware that increasing this value will improve the quality of water edge rendering but may also increase rendering overhead. It’s important to balance visual quality with performance requirements.

Best practices when using this variable include:

  1. Start with the default value (1) and increase it only if edge artifacts are noticeable.
  2. Test different values to find the optimal balance between visual quality and performance for your specific use case.
  3. Consider the interaction with other water rendering settings, especially jitter samples, for a comprehensive approach to water edge quality.

The associated variable CVarWaterMeshGPUQuadTreeMultiSampling is the actual console variable that controls this setting. It is used in the BuildGPUQuadTree function of the FWaterMeshSceneProxy class to set the number of MSAA samples for water mesh rendering. The value is clamped between 1 and 8 to ensure it stays within a reasonable range. This variable directly affects the Params.NumMSAASamples parameter used in the water mesh rendering process.

#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:40

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTreeMultiSampling(
	TEXT("r.Water.WaterMesh.GPUQuadTree.MultiSampling"), 1,
	TEXT("Rasterizes water meshes into the GPU water quadtree with a multisampled rendertarget, reducing missing water tile artifacts near the edges of water bodies. Default: 1, Min: 1, Max : 8"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTreeNumJitterSamples(
	TEXT("r.Water.WaterMesh.GPUQuadTree.NumJitterSamples"), 4,
	TEXT("Rasterizes water meshes into the GPU water quadtree with multiple jittered draw calls, reducing missing water tile artifacts near the edges of water bodies. Default: 4, Min: 1, Max : 16. 1 disables this feature."),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTreeMultiSampling(
	TEXT("r.Water.WaterMesh.GPUQuadTree.MultiSampling"), 1,
	TEXT("Rasterizes water meshes into the GPU water quadtree with a multisampled rendertarget, reducing missing water tile artifacts near the edges of water bodies. Default: 1, Min: 1, Max : 8"),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTreeNumJitterSamples(
	TEXT("r.Water.WaterMesh.GPUQuadTree.NumJitterSamples"), 4,

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

Scope (from outer to inner):

file
function     void FWaterMeshSceneProxy::BuildGPUQuadTree

Source code excerpt:

	Params.RequestedQuadTreeResolution = Resolution;
	Params.SuperSamplingFactor = FMath::Clamp(CVarWaterMeshGPUQuadTreeSuperSampling.GetValueOnRenderThread(), 1, 8);
	Params.NumMSAASamples = FMath::Clamp(CVarWaterMeshGPUQuadTreeMultiSampling.GetValueOnRenderThread(), 1, 8);
	Params.NumJitterSamples = FMath::Clamp(CVarWaterMeshGPUQuadTreeNumJitterSamples.GetValueOnRenderThread(), 1, 16);
	Params.JitterSampleFootprint = FMath::Max(CVarWaterMeshGPUQuadTreeJitterSampleFootprint.GetValueOnRenderThread(), 0.0f);
	Params.CaptureDepthRange = WaterQuadTreeDepthRange;
	Params.bUseMSAAJitterPattern = CVarWaterMeshGPUQuadTreeJitterPattern.GetValueOnRenderThread() == 1;
	Params.bUseConservativeRasterization = bAllDrawsAreConservativeRasterCompatible && CVarWaterMeshGPUQuadTreeConservativeRasterization.GetValueOnRenderThread() != 0;