UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VelocityRendering.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "RHI.h"
7#include "HitProxies.h"
8#include "RendererInterface.h"
9#include "DepthRendering.h"
10
13class FScene;
15class FViewInfo;
16
18
20{
21 // Renders a separate velocity pass for opaques.
22 Opaque = 0,
23
24 // Renders a separate velocity / depth pass for translucency AFTER the translucent pass.
26
27 // Renders a secondary translucent velocity / depth pass for pixels that are clipped by opacity mask clip value (e.g., write has pixel animation mask).
29
30 Count
31};
32
34
35// Group Velocity Rendering accessors, types, etc.
37{
39 static EPixelFormat GetFormat(EShaderPlatform ShaderPlatform);
40
43
45 static FRDGTextureDesc GetRenderTargetDesc(EShaderPlatform ShaderPlatform, FIntPoint Extent, const bool bRequireMultiView = false);
46
48 static bool IsVelocityPassSupported(EShaderPlatform ShaderPlatform);
49
51 static bool DepthPassCanOutputVelocity(ERHIFeatureLevel::Type FeatureLevel);
52
54 static bool BasePassCanOutputVelocity(EShaderPlatform ShaderPlatform);
55
57 static bool IsParallelVelocity(EShaderPlatform ShaderPlatform);
58};
59
64{
65public:
68 const FScene* Scene,
73
75
76 /* Checks whether the primitive should emit velocity for the current view by comparing screen space size against a threshold. */
77 static bool PrimitiveHasVelocityForView(const FViewInfo& View, const FPrimitiveSceneProxy* PrimitiveSceneProxy);
78
79protected:
80 bool Process(
81 const FMeshBatch& MeshBatch,
84 const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy,
85 const FMaterialRenderProxy& RESTRICT MaterialRenderProxy,
86 const FMaterial& RESTRICT MaterialResource,
87 ERasterizerFillMode MeshFillMode,
88 ERasterizerCullMode MeshCullMode);
89
91 const FSceneTexturesConfig& SceneTexturesConfig,
92 const FPSOPrecacheVertexFactoryData& VertexFactoryData,
93 const FMaterial& RESTRICT MaterialResource,
94 ERasterizerFillMode MeshFillMode,
95 ERasterizerCullMode MeshCullMode,
97
98protected:
101};
102
107{
108public:
110 const FScene* Scene,
116
118 static bool PrimitiveCanHaveVelocity(EShaderPlatform ShaderPlatform, const FPrimitiveSceneProxy* PrimitiveSceneProxy);
119 static bool PrimitiveCanHaveVelocity(EShaderPlatform ShaderPlatform, bool bDrawVelocity, bool bHasStaticLighting);
120
122 static bool PrimitiveHasVelocityForFrame(EShaderPlatform ShaderPlatform, const FPrimitiveSceneProxy* PrimitiveSceneProxy);
123
124private:
125 bool TryAddMeshBatch(
128 const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy,
130 const FMaterialRenderProxy* MaterialRenderProxy,
131 const FMaterial* Material);
132
133 virtual void AddMeshBatch(
136 const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy,
137 int32 StaticMeshId = -1) override final;
138
139 virtual void CollectPSOInitializers(
140 const FSceneTexturesConfig& SceneTexturesConfig,
141 const FMaterial& Material,
142 const FPSOPrecacheVertexFactoryData& VertexFactoryData,
145};
146
151class FTranslucentVelocityMeshProcessor : public FSceneRenderingAllocatorObject<FTranslucentVelocityMeshProcessor>, public FVelocityMeshProcessor
152{
153public:
155 const FScene* Scene,
161
163 static bool PrimitiveCanHaveVelocity(EShaderPlatform ShaderPlatform, const FPrimitiveSceneProxy* PrimitiveSceneProxy);
164
166 static bool PrimitiveHasVelocityForFrame(const FPrimitiveSceneProxy* PrimitiveSceneProxy);
167
168private:
169 bool TryAddMeshBatch(
172 const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy,
174 const FMaterialRenderProxy* MaterialRenderProxy,
175 const FMaterial* Material);
176
177 virtual void AddMeshBatch(
180 const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy,
181 int32 StaticMeshId = -1) override final;
182
183 virtual void CollectPSOInitializers(
184 const FSceneTexturesConfig& SceneTexturesConfig,
185 const FMaterial& Material,
186 const FPSOPrecacheVertexFactoryData& VertexFactoryData,
189};
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define RESTRICT
Definition Platform.h:706
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EDepthDrawingMode
Definition DepthRendering.h:21
@ DDM_None
Definition DepthRendering.h:23
EPixelFormat
Definition PixelFormat.h:16
ERasterizerCullMode
Definition RHIDefinitions.h:369
ETextureCreateFlags
Definition RHIDefinitions.h:1091
ERasterizerFillMode
Definition RHIDefinitions.h:358
EShaderPlatform
Definition RHIShaderPlatform.h:11
EMeshPass::Type GetMeshPassFromVelocityPass(EVelocityPass VelocityPass)
Definition VelocityRendering.cpp:361
EVelocityPass
Definition VelocityRendering.h:20
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition MaterialRenderProxy.h:102
Definition MaterialShared.h:2058
Definition MeshPassProcessor.h:1670
Definition MeshPassProcessor.h:2199
const FScene *RESTRICT Scene
Definition MeshPassProcessor.h:2203
ERHIFeatureLevel::Type FeatureLevel
Definition MeshPassProcessor.h:2204
Definition VelocityRendering.h:107
static bool PrimitiveHasVelocityForFrame(EShaderPlatform ShaderPlatform, const FPrimitiveSceneProxy *PrimitiveSceneProxy)
Definition VelocityRendering.cpp:871
static bool PrimitiveCanHaveVelocity(EShaderPlatform ShaderPlatform, const FPrimitiveSceneProxy *PrimitiveSceneProxy)
Definition VelocityRendering.cpp:850
Definition PrimitiveSceneInfo.h:266
Definition PrimitiveSceneProxy.h:296
Definition SceneView.h:1425
Definition ScenePrivate.h:2875
Definition StaticMeshBatch.h:16
Definition VelocityRendering.h:152
static bool PrimitiveHasVelocityForFrame(const FPrimitiveSceneProxy *PrimitiveSceneProxy)
Definition VelocityRendering.cpp:1050
static bool PrimitiveCanHaveVelocity(EShaderPlatform ShaderPlatform, const FPrimitiveSceneProxy *PrimitiveSceneProxy)
Definition VelocityRendering.cpp:1040
Definition VelocityRendering.h:64
bool CollectPSOInitializersInternal(const FSceneTexturesConfig &SceneTexturesConfig, const FPSOPrecacheVertexFactoryData &VertexFactoryData, const FMaterial &RESTRICT MaterialResource, ERasterizerFillMode MeshFillMode, ERasterizerCullMode MeshCullMode, TArray< FPSOPrecacheData > &PSOInitializers)
Definition VelocityRendering.cpp:1279
EDepthDrawingMode EarlyZPassMode
Definition VelocityRendering.h:99
FMeshPassProcessorRenderState PassDrawRenderState
Definition VelocityRendering.h:74
EMeshPass::Type MeshPassType
Definition VelocityRendering.h:100
static bool PrimitiveHasVelocityForView(const FViewInfo &View, const FPrimitiveSceneProxy *PrimitiveSceneProxy)
Definition VelocityRendering.cpp:812
Definition SceneRendering.h:1132
Definition Array.h:670
Definition ConcurrentLinearAllocator.h:571
Type
Definition MeshPassProcessor.h:38
@ Num
Definition MeshPassProcessor.h:86
Type
Definition RHIFeatureLevel.h:20
Definition MeshBatch.h:371
Definition MeshPassProcessor.h:2118
Definition PSOPrecache.h:30
Definition PSOPrecache.h:150
Definition PrimitiveViewRelevance.h:14
Definition RenderGraphDefinitions.h:627
Definition SceneTexturesConfig.h:114
Definition VelocityRendering.h:37
static EPixelFormat GetFormat(EShaderPlatform ShaderPlatform)
Definition VelocityRendering.cpp:758
static bool IsVelocityPassSupported(EShaderPlatform ShaderPlatform)
Definition VelocityRendering.cpp:786
static bool BasePassCanOutputVelocity(EShaderPlatform ShaderPlatform)
Definition VelocityRendering.cpp:800
static bool IsParallelVelocity(EShaderPlatform ShaderPlatform)
Definition VelocityRendering.cpp:805
static bool DepthPassCanOutputVelocity(ERHIFeatureLevel::Type FeatureLevel)
Definition VelocityRendering.cpp:793
static FRDGTextureDesc GetRenderTargetDesc(EShaderPlatform ShaderPlatform, FIntPoint Extent, const bool bRequireMultiView=false)
Definition VelocityRendering.cpp:781
static ETextureCreateFlags GetCreateFlags(EShaderPlatform ShaderPlatform)
Definition VelocityRendering.cpp:774
Definition IntPoint.h:25