Plasma Engine  2.0
Loading...
Searching...
No Matches
ReflectionPoolData.h
1#pragma once
2
3#include <Core/World/World.h>
4#include <Foundation/Math/Color16f.h>
5#include <Foundation/Types/Bitflags.h>
6#include <RendererCore/Lights/Implementation/ReflectionPool.h>
7#include <RendererCore/Lights/Implementation/ReflectionProbeData.h>
8#include <RendererCore/Lights/Implementation/ReflectionProbeMapping.h>
9#include <RendererCore/Lights/Implementation/ReflectionProbeUpdater.h>
10#include <RendererCore/Pipeline/View.h>
11
15
16static constexpr plUInt32 s_uiReflectionCubeMapSize = 128;
17static constexpr plUInt32 s_uiNumReflectionProbeCubeMaps = 32;
18static constexpr float s_fDebugSphereRadius = 0.3f;
19
20inline plUInt32 GetMipLevels()
21{
22 return plMath::Log2i(s_uiReflectionCubeMapSize) - 1; // only down to 4x4
23}
24
27
29{
30 Data();
31 ~Data();
32
33 struct ProbeData
34 {
36 plTransform m_GlobalTransform;
38 plTextureCubeResourceHandle m_hCubeMap; // static data or empty for dynamic.
39 };
40
42 {
44 : m_mapping(s_uiNumReflectionProbeCubeMaps)
45 {
46 }
47 PL_DISALLOW_COPY_AND_ASSIGN(WorldReflectionData);
48
50 plReflectionProbeId m_SkyLight; // SkyLight is always fixed at reflectionIndex 0.
51 plEventSubscriptionID m_mappingSubscriptionId = 0;
53 };
54
55 // WorldReflectionData management
56 plReflectionProbeId AddProbe(const plWorld* pWorld, ProbeData&& probeData);
57 plReflectionPool::Data::WorldReflectionData& GetWorldData(const plWorld* pWorld);
58 void RemoveProbe(const plWorld* pWorld, plReflectionProbeId id);
59 void UpdateProbeData(ProbeData& ref_probeData, const plReflectionProbeDesc& desc, const plReflectionProbeComponentBase* pComponent);
60 bool UpdateSkyLightData(ProbeData& ref_probeData, const plReflectionProbeDesc& desc, const plSkyLightComponent* pComponent);
61 void OnReflectionProbeMappingEvent(const plUInt32 uiWorldIndex, const plReflectionProbeMappingEvent& e);
62
63 void PreExtraction();
64 void PostExtraction();
65
66 // Dynamic Update Queue (all worlds combined)
67 plHashSet<plReflectionProbeRef> m_PendingDynamicUpdate;
68 plDeque<plReflectionProbeRef> m_DynamicUpdateQueue;
69
70 plHashSet<plReflectionProbeRef> m_ActiveDynamicUpdate;
71 plReflectionProbeUpdater m_ReflectionProbeUpdater;
72
74 void CreateSkyIrradianceTexture();
75
76 plMutex m_Mutex;
77 plUInt64 m_uiWorldHasSkyLight = 0;
78 plUInt64 m_uiSkyIrradianceChanged = 0;
79 plHybridArray<plUniquePtr<WorldReflectionData>, 2> m_WorldReflectionData;
80
81 // GPU storage
82 plGALTextureHandle m_hFallbackReflectionSpecularTexture;
83 plGALTextureHandle m_hSkyIrradianceTexture;
84 plHybridArray<plAmbientCube<plColorLinear16f>, 64> m_SkyIrradianceStorage;
85
86 // Debug data
87 plMeshResourceHandle m_hDebugSphere;
89};
Box reflection probe component.
Definition BoxReflectionProbeComponent.h:15
Definition Deque.h:270
Definition RendererFoundationDLL.h:411
Definition HashSet.h:191
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition IdTable.h:171
Provides a simple mechanism for mutual exclusion to prevent multiple threads from accessing a shared ...
Definition Mutex.h:13
Base class for all reflection probes.
Definition ReflectionProbeComponentBase.h:13
This class creates a reflection probe atlas and controls the mapping of added probes to the available...
Definition ReflectionProbeMapping.h:25
Renders reflection probes and stores filtered mipmap chains into an atlas texture as well as computin...
Definition ReflectionProbeUpdater.h:15
Definition SkyLightComponent.h:15
Sphere reflection probe component.
Definition SphereReflectionProbeComponent.h:18
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
PL_ALWAYS_INLINE plUInt32 Log2i(plUInt32 uiVal)
Returns the integral logarithm to the base 2, that comes closest to the given integer.
Definition MathInt32_inl.h:41
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
Definition ReflectionPoolData.h:34
Definition ReflectionPoolData.h:42
plReflectionPool::Data
Definition ReflectionPoolData.h:29
void PreExtraction()
Dynamic Update.
Definition ReflectionPoolData.cpp:213
void CreateReflectionViewsAndResources()
Resource Creation.
Definition ReflectionPoolData.cpp:296
Describes how a cube map should be generated.
Definition ReflectionProbeData.h:24
Event generated on mapping changes.
Definition ReflectionProbeMapping.h:11