5 #include "Engine/Engine.h" 36 void Reset(int32 InNumVertices);
38 virtual void InitRHI()
override;
47 void SetNum(int32 NewVertexCount);
50 void SetData(
const TArray<uint8>& Data);
52 virtual void Bind(FLocalVertexFactory::FDataType& DataType) = 0;
55 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 19 56 virtual void CreateSRV() = 0;
70 virtual void Bind(FLocalVertexFactory::FDataType& DataType)
override 72 DataType.PositionComponent = FVertexStreamComponent(
this, 0, 12, VET_Float3);
73 #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 19 79 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 19 80 virtual void CreateSRV()
override 94 :
FRuntimeMeshVertexBuffer(InUpdateFrequency, (bInUseHighPrecision ? sizeof(FPackedRGBA16N) : sizeof(FPackedNormal)) * 2)
95 , bUseHighPrecision(bInUseHighPrecision)
100 virtual void Bind(FLocalVertexFactory::FDataType& DataType)
override 102 uint32 TangentSizeInBytes = 0;
103 uint32 TangentXOffset = 0;
104 uint32 TangentZOffset = 0;
105 EVertexElementType TangentElementType = VET_None;
107 if (bUseHighPrecision)
109 TangentElementType = VET_UShort4N;
116 TangentElementType = VET_PackedNormal;
122 #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 19 123 DataType.TangentBasisComponents[0] = FVertexStreamComponent(
this, TangentXOffset, TangentSizeInBytes, TangentElementType, EVertexStreamUsage::ManualFetch);
124 DataType.TangentBasisComponents[1] = FVertexStreamComponent(
this, TangentZOffset, TangentSizeInBytes, TangentElementType, EVertexStreamUsage::ManualFetch);
127 DataType.TangentBasisComponents[0] = FVertexStreamComponent(
this, TangentXOffset, TangentSizeInBytes, TangentElementType);
128 DataType.TangentBasisComponents[1] = FVertexStreamComponent(
this, TangentZOffset, TangentSizeInBytes, TangentElementType);
133 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 20 134 virtual void CreateSRV()
override 136 ShaderResourceView = RHICreateShaderResourceView(VertexBufferRHI, bUseHighPrecision ? 8 : 4, bUseHighPrecision ? PF_R16G16B16A16_SNORM : PF_R8G8B8A8_SNORM);
138 #elif ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 19 139 virtual void CreateSRV()
override 141 ShaderResourceView = RHICreateShaderResourceView(VertexBufferRHI, bUseHighPrecision? 8 : 4, bUseHighPrecision? PF_A16B16G16R16 : PF_R8G8B8A8);
156 :
FRuntimeMeshVertexBuffer(InUpdateFrequency, (bInUseHighPrecision ? sizeof(FVector2D) : sizeof(FVector2DHalf)) * InNumUVs)
157 , bUseHighPrecision(bInUseHighPrecision), NumUVs(InNumUVs)
162 virtual void Bind(FLocalVertexFactory::FDataType& DataType)
override 164 DataType.TextureCoordinates.Empty();
166 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 19 167 DataType.NumTexCoords = NumUVs;
171 EVertexElementType UVDoubleWideVertexElementType = VET_None;
172 EVertexElementType UVVertexElementType = VET_None;
173 uint32 UVSizeInBytes = 0;
174 if (bUseHighPrecision)
176 UVSizeInBytes =
sizeof(FVector2D);
177 UVDoubleWideVertexElementType = VET_Float4;
178 UVVertexElementType = VET_Float2;
182 UVSizeInBytes =
sizeof(FVector2DHalf);
183 UVDoubleWideVertexElementType = VET_Half4;
184 UVVertexElementType = VET_Half2;
187 uint32 UVStride = UVSizeInBytes * NumUVs;
190 for (UVIndex = 0; UVIndex < NumUVs - 1; UVIndex += 2)
192 #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 19 193 DataType.TextureCoordinates.Add(FVertexStreamComponent(
this, UVSizeInBytes * UVIndex, UVStride, UVDoubleWideVertexElementType, EVertexStreamUsage::ManualFetch));
195 DataType.TextureCoordinates.Add(FVertexStreamComponent(
this, UVSizeInBytes * UVIndex, UVStride, UVDoubleWideVertexElementType));
200 if (UVIndex < NumUVs)
202 #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 19 203 DataType.TextureCoordinates.Add(FVertexStreamComponent(
this, UVSizeInBytes * UVIndex, UVStride, UVDoubleWideVertexElementType, EVertexStreamUsage::ManualFetch));
205 DataType.TextureCoordinates.Add(FVertexStreamComponent(
this, UVSizeInBytes * UVIndex, UVStride, UVDoubleWideVertexElementType));
209 #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 19 215 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 19 216 virtual void CreateSRV()
override 218 ShaderResourceView = RHICreateShaderResourceView(VertexBufferRHI, bUseHighPrecision ? 8 : 4, bUseHighPrecision ? PF_G32R32F : PF_G16R16F);
232 virtual void Bind(FLocalVertexFactory::FDataType& DataType)
override 234 #if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION >= 19 235 DataType.ColorComponent = FVertexStreamComponent(
this, 0, 4, EVertexElementType::VET_Color, EVertexStreamUsage::ManualFetch);
238 DataType.ColorComponent = FVertexStreamComponent(
this, 0, 4, EVertexElementType::VET_Color);
243 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 19 244 virtual void CreateSRV()
override 276 virtual void InitRHI()
override;
279 int32
Num() {
return NumIndices; }
285 void SetNum(int32 NewIndexCount);
288 void SetData(
const TArray<uint8>& Data);
299 void Init(FLocalVertexFactory::FDataType VertexStructure);
302 #if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 19 303 virtual uint64 GetStaticBatchElementVisibility(
const class FSceneView& View,
const struct FMeshBatch* Batch,
const void* InViewCustomData =
nullptr)
const;
305 virtual uint64 GetStaticBatchElementVisibility(
const class FSceneView& View,
const struct FMeshBatch* Batch)
const;
virtual void Bind(FLocalVertexFactory::FDataType &DataType) override
const EBufferUsageFlags UsageFlags
int32 GetBufferSize() const
FShaderResourceViewRHIRef ShaderResourceView
~FRuntimeMeshVertexBuffer()
virtual void Bind(FLocalVertexFactory::FDataType &DataType) override
virtual void Bind(FLocalVertexFactory::FDataType &DataType) override
TSharedPtr< FRuntimeMeshSectionProxy, ESPMode::NotThreadSafe > FRuntimeMeshSectionProxyPtr
FRuntimeMeshTangentsVertexBuffer(EUpdateFrequency InUpdateFrequency, bool bInUseHighPrecision)
int32 GetBufferSize() const
virtual void Bind(FLocalVertexFactory::FDataType &DataType) override
EBufferUsageFlags UsageFlags
void Reset(int32 InNumVertices)
FRuntimeMeshVertexBuffer(EUpdateFrequency InUpdateFrequency, int32 InVertexSize)
virtual void Bind(FLocalVertexFactory::FDataType &DataType)=0
FRuntimeMeshSectionProxy * SectionParent
TWeakPtr< FRuntimeMeshSectionProxy, ESPMode::NotThreadSafe > FRuntimeMeshSectionProxyWeakPtr
FRuntimeMeshPositionVertexBuffer(EUpdateFrequency InUpdateFrequency)
#define offsetof(STRUCTURE, FIELD)
~FRuntimeMeshIndexBuffer()
void SetData(const TArray< uint8 > &Data)
virtual void InitRHI() override
FRuntimeMeshColorVertexBuffer(EUpdateFrequency InUpdateFrequency)
void SetNum(int32 NewVertexCount)
FRuntimeMeshUVsVertexBuffer(EUpdateFrequency InUpdateFrequency, bool bInUseHighPrecision, int32 InNumUVs)