// Copyright Epic Games, Inc. All Rights Reserved. /*============================================================================= DistortionRendering.h: Distortion rendering implementation. =============================================================================*/ #pragma once #include "CoreMinimal.h" #include "RendererInterface.h" #include "MeshPassProcessor.h" class FPrimitiveSceneProxy; struct FMeshPassProcessorRenderState; /** * Set of distortion scene prims */ class FDistortionPrimSet { public: /** * Iterate over the distortion prims and draw their accumulated offsets * @param ViewInfo - current view used to draw items * @param DPGIndex - current DPG used to draw items * @return true if anything was drawn */ bool DrawAccumulatedOffsets(FRHICommandListImmediate& RHICmdList, const class FViewInfo& View, const FMeshPassProcessorRenderState& DrawRenderState, bool bInitializeOffsets); /** * Adds a new primitives to the list of distortion prims * @param PrimitiveSceneProxies - primitive info to add. */ void Append(FPrimitiveSceneProxy** PrimitiveSceneProxies, int32 NumProxies) { Prims.Append(PrimitiveSceneProxies, NumProxies); } /** * @return number of prims to render */ int32 NumPrims() const { return Prims.Num(); } /** * @return a prim currently set to render */ const FPrimitiveSceneProxy* GetPrim(int32 i)const { check(i>=0 && i Prims; }; extern void SetupDistortionParams(FVector4f& DistortionParams, const FViewInfo& View); class FDistortionMeshProcessor : public FSceneRenderingAllocatorObject, public FMeshPassProcessor { public: FDistortionMeshProcessor( const FScene* Scene, ERHIFeatureLevel::Type FeatureLevel, const FSceneView* InViewIfDynamicMeshCommand, const FMeshPassProcessorRenderState& InPassDrawRenderState, const FMeshPassProcessorRenderState& InDistortionPassStateNoDepthTest, FMeshPassDrawListContext* InDrawListContext); virtual void AddMeshBatch(const FMeshBatch& RESTRICT MeshBatch, uint64 BatchElementMask, const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy, int32 StaticMeshId = -1) override final; virtual void CollectPSOInitializers(const FSceneTexturesConfig& SceneTexturesConfig, const FMaterial& Material, const FPSOPrecacheVertexFactoryData& VertexFactoryData, const FPSOPrecacheParams& PreCacheParams, TArray& PSOInitializers) override final; FMeshPassProcessorRenderState PassDrawRenderState; FMeshPassProcessorRenderState PassDrawRenderStateNoDepthTest; private: bool TryAddMeshBatch( const FMeshBatch& RESTRICT MeshBatch, uint64 BatchElementMask, const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy, int32 StaticMeshId, const FMaterialRenderProxy& MaterialRenderProxy, const FMaterial& Material); bool Process( const FMeshBatch& MeshBatch, uint64 BatchElementMask, const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy, int32 StaticMeshId, const FMaterialRenderProxy& RESTRICT MaterialRenderProxy, const FMaterial& RESTRICT MaterialResource, ERasterizerFillMode MeshFillMode, ERasterizerCullMode MeshCullMode); };