First shadow mapping commit
Former-commit-id: 7465a7c3297626f8db8c1ff48a20c0e0d9feb765
This commit is contained in:
@@ -17,7 +17,9 @@
|
||||
///TODO: Scale ?
|
||||
|
||||
NzLight::NzLight(nzLightType type) :
|
||||
m_type(type)
|
||||
m_type(type),
|
||||
m_shadowCastingEnabled(false),
|
||||
m_shadowMapUpdated(false)
|
||||
{
|
||||
SetAmbientFactor((type == nzLightType_Directional) ? 0.2f : 0.f);
|
||||
SetAttenuation(0.9f);
|
||||
@@ -177,3 +179,18 @@ void NzLight::MakeBoundingVolume() const
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NzLight::UpdateShadowMap() const
|
||||
{
|
||||
if (m_shadowCastingEnabled)
|
||||
{
|
||||
if (!m_shadowMap)
|
||||
m_shadowMap = NzTexture::New();
|
||||
|
||||
m_shadowMap->Create(nzImageType_2D, nzPixelFormat_Depth16, 256, 256);
|
||||
}
|
||||
else
|
||||
m_shadowMap.Reset();
|
||||
|
||||
m_shadowMapUpdated = true;
|
||||
}
|
||||
|
||||
@@ -148,6 +148,9 @@ bool NzRenderTexture::AttachBuffer(nzAttachmentPoint attachmentPoint, nzUInt8 in
|
||||
Unlock();
|
||||
|
||||
unsigned int attachIndex = attachmentIndex[attachmentPoint] + index;
|
||||
if (attachIndex >= m_impl->attachments.size())
|
||||
m_impl->attachments.resize(attachIndex+1);
|
||||
|
||||
Attachment& attachment = m_impl->attachments[attachIndex];
|
||||
attachment.attachmentPoint = attachmentPoint;
|
||||
attachment.buffer = buffer;
|
||||
@@ -286,6 +289,9 @@ bool NzRenderTexture::AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 i
|
||||
Unlock();
|
||||
|
||||
unsigned int attachIndex = attachmentIndex[attachmentPoint] + index;
|
||||
if (attachIndex >= m_impl->attachments.size())
|
||||
m_impl->attachments.resize(attachIndex+1);
|
||||
|
||||
Attachment& attachment = m_impl->attachments[attachIndex];
|
||||
attachment.attachmentPoint = attachmentPoint;
|
||||
attachment.isBuffer = false;
|
||||
|
||||
Reference in New Issue
Block a user