r.Water.WaterMesh.LODScaleBias
r.Water.WaterMesh.LODScaleBias
#Overview
name: r.Water.WaterMesh.LODScaleBias
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
This value is added to the LOD Scale of each Mesh Component. Negative values will lower the overall density/resolution or the vertex grid and make the LODs smaller, higher values will increase the density/resolution and make the LODs larger. Smallest value is -0.5. That will make the inner LOD as tight and optimized as possible
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.WaterMesh.LODScaleBias is to adjust the Level of Detail (LOD) scale for water mesh components in Unreal Engine 5. This setting variable is specifically used for the water rendering system within the engine.
This variable is primarily used in the Experimental Water plugin, which is part of Unreal Engine 5’s water rendering system. The plugin is located in the Engine/Plugins/Experimental/Water directory.
The value of this variable is set through a console variable (CVarWaterMeshLODScaleBias) with a default value of 0.0f. It can be changed at runtime through console commands or programmatically.
The variable interacts with other water mesh-related variables, such as CVarWaterMeshLODCountBias and CVarWaterMeshTessFactorBias. Together, these variables control the level of detail and tessellation of water meshes.
Developers must be aware that this variable directly affects the density and resolution of the water mesh’s vertex grid. Negative values will lower the overall density/resolution and make the LODs smaller, while positive values will increase the density/resolution and make the LODs larger.
Best practices when using this variable include:
- Use it in conjunction with other water mesh variables for fine-tuning performance and visual quality.
- Be cautious when setting extreme values, as they may impact performance or visual quality significantly.
- Test thoroughly across different hardware configurations to ensure optimal performance.
Regarding the associated variable CVarWaterMeshLODScaleBias:
The purpose of CVarWaterMeshLODScaleBias is to implement the console variable for r.Water.WaterMesh.LODScaleBias. It serves as the internal representation of the setting within the engine’s code.
This variable is used in the WaterMeshComponent.cpp file, which is part of the Experimental Water plugin. It’s primarily used in the UWaterMeshComponent::Update function to detect changes in scalability settings.
The value of CVarWaterMeshLODScaleBias is set when the console variable is initialized and can be accessed using the GetValueOnGameThread() method.
CVarWaterMeshLODScaleBias interacts with other console variables related to water mesh rendering, such as CVarWaterMeshLODCountBias and CVarWaterMeshTessFactorBias.
Developers should be aware that changes to this variable will trigger a rebuild of the water mesh if the value differs from the cached LODScaleBiasScalability value.
Best practices for using CVarWaterMeshLODScaleBias include:
- Use it to implement dynamic adjustments to water mesh LOD scaling based on performance requirements or visual quality settings.
- Cache its value and compare it to detect changes, as demonstrated in the UWaterMeshComponent::Update function.
- Consider its impact on performance when adjusting its value, especially in performance-critical scenarios.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshComponent.cpp:30
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarWaterMeshLODScaleBias(
TEXT("r.Water.WaterMesh.LODScaleBias"), 0.0f,
TEXT("This value is added to the LOD Scale of each Mesh Component. Negative values will lower the overall density/resolution or the vertex grid and make the LODs smaller, higher values will increase the density/resolution and make the LODs larger. Smallest value is -0.5. That will make the inner LOD as tight and optimized as possible"),
ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTree(
TEXT("r.Water.WaterMesh.GPUQuadTree"),
0,
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMeshLODScaleBias
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshComponent.cpp:29
Scope: file
Source code excerpt:
ECVF_Scalability);
static TAutoConsoleVariable<float> CVarWaterMeshLODScaleBias(
TEXT("r.Water.WaterMesh.LODScaleBias"), 0.0f,
TEXT("This value is added to the LOD Scale of each Mesh Component. Negative values will lower the overall density/resolution or the vertex grid and make the LODs smaller, higher values will increase the density/resolution and make the LODs larger. Smallest value is -0.5. That will make the inner LOD as tight and optimized as possible"),
ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarWaterMeshGPUQuadTree(
TEXT("r.Water.WaterMesh.GPUQuadTree"),
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshComponent.cpp:822
Scope (from outer to inner):
file
function void UWaterMeshComponent::Update
Source code excerpt:
const int32 NewLODCountBias = CVarWaterMeshLODCountBias.GetValueOnGameThread();
const int32 NewTessFactorBias = CVarWaterMeshTessFactorBias.GetValueOnGameThread();
const float NewLODScaleBias = CVarWaterMeshLODScaleBias.GetValueOnGameThread();
if (bNeedsRebuild
|| !!CVarWaterMeshShowTileGenerationGeometry.GetValueOnGameThread()
|| !!CVarWaterMeshForceRebuildMeshPerFrame.GetValueOnGameThread()
|| (NewLODCountBias != LODCountBiasScalability)
|| (NewTessFactorBias != TessFactorBiasScalability)
|| (NewLODScaleBias != LODScaleBiasScalability))
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Public/WaterMeshComponent.h:133
Scope (from outer to inner):
file
function class WATER_API UWaterMeshComponent : public UMeshComponent { GENERATED_BODY
Source code excerpt:
int32 TessFactorBiasScalability = 0;
/** Cached CVarWaterMeshLODScaleBias to detect changes in scalability */
float LODScaleBiasScalability = 0.0f;
/** Highest tessellation factor of a water tile. Max number of verts on the side of a tile will be (2^TessellationFactor)+1) */
UPROPERTY(EditAnywhere, Category = Rendering, meta = (ClampMin = "1", ClampMax = "12"))
int32 TessellationFactor = 6;