p.ChaosCloth.UseTimeStepSmoothing
p.ChaosCloth.UseTimeStepSmoothing
#Overview
name: p.ChaosCloth.UseTimeStepSmoothing
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Use time step smoothing to avoid jitter during drastic changes in time steps.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.ChaosCloth.UseTimeStepSmoothing is to control time step smoothing in the Chaos Cloth simulation system to avoid jitter during drastic changes in time steps.
This setting variable is primarily used in the Chaos Cloth simulation system, which is part of the ChaosCloth plugin in Unreal Engine 5. It’s specifically utilized in the clothing simulation module.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of true in the ChaosClothingSimulation.cpp file.
The associated variable bClothUseTimeStepSmoothing interacts directly with p.ChaosCloth.UseTimeStepSmoothing. They share the same value, with bClothUseTimeStepSmoothing being used in the actual simulation code.
Developers must be aware that this variable affects the smoothness of cloth simulation, particularly when there are significant changes in time steps. Disabling it might lead to more apparent jitter in cloth movement during such changes.
Best practices when using this variable include:
- Keeping it enabled (true) for most scenarios to ensure smooth cloth simulation.
- Only disabling it if there’s a specific need for more responsive, albeit potentially jittery, cloth behavior.
- Being cautious when changing its value during runtime, as it could lead to noticeable changes in cloth behavior.
Regarding the associated variable bClothUseTimeStepSmoothing:
- Its purpose is to directly control the time step smoothing in the simulation code.
- It’s used within the ChaosCloth plugin, specifically in the FClothingSimulation::Simulate function.
- Its value is set by the p.ChaosCloth.UseTimeStepSmoothing console variable.
- It directly affects how the delta time is calculated for the cloth simulation.
- Developers should be aware that this variable directly impacts the simulation’s behavior and performance.
- Best practice is to avoid modifying this variable directly in code, instead using the console variable to ensure consistency across the engine.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulation.cpp:60
Scope: file
Source code excerpt:
{
bool bClothUseTimeStepSmoothing = true;
FAutoConsoleVariableRef CVarClothUseTimeStepSmoothing(TEXT("p.ChaosCloth.UseTimeStepSmoothing"), bClothUseTimeStepSmoothing, TEXT("Use time step smoothing to avoid jitter during drastic changes in time steps."));
#if CHAOS_DEBUG_DRAW
namespace ClothingSimulationCVar
{
TAutoConsoleVariable<bool> DebugDrawLocalSpace (TEXT("p.ChaosCloth.DebugDrawLocalSpace" ), false, TEXT("Whether to debug draw the Chaos Cloth local space"), ECVF_Cheat);
TAutoConsoleVariable<bool> DebugDrawBounds (TEXT("p.ChaosCloth.DebugDrawBounds" ), false, TEXT("Whether to debug draw the Chaos Cloth bounds"), ECVF_Cheat);
#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/Graph/Nodes/MovieGraphGlobalGameOverrides.cpp:84
Scope (from outer to inner):
file
function void UMovieGraphGlobalGameOverridesNode::BuildNewProcessCommandLineArgsImpl
Source code excerpt:
InOutDeviceProfileCvars.Add(FString::Printf(TEXT("p.Chaos.ImmPhys.MinStepTime=%d"), 0));
InOutDeviceProfileCvars.Add(FString::Printf(TEXT("r.SkipRedundantTransformUpdate=%d"), 0));
InOutDeviceProfileCvars.Add(FString::Printf(TEXT("p.ChaosCloth.UseTimeStepSmoothing=%d"), 0));
}
void UMovieGraphGlobalGameOverridesNode::ApplySettings(const bool bOverrideValues, UWorld* InWorld)
{
// Apply the scalability settings
if (bOverrideValues)
#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/Graph/Nodes/MovieGraphGlobalGameOverrides.cpp:168
Scope (from outer to inner):
file
function void UMovieGraphGlobalGameOverridesNode::ApplySettings
Source code excerpt:
// Cloth's time step smoothing messes up the change in number of simulation substeps that fixes the cloth simulation behavior when using Temporal Samples.
MOVIEPIPELINE_STORE_AND_OVERRIDE_CVAR_INT(PreviousChaosClothUseTimeStepSmoothing, TEXT("p.ChaosCloth.UseTimeStepSmoothing"), 0, bOverrideValues);
// Water skips water info texture when the world's game viewport rendering is disabled so we need to prevent this from happening.
MOVIEPIPELINE_STORE_AND_OVERRIDE_CVAR_INT_IF_EXIST(PreviousSkipWaterInfoTextureRenderWhenWorldRenderingDisabled, TEXT("r.Water.SkipWaterInfoTextureRenderWhenWorldRenderingDisabled"), 0, bOverrideValues);
}
#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/MoviePipelineGameOverrideSetting.cpp:135
Scope (from outer to inner):
file
function void UMoviePipelineGameOverrideSetting::ApplyCVarSettings
Source code excerpt:
// Cloth's time step smoothing messes up the change in number of simulation substeps that fixes the cloth simulation behavior when using Temporal Samples.
MOVIEPIPELINE_STORE_AND_OVERRIDE_CVAR_INT(PreviousChaosClothUseTimeStepSmoothing, TEXT("p.ChaosCloth.UseTimeStepSmoothing"), 0, bOverrideValues);
// Water skips water info texture when the world's game viewport rendering is disabled so we need to prevent this from happening.
MOVIEPIPELINE_STORE_AND_OVERRIDE_CVAR_INT_IF_EXIST(PreviousSkipWaterInfoTextureRenderWhenWorldRenderingDisabled, TEXT("r.Water.SkipWaterInfoTextureRenderWhenWorldRenderingDisabled"), 0, bOverrideValues);
// Must come after the above cvars so that if one of those cvars is also specified by the Scalability level, then we restore to the value in the original scalability level
// not the value we cached in the Cinematic level (if applied).
#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineCore/Private/MoviePipelineGameOverrideSetting.cpp:243
Scope (from outer to inner):
file
function void UMoviePipelineGameOverrideSetting::BuildNewProcessCommandLineArgsImpl
Source code excerpt:
InOutDeviceProfileCvars.Add(FString::Printf(TEXT("p.Chaos.ImmPhys.MinStepTime=%d"), 0));
InOutDeviceProfileCvars.Add(FString::Printf(TEXT("r.SkipRedundantTransformUpdate=%d"), 0));
InOutDeviceProfileCvars.Add(FString::Printf(TEXT("p.ChaosCloth.UseTimeStepSmoothing=%d"), 0));
}
#Associated Variable and Callsites
This variable is associated with another variable named bClothUseTimeStepSmoothing
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulation.cpp:59
Scope: file
Source code excerpt:
namespace Chaos
{
bool bClothUseTimeStepSmoothing = true;
FAutoConsoleVariableRef CVarClothUseTimeStepSmoothing(TEXT("p.ChaosCloth.UseTimeStepSmoothing"), bClothUseTimeStepSmoothing, TEXT("Use time step smoothing to avoid jitter during drastic changes in time steps."));
#if CHAOS_DEBUG_DRAW
namespace ClothingSimulationCVar
{
TAutoConsoleVariable<bool> DebugDrawLocalSpace (TEXT("p.ChaosCloth.DebugDrawLocalSpace" ), false, TEXT("Whether to debug draw the Chaos Cloth local space"), ECVF_Cheat);
TAutoConsoleVariable<bool> DebugDrawBounds (TEXT("p.ChaosCloth.DebugDrawBounds" ), false, TEXT("Whether to debug draw the Chaos Cloth bounds"), ECVF_Cheat);
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulation.cpp:494
Scope (from outer to inner):
file
function void FClothingSimulation::Simulate
Source code excerpt:
const Softs::FSolverReal DeltaTime = (Softs::FSolverReal)Context->DeltaSeconds;
const Softs::FSolverReal PrevDeltaTime = Solver->GetDeltaTime();
const Softs::FSolverReal SmoothedDeltaTime = bClothUseTimeStepSmoothing ?
PrevDeltaTime + (DeltaTime - PrevDeltaTime) * DeltaTimeDecay :
DeltaTime;
const double StartTime = FPlatformTime::Seconds();
const float PrevSimulationTime = SimulationTime; // Copy the atomic to prevent a re-read