Plasma Engine  2.0
Loading...
Searching...
No Matches
LSAOPass.h
1#pragma once
2
3#include <RendererCore/../../../Data/Base/Shaders/Pipeline/LSAOConstants.h>
4#include <RendererCore/Declarations.h>
5#include <RendererCore/Pipeline/RenderPipelinePass.h>
6#include <RendererCore/Shader/ConstantBufferStorage.h>
7#include <RendererCore/Shader/ShaderResource.h>
8#include <RendererFoundation/RendererFoundationDLL.h>
9
11struct PL_RENDERERCORE_DLL plLSAODepthCompareFunction
12{
13 using StorageType = plUInt8;
14
15 enum Enum
16 {
17 Depth,
19 Normal,
21 NormalAndSampleDistance,
23 Default = NormalAndSampleDistance
24 };
25};
26
27PL_DECLARE_REFLECTABLE_TYPE(PL_RENDERERCORE_DLL, plLSAODepthCompareFunction);
28
38class PL_RENDERERCORE_DLL plLSAOPass : public plRenderPipelinePass
39{
40 PL_ADD_DYNAMIC_REFLECTION(plLSAOPass, plRenderPipelinePass);
41
42public:
43 plLSAOPass();
45
46 virtual bool GetRenderTargetDescriptions(const plView& view, const plArrayPtr<plGALTextureCreationDescription* const> inputs, plArrayPtr<plGALTextureCreationDescription> outputs) override;
47 virtual void InitRenderPipelinePass(const plArrayPtr<plRenderPipelinePassConnection* const> inputs, const plArrayPtr<plRenderPipelinePassConnection* const> outputs) override;
48
49 virtual void Execute(const plRenderViewContext& renderViewContext, const plArrayPtr<plRenderPipelinePassConnection* const> inputs, const plArrayPtr<plRenderPipelinePassConnection* const> outputs) override;
50 virtual void ExecuteInactive(const plRenderViewContext& renderViewContext, const plArrayPtr<plRenderPipelinePassConnection* const> inputs, const plArrayPtr<plRenderPipelinePassConnection* const> outputs) override;
51 virtual plResult Serialize(plStreamWriter& inout_stream) const override;
52 virtual plResult Deserialize(plStreamReader& inout_stream) override;
53
54 plUInt32 GetLineToLinePixelOffset() const { return m_iLineToLinePixelOffset; }
55 void SetLineToLinePixelOffset(plUInt32 uiPixelOffset);
56 plUInt32 GetLineSamplePixelOffset() const { return m_iLineSamplePixelOffsetFactor; }
57 void SetLineSamplePixelOffset(plUInt32 uiPixelOffset);
58
59 // Factor used for depth cutoffs (determines when a depth difference is too large to be considered)
60 float GetDepthCutoffDistance() const;
61 void SetDepthCutoffDistance(float fDepthCutoffDistance);
62
63 // Determines how quickly the occlusion falls of.
64 float GetOcclusionFalloff() const;
65 void SetOcclusionFalloff(float fFalloff);
66
67
68protected:
70 void DestroyLineSweepData();
71 void SetupLineSweepData(const plVec3I32& imageResolution);
72
73
74 void AddLinesForDirection(const plVec3I32& imageResolution, const plVec2I32& sampleDir, plUInt32 lineIndex, plDynamicArray<LineInstruction>& outinLineInstructions, plUInt32& outinTotalNumberOfSamples);
75
76 plRenderPipelineNodeInputPin m_PinDepthInput;
78
79 plConstantBufferStorageHandle m_hLineSweepCB;
80
81 bool m_bSweepDataDirty = true;
82 bool m_bConstantsDirty = true;
83
86 plGALBufferUnorderedAccessViewHandle m_hLineSweepOutputUAV;
87 plGALBufferResourceViewHandle m_hLineSweepOutputSRV;
88
91 plGALBufferResourceViewHandle m_hLineSweepInfoSRV;
92
94 plUInt32 m_uiNumSweepLines = 0;
95
96 plInt32 m_iLineToLinePixelOffset = 2;
97 plInt32 m_iLineSamplePixelOffsetFactor = 1;
98 float m_fOcclusionFalloff = 0.2f;
99 float m_fDepthCutoffDistance = 4.0f;
100
101 plEnum<plLSAODepthCompareFunction> m_DepthCompareFunction;
102 bool m_bDistributedGathering = true;
103
104 plShaderResourceHandle m_hShaderLineSweep;
105 plShaderResourceHandle m_hShaderGather;
106 plShaderResourceHandle m_hShaderAverage;
107};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition ConstantBufferStorage.h:54
Definition DynamicArray.h:81
Definition RendererFoundationDLL.h:418
Definition RendererFoundationDLL.h:432
Definition RendererFoundationDLL.h:446
Definition LSAOPass.h:39
plGALBufferHandle m_hLineSweepOutputBuffer
Output of the line sweep pass.
Definition LSAOPass.h:85
plGALBufferHandle m_hLineInfoBuffer
Structured buffer containing instructions for every single line to trace.
Definition LSAOPass.h:90
Definition RenderPipelinePass.h:26
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
Encapsulates a view on the given world through the given camera and rendered with the specified Rende...
Definition View.h:21
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Defines the depth compare function to be used to decide sample weights.
Definition LSAOPass.h:12
Enum
Definition LSAOPass.h:16
Definition RenderPipelineNode.h:44
Definition RenderPipelineNode.h:51
Definition Declarations.h:51
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54