2021-05-06 17:02:10 +02:00
|
|
|
#pragma once
|
|
|
|
|
#include "RenderPass.h"
|
2021-05-10 23:57:55 +02:00
|
|
|
#include "Graphics/GraphicsResources.h"
|
2021-10-01 19:55:04 +02:00
|
|
|
#include "Scene/Scene.h"
|
2021-05-06 17:02:10 +02:00
|
|
|
|
|
|
|
|
namespace Seele
|
|
|
|
|
{
|
|
|
|
|
DECLARE_REF(CameraActor)
|
2021-05-10 23:57:55 +02:00
|
|
|
DECLARE_REF(Scene)
|
|
|
|
|
DECLARE_REF(Viewport)
|
2021-10-01 19:55:04 +02:00
|
|
|
struct LightCullingPassData
|
|
|
|
|
{
|
2021-10-05 12:24:41 +02:00
|
|
|
LightEnv lightEnv;
|
2021-10-01 19:55:04 +02:00
|
|
|
};
|
|
|
|
|
class LightCullingPass : public RenderPass<LightCullingPassData>
|
2021-05-06 17:02:10 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2022-11-17 16:47:42 +01:00
|
|
|
LightCullingPass(Gfx::PGraphics graphics);
|
2021-05-06 17:02:10 +02:00
|
|
|
virtual ~LightCullingPass();
|
2022-11-17 16:47:42 +01:00
|
|
|
virtual void beginFrame(const Component::Camera& cam) override;
|
2022-04-15 23:45:44 +02:00
|
|
|
virtual void render() override;
|
|
|
|
|
virtual void endFrame() override;
|
2021-05-06 17:02:10 +02:00
|
|
|
virtual void publishOutputs() override;
|
|
|
|
|
virtual void createRenderPass() override;
|
|
|
|
|
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
|
|
|
|
|
private:
|
2021-05-10 23:57:55 +02:00
|
|
|
void setupFrustums();
|
2022-02-24 22:38:26 +01:00
|
|
|
static constexpr uint32 BLOCK_SIZE = 32;
|
2021-05-10 23:57:55 +02:00
|
|
|
static constexpr uint32 INDEX_LIGHT_ENV = 1;
|
2021-10-13 15:20:30 +02:00
|
|
|
struct DispatchParams
|
2021-05-06 17:02:10 +02:00
|
|
|
{
|
|
|
|
|
glm::uvec3 numThreadGroups;
|
|
|
|
|
uint32_t pad0;
|
|
|
|
|
glm::uvec3 numThreads;
|
|
|
|
|
uint32_t pad1;
|
|
|
|
|
} dispatchParams;
|
2021-10-13 15:20:30 +02:00
|
|
|
struct Plane
|
2021-05-06 17:02:10 +02:00
|
|
|
{
|
2023-01-21 18:43:21 +01:00
|
|
|
Vector n;
|
2021-05-06 17:02:10 +02:00
|
|
|
float d;
|
|
|
|
|
};
|
2021-10-13 15:20:30 +02:00
|
|
|
struct Frustum
|
2021-05-06 17:02:10 +02:00
|
|
|
{
|
|
|
|
|
Plane planes[4];
|
|
|
|
|
};
|
2021-09-29 22:12:56 +02:00
|
|
|
|
2021-05-10 23:57:55 +02:00
|
|
|
Gfx::PStructuredBuffer frustumBuffer;
|
|
|
|
|
Gfx::PUniformBuffer dispatchParamsBuffer;
|
|
|
|
|
Gfx::PUniformBuffer viewParamsBuffer;
|
|
|
|
|
Gfx::PDescriptorSet frustumDescriptorSet;
|
|
|
|
|
Gfx::PComputeShader frustumShader;
|
|
|
|
|
Gfx::PPipelineLayout frustumLayout;
|
|
|
|
|
Gfx::PComputePipeline frustumPipeline;
|
|
|
|
|
|
|
|
|
|
Gfx::PTexture2D depthAttachment;
|
|
|
|
|
Gfx::PStructuredBuffer frustums;
|
|
|
|
|
Gfx::PStructuredBuffer oLightIndexCounter;
|
|
|
|
|
Gfx::PStructuredBuffer tLightIndexCounter;
|
|
|
|
|
Gfx::PStructuredBuffer oLightIndexList;
|
|
|
|
|
Gfx::PStructuredBuffer tLightIndexList;
|
|
|
|
|
Gfx::PTexture2D oLightGrid;
|
|
|
|
|
Gfx::PTexture2D tLightGrid;
|
|
|
|
|
Gfx::PDescriptorSet lightEnvDescriptorSet;
|
|
|
|
|
Gfx::PDescriptorSet cullingDescriptorSet;
|
|
|
|
|
Gfx::PDescriptorLayout lightEnvDescriptorLayout;
|
|
|
|
|
Gfx::PDescriptorLayout cullingDescriptorLayout;
|
|
|
|
|
Gfx::PComputeShader cullingShader;
|
|
|
|
|
Gfx::PPipelineLayout cullingLayout;
|
|
|
|
|
Gfx::PComputePipeline cullingPipeline;
|
2021-05-06 17:02:10 +02:00
|
|
|
};
|
2021-05-10 23:57:55 +02:00
|
|
|
DEFINE_REF(LightCullingPass)
|
2021-05-06 17:02:10 +02:00
|
|
|
} // namespace Seele
|