Add shadow mapping (wip)

This commit is contained in:
SirLynix
2022-11-07 02:16:02 +01:00
committed by Jérôme Leclercq
parent be9fba3190
commit 4a10c1f8fe
23 changed files with 333 additions and 44 deletions

View File

@@ -12,6 +12,7 @@
#include <Nazara/Math/BoundingVolume.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utility/PixelFormat.hpp>
#include <Nazara/Utils/Signal.hpp>
#include <memory>
@@ -20,21 +21,32 @@ namespace Nz
class CommandBufferBuilder;
class RenderBuffer;
class RenderFrame;
class Texture;
class NAZARA_GRAPHICS_API Light
{
public:
inline Light(UInt8 lightType);
Light(UInt8 lightType);
Light(const Light&) = delete;
Light(Light&&) noexcept = default;
virtual ~Light();
virtual float ComputeContributionScore(const BoundingVolumef& boundingVolume) const = 0;
inline void EnableShadowCasting(bool castShadows);
virtual void FillLightData(void* data) const = 0;
inline const BoundingVolumef& GetBoundingVolume() const;
inline UInt8 GetLightType() const;
inline PixelFormat GetShadowMapFormat() const;
inline UInt32 GetShadowMapSize() const;
inline bool IsShadowCaster() const;
inline void UpdateShadowMapFormat(PixelFormat format);
inline void UpdateShadowMapSettings(UInt32 size, PixelFormat format);
inline void UpdateShadowMapSize(UInt32 size);
virtual void UpdateTransform(const Vector3f& position, const Quaternionf& rotation, const Vector3f& scale) = 0;
@@ -42,13 +54,18 @@ namespace Nz
Light& operator=(Light&&) noexcept = default;
NazaraSignal(OnLightDataInvalided, Light* /*emitter*/);
NazaraSignal(OnLightShadowCastingChanged, Light* /*light*/, bool /*isShadowCasting*/);
NazaraSignal(OnLightShadowMapSettingChange, Light* /*light*/, PixelFormat /*newPixelFormat*/, UInt32 /*newSize*/);
protected:
inline void UpdateBoundingVolume(const BoundingVolumef& boundingVolume);
private:
BoundingVolumef m_boundingVolume;
PixelFormat m_shadowMapFormat;
UInt8 m_lightType;
UInt32 m_shadowMapSize;
bool m_isShadowCaster;
};
}