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

@@ -8,10 +8,13 @@
namespace Nz
{
inline Light::Light(UInt8 lightType) :
m_boundingVolume(BoundingVolumef::Null()),
m_lightType(lightType)
inline void Light::EnableShadowCasting(bool castShadows)
{
if (m_isShadowCaster != castShadows)
{
m_isShadowCaster = castShadows;
OnLightShadowCastingChanged(this, castShadows);
}
}
inline const BoundingVolumef& Light::GetBoundingVolume() const
@@ -24,6 +27,58 @@ namespace Nz
return m_lightType;
}
inline PixelFormat Light::GetShadowMapFormat() const
{
return m_shadowMapFormat;
}
inline UInt32 Light::GetShadowMapSize() const
{
return m_shadowMapSize;
}
inline bool Light::IsShadowCaster() const
{
return m_isShadowCaster;
}
inline void Light::UpdateShadowMapFormat(PixelFormat format)
{
if (m_shadowMapFormat != format)
{
PixelFormatContent content = PixelFormatInfo::GetContent(format);
NazaraAssert(content != PixelFormatContent::Depth && content != PixelFormatContent::DepthStencil, "invalid shadow map format (has no depth)");
OnLightShadowMapSettingChange(this, format, m_shadowMapSize);
m_shadowMapFormat = format;
}
}
inline void Light::UpdateShadowMapSettings(UInt32 size, PixelFormat format)
{
if (m_shadowMapFormat != format || m_shadowMapSize != size)
{
NazaraAssert(size > 0, "invalid shadow map size");
PixelFormatContent content = PixelFormatInfo::GetContent(format);
NazaraAssert(content != PixelFormatContent::Depth && content != PixelFormatContent::DepthStencil, "invalid shadow map format (has no depth)");
OnLightShadowMapSettingChange(this, format, size);
m_shadowMapFormat = format;
m_shadowMapSize = size;
}
}
inline void Light::UpdateShadowMapSize(UInt32 size)
{
if (m_shadowMapSize != size)
{
NazaraAssert(size > 0, "invalid shadow map size");
OnLightShadowMapSettingChange(this, m_shadowMapFormat, size);
m_shadowMapSize = size;
}
}
inline void Light::UpdateBoundingVolume(const BoundingVolumef& boundingVolume)
{
m_boundingVolume = boundingVolume;