r.Water.MaxFlowVelocity
r.Water.MaxFlowVelocity
#Overview
name: r.Water.MaxFlowVelocity
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The maximum magnitude for the velocity of a river to encode in the WaterInfo texture
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.MaxFlowVelocity is to set the maximum magnitude for the velocity of a river that can be encoded in the WaterInfo texture within Unreal Engine’s water simulation system.
This setting variable is primarily used by the Water plugin, which is an experimental feature in Unreal Engine 5. It is part of the water rendering and simulation subsystem.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1024.0f, but can be changed at runtime through console commands or programmatically.
The associated variable CVarWaterMaxFlowVelocity directly interacts with r.Water.MaxFlowVelocity. They share the same value and purpose.
Developers must be aware that this variable affects the encoding of river velocity in the WaterInfo texture. Setting it too low might result in clamping of high-velocity flows, while setting it too high might reduce the precision of velocity encoding for slower flows.
Best practices when using this variable include:
- Adjust it based on the expected range of river velocities in your scene.
- Consider the trade-off between accommodating high velocities and maintaining precision for slower flows.
- Test different values to find the optimal balance for your specific water simulation needs.
Regarding the associated variable CVarWaterMaxFlowVelocity:
- It’s the actual C++ variable that stores and provides access to the r.Water.MaxFlowVelocity value.
- It’s implemented as a TAutoConsoleVariable, allowing for easy runtime modification.
- The GetWaterMaxFlowVelocity function provides a thread-safe way to access this value, returning the appropriate value depending on whether it’s called from the render thread or game thread.
- When using this variable in code, always use the GetWaterMaxFlowVelocity function to ensure thread-safe access.
Developers should be cautious when directly accessing or modifying CVarWaterMaxFlowVelocity and should prefer using the provided utility functions like GetWaterMaxFlowVelocity for safe access to the value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterUtils.cpp:11
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarWaterMaxFlowVelocity(
TEXT("r.Water.MaxFlowVelocity"),
1024.0f,
TEXT("The maximum magnitude for the velocity of a river to encode in the WaterInfo texture"),
ECVF_Default);
UMaterialInstanceDynamic* FWaterUtils::GetOrCreateTransientMID(UMaterialInstanceDynamic* InMID, FName InMIDName, UMaterialInterface* InMaterialInterface, EObjectFlags InAdditionalObjectFlags)
{
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMaxFlowVelocity
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterUtils.cpp:10
Scope: file
Source code excerpt:
extern TAutoConsoleVariable<int32> CVarWaterMeshEnableRendering;
static TAutoConsoleVariable<float> CVarWaterMaxFlowVelocity(
TEXT("r.Water.MaxFlowVelocity"),
1024.0f,
TEXT("The maximum magnitude for the velocity of a river to encode in the WaterInfo texture"),
ECVF_Default);
UMaterialInstanceDynamic* FWaterUtils::GetOrCreateTransientMID(UMaterialInstanceDynamic* InMID, FName InMIDName, UMaterialInterface* InMaterialInterface, EObjectFlags InAdditionalObjectFlags)
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterUtils.cpp:122
Scope (from outer to inner):
file
function float FWaterUtils::GetWaterMaxFlowVelocity
Source code excerpt:
float FWaterUtils::GetWaterMaxFlowVelocity(bool bIsRenderThread)
{
return (bIsRenderThread ? CVarWaterMaxFlowVelocity.GetValueOnRenderThread() : CVarWaterMaxFlowVelocity.GetValueOnGameThread());
}
FVector4f FWaterUtils::PackFlowData(float VelocityMagnitude, float DirectionAngle)
{
check((DirectionAngle >= 0.f) && (DirectionAngle <= TWO_PI));
checkf(VelocityMagnitude >= 0., TEXT("We expect a positive magnitude"));