Plasma Engine  2.0
Loading...
Searching...
No Matches
ReflectionProbeUpdater.h
1#pragma once
2
3#include <RendererCore/RendererCorePCH.h>
4
5#include <Core/Graphics/Camera.h>
6#include <RendererCore/Lights/Implementation/ReflectionProbeData.h>
7#include <RendererCore/Pipeline/Declarations.h>
8#include <RendererFoundation/RendererFoundationDLL.h>
9
10PL_DECLARE_FLAGS(plUInt8, plReflectionProbeUpdaterFlags, SkyLight, HasCustomCubeMap);
11
15{
16public:
25
26public:
29
33 plUInt32 GetFreeUpdateSlots(plDynamicArray<plReflectionProbeRef>& out_updatesFinished);
34
41 plResult StartDynamicUpdate(const plReflectionProbeRef& probe, const plReflectionProbeDesc& desc, const plTransform& globalTransform, const TargetSlot& target);
42
50
52 void CancelUpdate(const plReflectionProbeRef& probe);
53
56
59
60private:
61 struct ReflectionView
62 {
63 plViewHandle m_hView;
64 plCamera m_Camera;
65 };
66
67 struct UpdateStep
68 {
69 using StorageType = plUInt8;
70
71 enum Enum
72 {
73 RenderFace0,
74 RenderFace1,
75 RenderFace2,
76 RenderFace3,
77 RenderFace4,
78 RenderFace5,
79 Filter,
80
81 ENUM_COUNT,
82
83 Default = Filter
84 };
85
86 static bool IsRenderStep(Enum value) { return value >= UpdateStep::RenderFace0 && value <= UpdateStep::RenderFace5; }
87 static Enum NextStep(Enum value) { return static_cast<UpdateStep::Enum>((value + 1) % UpdateStep::ENUM_COUNT); }
88 };
89
90 struct ProbeUpdateInfo
91 {
92 ProbeUpdateInfo();
93 ~ProbeUpdateInfo();
94
98 plTransform m_globalTransform;
99 plTextureCubeResourceHandle m_sourceTexture;
100 TargetSlot m_TargetSlot;
101
102 struct Step
103 {
104 PL_DECLARE_POD_TYPE();
105
106 plUInt8 m_uiViewIndex;
107 plEnum<UpdateStep> m_UpdateStep;
108 };
109
110 bool m_bInUse = false;
111 plEnum<UpdateStep> m_LastUpdateStep;
112
113 plHybridArray<Step, 8> m_UpdateSteps;
114
115 plGALTextureHandle m_hCubemap;
116 plGALTextureHandle m_hCubemapProxies[6];
117 };
118
119private:
120 static void CreateViews(
121 plDynamicArray<ReflectionView>& views, plUInt32 uiMaxRenderViews, const char* szNameSuffix, const char* szRenderPipelineResource);
122 void CreateReflectionViewsAndResources();
123
124 void ResetProbeUpdateInfo(plUInt32 uiInfo);
125 void AddViewToRender(const ProbeUpdateInfo::Step& step, ProbeUpdateInfo& updateInfo);
126
127 bool m_bUpdateStepsFlushed = true;
128
129 plDynamicArray<ReflectionView> m_RenderViews;
130 plDynamicArray<ReflectionView> m_FilterViews;
131
132 // Active Dynamic Updates
134 plHybridArray<plReflectionProbeRef, 4> m_FinishedLastFrame;
135};
A camera class that stores the orientation and some basic camera settings.
Definition Camera.h:41
Definition DynamicArray.h:81
Definition RendererFoundationDLL.h:411
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Renders reflection probes and stores filtered mipmap chains into an atlas texture as well as computin...
Definition ReflectionProbeUpdater.h:15
void GenerateUpdateSteps()
Generates update steps. Should be called in PreExtraction phase.
Definition ReflectionProbeUpdater.cpp:162
plUInt32 GetFreeUpdateSlots(plDynamicArray< plReflectionProbeRef > &out_updatesFinished)
Returns how many new probes can be started this frame.
Definition ReflectionProbeUpdater.cpp:88
plResult StartDynamicUpdate(const plReflectionProbeRef &probe, const plReflectionProbeDesc &desc, const plTransform &globalTransform, const TargetSlot &target)
Starts rendering a new reflection probe.
Definition ReflectionProbeUpdater.cpp:101
void CancelUpdate(const plReflectionProbeRef &probe)
Cancel a previously started update.
Definition ReflectionProbeUpdater.cpp:149
plReflectionProbeUpdater()
plReflectionProbeUpdater
plResult StartFilterUpdate(const plReflectionProbeRef &probe, const plReflectionProbeDesc &desc, plTextureCubeResourceHandle hSourceTexture, const TargetSlot &target)
Starts filtering an existing cube map into a new reflection probe.
Definition ReflectionProbeUpdater.cpp:124
void ScheduleUpdateSteps()
Schedules probe rendering views. Should be called at some point during the extraction phase....
Definition ReflectionProbeUpdater.cpp:225
Definition Declarations.h:64
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Describes how a cube map should be generated.
Definition ReflectionProbeData.h:24
A unique reference to a reflection probe.
Definition ReflectionProbeData.h:76
Definition ReflectionProbeUpdater.h:103
Defines the target specular reflection probe atlas and index as well as the sky irradiance atlas and ...
Definition ReflectionProbeUpdater.h:19
plInt32 m_iIrradianceOutputIndex
If -1, no irradiance is computed.
Definition ReflectionProbeUpdater.h:23
plGALTextureHandle m_hSpecularOutputTexture
Must be a valid cube map texture array handle.
Definition ReflectionProbeUpdater.h:20
plInt32 m_iSpecularOutputIndex
Must be a valid index into the atlas texture.
Definition ReflectionProbeUpdater.h:22
plGALTextureHandle m_hIrradianceOutputTexture
Optional. Must be set if m_iIrradianceOutputIndex != -1.
Definition ReflectionProbeUpdater.h:21
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54