r.Water.WaterMesh.EnableRendering
r.Water.WaterMesh.EnableRendering
#Overview
name: r.Water.WaterMesh.EnableRendering
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Turn off all water rendering from within the scene proxy
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.Water.WaterMesh.EnableRendering is to control the rendering of water meshes in Unreal Engine 5’s water system. This setting variable is primarily used for the rendering system, specifically for water-related rendering.
The Unreal Engine subsystem that relies on this setting variable is the Water plugin, which is part of the experimental features in UE5. This can be seen from the file paths in the callsites, which are located in the “Plugins/Experimental/Water” directory.
The value of this variable is set as a console variable (CVar) with an initial value of 1, meaning water mesh rendering is enabled by default. It can be changed at runtime through the console or programmatically.
This variable interacts closely with other water-related variables, particularly:
- CVarWaterEnabled
- CVarWaterMeshEnabled
Developers must be aware that:
- This variable affects the rendering thread, as indicated by the ECVF_RenderThreadSafe flag.
- Changing this variable will trigger a callback (NotifyWaterVisibilityChanged) in the WaterSubsystem.
- The variable is used in conjunction with IsWaterMeshEnabled to determine if water mesh rendering should occur.
Best practices when using this variable include:
- Use it for debugging or performance optimization purposes.
- Be cautious when disabling water mesh rendering, as it may affect the visual quality of your game.
- Consider the impact on other water-related systems when modifying this variable.
Regarding the associated variable CVarWaterMeshEnableRendering:
The purpose of CVarWaterMeshEnableRendering is to provide a programmatic way to control the r.Water.WaterMesh.EnableRendering console variable. It’s used internally by the Water plugin to manage the state of water mesh rendering.
This variable is used across multiple files in the Water plugin, including WaterMeshSceneProxy.cpp, WaterSubsystem.cpp, and WaterUtils.cpp. It’s primarily used to check the current state of water mesh rendering and to set up callbacks for when the value changes.
The value of CVarWaterMeshEnableRendering is set when the TAutoConsoleVariable is created, mirroring the value of r.Water.WaterMesh.EnableRendering.
CVarWaterMeshEnableRendering interacts closely with other water-related variables, particularly CVarWaterEnabled and CVarWaterMeshEnabled. These variables work together to determine the overall state of water rendering in the engine.
Developers should be aware that:
- Changes to this variable will affect the rendering thread.
- The variable is used in the WaterSubsystem to manage water visibility changes.
- It’s used in utility functions like IsWaterMeshRenderingEnabled to determine if water mesh rendering should occur.
Best practices when using CVarWaterMeshEnableRendering include:
- Use it in conjunction with other water-related variables for a comprehensive control over water rendering.
- Be aware of its thread-safe nature when accessing its value in different contexts (render thread vs. game thread).
- Consider using the provided utility functions (like IsWaterMeshRenderingEnabled) instead of directly accessing the variable when possible.
#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:100
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarWaterMeshEnableRendering(
TEXT("r.Water.WaterMesh.EnableRendering"),
1,
TEXT("Turn off all water rendering from within the scene proxy"),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarWaterMeshShowLODLevels(
#Associated Variable and Callsites
This variable is associated with another variable named CVarWaterMeshEnableRendering
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterMeshSceneProxy.cpp:99
Scope: file
Source code excerpt:
);
TAutoConsoleVariable<int32> CVarWaterMeshEnableRendering(
TEXT("r.Water.WaterMesh.EnableRendering"),
1,
TEXT("Turn off all water rendering from within the scene proxy"),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterSubsystem.cpp:116
Scope: file
Source code excerpt:
extern TAutoConsoleVariable<int32> CVarWaterMeshEnabled;
extern TAutoConsoleVariable<int32> CVarWaterMeshEnableRendering;
// ----------------------------------------------------------------------------------
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
/** Debug-only struct for displaying some information about which post process material is being used : */
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterSubsystem.cpp:264
Scope (from outer to inner):
file
function void UWaterSubsystem::Initialize
Source code excerpt:
CVarWaterEnabled->SetOnChangedCallback(NotifyWaterVisibilityChanged);
CVarWaterMeshEnabled->SetOnChangedCallback(NotifyWaterVisibilityChanged);
CVarWaterMeshEnableRendering->SetOnChangedCallback(NotifyWaterVisibilityChanged);
#if WITH_EDITOR
GetDefault<UWaterRuntimeSettings>()->OnSettingsChange.AddUObject(this, &UWaterSubsystem::ApplyRuntimeSettings);
#endif //WITH_EDITOR
ApplyRuntimeSettings(GetDefault<UWaterRuntimeSettings>(), EPropertyChangeType::ValueSet);
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterSubsystem.cpp:326
Scope (from outer to inner):
file
function void UWaterSubsystem::Deinitialize
Source code excerpt:
CVarWaterEnabled->SetOnChangedCallback(NullCallback);
CVarWaterMeshEnabled->SetOnChangedCallback(NullCallback);
CVarWaterMeshEnableRendering->SetOnChangedCallback(NullCallback);
World->OnBeginPostProcessSettings.RemoveAll(this);
World->RemovePostProcessVolume(&UnderwaterPostProcessVolume);
GetWaterBodyManagerInternal().Deinitialize();
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterUtils.cpp:8
Scope: file
Source code excerpt:
extern TAutoConsoleVariable<int32> CVarWaterEnabled;
extern TAutoConsoleVariable<int32> CVarWaterMeshEnabled;
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);
#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterUtils.cpp:117
Scope (from outer to inner):
file
function bool FWaterUtils::IsWaterMeshRenderingEnabled
Source code excerpt:
bool FWaterUtils::IsWaterMeshRenderingEnabled(bool bIsRenderThread)
{
return IsWaterMeshEnabled(bIsRenderThread) && !!(bIsRenderThread ? CVarWaterMeshEnableRendering.GetValueOnRenderThread() : CVarWaterMeshEnableRendering.GetValueOnGameThread());
}
float FWaterUtils::GetWaterMaxFlowVelocity(bool bIsRenderThread)
{
return (bIsRenderThread ? CVarWaterMaxFlowVelocity.GetValueOnRenderThread() : CVarWaterMaxFlowVelocity.GetValueOnGameThread());
}