Graphics: Implement point-light shadow-mapping
This commit is contained in:
committed by
Jérôme Leclercq
parent
6731e07b54
commit
f8238a6e6c
@@ -123,6 +123,7 @@ namespace Nz
|
||||
bool HasAttachment(const std::vector<FramePass::Input>& inputs, std::size_t attachmentIndex) const;
|
||||
void RemoveDuplicatePasses();
|
||||
std::size_t ResolveAttachmentIndex(std::size_t attachmentIndex) const;
|
||||
void RegisterPassInput(std::size_t passIndex, std::size_t attachmentIndex);
|
||||
std::size_t RegisterTexture(std::size_t attachmentIndex);
|
||||
void ReorderPasses();
|
||||
void TraverseGraph(std::size_t passIndex);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/FramePassAttachment.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
@@ -73,6 +74,7 @@ namespace Nz
|
||||
inline void SetDepthStencilInput(std::size_t attachmentId);
|
||||
inline void SetDepthStencilOutput(std::size_t attachmentId);
|
||||
inline void SetExecutionCallback(ExecutionCallback callback);
|
||||
inline void SetInputLayout(std::size_t inputIndex, TextureLayout layout);
|
||||
inline void SetReadInput(std::size_t inputIndex, bool doesRead);
|
||||
|
||||
FramePass& operator=(const FramePass&) = delete;
|
||||
@@ -89,6 +91,7 @@ namespace Nz
|
||||
struct Input
|
||||
{
|
||||
std::size_t attachmentId;
|
||||
std::optional<TextureLayout> assumedLayout;
|
||||
bool doesRead = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -128,6 +128,12 @@ namespace Nz
|
||||
m_executionCallback = std::move(callback);
|
||||
}
|
||||
|
||||
inline void FramePass::SetInputLayout(std::size_t inputIndex, TextureLayout layout)
|
||||
{
|
||||
assert(inputIndex < m_inputs.size());
|
||||
m_inputs[inputIndex].assumedLayout = layout;
|
||||
}
|
||||
|
||||
inline void FramePass::SetReadInput(std::size_t inputIndex, bool doesRead)
|
||||
{
|
||||
assert(inputIndex < m_inputs.size());
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace Nz
|
||||
m_position = position;
|
||||
|
||||
UpdateBoundingVolume();
|
||||
OnLightTransformInvalided(this);
|
||||
}
|
||||
|
||||
inline void PointLight::UpdateRadius(float radius)
|
||||
|
||||
64
include/Nazara/Graphics/PointLightShadowData.hpp
Normal file
64
include/Nazara/Graphics/PointLightShadowData.hpp
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_GRAPHICS_POINTLIGHTSHADOWDATA_HPP
|
||||
#define NAZARA_GRAPHICS_POINTLIGHTSHADOWDATA_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/DepthPipelinePass.hpp>
|
||||
#include <Nazara/Graphics/Light.hpp>
|
||||
#include <Nazara/Graphics/LightShadowData.hpp>
|
||||
#include <Nazara/Graphics/ShadowViewer.hpp>
|
||||
#include <array>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class FramePipeline;
|
||||
class PointLight;
|
||||
|
||||
class NAZARA_GRAPHICS_API PointLightShadowData : public LightShadowData
|
||||
{
|
||||
public:
|
||||
PointLightShadowData(FramePipeline& pipeline, ElementRendererRegistry& elementRegistry, const PointLight& light);
|
||||
PointLightShadowData(const PointLightShadowData&) = delete;
|
||||
PointLightShadowData(PointLightShadowData&&) = delete;
|
||||
~PointLightShadowData() = default;
|
||||
|
||||
void PrepareRendering(RenderFrame& renderFrame) override;
|
||||
|
||||
void RegisterMaterialInstance(const MaterialInstance& matInstance) override;
|
||||
void RegisterPassInputs(FramePass& pass) override;
|
||||
void RegisterToFrameGraph(FrameGraph& frameGraph) override;
|
||||
|
||||
const Texture* RetrieveLightShadowmap(const BakedFrameGraph& bakedGraph) const override;
|
||||
|
||||
void UnregisterMaterialInstance(const MaterialInstance& matInstance) override;
|
||||
|
||||
PointLightShadowData& operator=(const PointLightShadowData&) = delete;
|
||||
PointLightShadowData& operator=(PointLightShadowData&&) = delete;
|
||||
|
||||
private:
|
||||
NazaraSlot(Light, OnLightShadowMapSettingChange, m_onLightShadowMapSettingChange);
|
||||
NazaraSlot(Light, OnLightTransformInvalided, m_onLightTransformInvalidated);
|
||||
|
||||
struct DirectionData
|
||||
{
|
||||
std::optional<DepthPipelinePass> depthPass;
|
||||
std::size_t attachmentIndex;
|
||||
ShadowViewer viewer;
|
||||
};
|
||||
|
||||
std::array<DirectionData, 6> m_directions;
|
||||
std::size_t m_cubeAttachmentIndex;
|
||||
FramePipeline& m_pipeline;
|
||||
const PointLight& m_light;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/PointLightShadowData.inl>
|
||||
|
||||
#endif // NAZARA_GRAPHICS_POINTLIGHTSHADOWDATA_HPP
|
||||
12
include/Nazara/Graphics/PointLightShadowData.inl
Normal file
12
include/Nazara/Graphics/PointLightShadowData.inl
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/PointLightShadowData.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
@@ -16,7 +16,7 @@ namespace Nz
|
||||
class NAZARA_GRAPHICS_API ShadowViewer : public AbstractViewer
|
||||
{
|
||||
public:
|
||||
inline ShadowViewer(const Recti& viewport, UInt32 renderMask);
|
||||
ShadowViewer() = default;
|
||||
ShadowViewer(const ShadowViewer&) = delete;
|
||||
ShadowViewer(ShadowViewer&&) = delete;
|
||||
~ShadowViewer() = default;
|
||||
|
||||
@@ -7,12 +7,6 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline ShadowViewer::ShadowViewer(const Recti& viewport, UInt32 renderMask) :
|
||||
m_renderMask(renderMask)
|
||||
{
|
||||
UpdateViewport(viewport);
|
||||
}
|
||||
|
||||
inline void ShadowViewer::UpdateRenderMask(UInt32 renderMask)
|
||||
{
|
||||
m_renderMask = renderMask;
|
||||
|
||||
Reference in New Issue
Block a user