Skip to content

Commit

Permalink
#149 Fix bug clear shadow depth
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed May 28, 2022
1 parent c82f318 commit 54ad961
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,59 +72,51 @@ namespace Skylicht
{
IVideoDriver* driver = getVideoDriver();

// Irrlicht Engine Mesh Buffer instance
// http://irrlicht.sourceforge.net/docu/classirr_1_1scene_1_1_c_mesh_buffer.html
IMeshBuffer* meshBuffer = new CMeshBuffer<S3DVertex>(driver->getVertexDescriptor(EVT_STANDARD), EIT_16BIT);
IIndexBuffer* ib = meshBuffer->getIndexBuffer();
IVertexBuffer* vb = meshBuffer->getVertexBuffer();

// Create vertices
video::SColor clr1(255, 255, 0, 0);
video::SColor clr2(255, 0, 255, 0);
video::SColor clr3(255, 0, 0, 255);
video::SColor clr4(255, 255, 255, 255);
video::SColor clr5(255, 255, 0, 255);
video::SColor clr6(255, 255, 255, 0);

video::SColor clr(255, 255, 255, 255);

vb->reallocate(12);

video::S3DVertex Vertices[] = {
// back
video::S3DVertex(0, 0, 0, 0, 0, -1, clr1, 0, 1),
video::S3DVertex(1, 0, 0, 0, 0, -1, clr1, 1, 1),
video::S3DVertex(1, 1, 0, 0, 0, -1, clr1, 1, 0),
video::S3DVertex(0, 1, 0, 0, 0, -1, clr1, 1, 0),
video::S3DVertex(0, 0, 0, 0, 0, -1, clr, 0, 1),
video::S3DVertex(1, 0, 0, 0, 0, -1, clr, 1, 1),
video::S3DVertex(1, 1, 0, 0, 0, -1, clr, 1, 0),
video::S3DVertex(0, 1, 0, 0, 0, -1, clr, 1, 0),

// front
video::S3DVertex(0, 0, 1, 0, 0, 1, clr2, 0, 1),
video::S3DVertex(1, 0, 1, 0, 0, 1, clr2, 1, 1),
video::S3DVertex(1, 1, 1, 0, 0, 1, clr2, 1, 0),
video::S3DVertex(0, 1, 1, 0, 0, 1, clr2, 1, 0),
video::S3DVertex(0, 0, 1, 0, 0, 1, clr, 0, 1),
video::S3DVertex(1, 0, 1, 0, 0, 1, clr, 1, 1),
video::S3DVertex(1, 1, 1, 0, 0, 1, clr, 1, 0),
video::S3DVertex(0, 1, 1, 0, 0, 1, clr, 1, 0),

// bottom
video::S3DVertex(0, 0, 0, 0, -1, 0, clr3, 0, 1),
video::S3DVertex(0, 0, 1, 0, -1, 0, clr3, 1, 1),
video::S3DVertex(1, 0, 1, 0, -1, 0, clr3, 1, 0),
video::S3DVertex(1, 0, 0, 0, -1, 0, clr3, 1, 0),
video::S3DVertex(0, 0, 0, 0, -1, 0, clr, 0, 1),
video::S3DVertex(0, 0, 1, 0, -1, 0, clr, 1, 1),
video::S3DVertex(1, 0, 1, 0, -1, 0, clr, 1, 0),
video::S3DVertex(1, 0, 0, 0, -1, 0, clr, 1, 0),

// top
video::S3DVertex(0, 1, 0, 0, 1, 0, clr4, 0, 1),
video::S3DVertex(0, 1, 1, 0, 1, 0, clr4, 1, 1),
video::S3DVertex(1, 1, 1, 0, 1, 0, clr4, 1, 0),
video::S3DVertex(1, 1, 0, 0, 1, 0, clr4, 1, 0),
video::S3DVertex(0, 1, 0, 0, 1, 0, clr, 0, 1),
video::S3DVertex(0, 1, 1, 0, 1, 0, clr, 1, 1),
video::S3DVertex(1, 1, 1, 0, 1, 0, clr, 1, 0),
video::S3DVertex(1, 1, 0, 0, 1, 0, clr, 1, 0),

// left
video::S3DVertex(1, 0, 0, -1, 0, 0, clr5, 0, 1),
video::S3DVertex(1, 0, 1, -1, 0, 0, clr5, 1, 1),
video::S3DVertex(1, 1, 1, -1, 0, 0, clr5, 1, 0),
video::S3DVertex(1, 1, 0, -1, 0, 0, clr5, 1, 0),
video::S3DVertex(1, 0, 0, -1, 0, 0, clr, 0, 1),
video::S3DVertex(1, 0, 1, -1, 0, 0, clr, 1, 1),
video::S3DVertex(1, 1, 1, -1, 0, 0, clr, 1, 0),
video::S3DVertex(1, 1, 0, -1, 0, 0, clr, 1, 0),

// right
video::S3DVertex(0, 0, 0, 1, 0, 0, clr5, 0, 1),
video::S3DVertex(0, 0, 1, 1, 0, 0, clr5, 1, 1),
video::S3DVertex(0, 1, 1, 1, 0, 0, clr5, 1, 0),
video::S3DVertex(0, 1, 0, 1, 0, 0, clr5, 1, 0),
video::S3DVertex(0, 0, 0, 1, 0, 0, clr, 0, 1),
video::S3DVertex(0, 0, 1, 1, 0, 0, clr, 1, 1),
video::S3DVertex(0, 1, 1, 1, 0, 0, clr, 1, 0),
video::S3DVertex(0, 1, 0, 1, 0, 0, clr, 1, 0),
};

for (u32 i = 0; i < 24; ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ namespace Skylicht
IVideoDriver* driver = getVideoDriver();
for (int i = 0; i < m_numCascade; i++)
{
driver->setRenderTargetArray(m_depthTexture, i, true, true);
// note: clear while 0xFFFFFFFF for max depth value
driver->setRenderTargetArray(m_depthTexture, i, true, true, SColor(255, 255, 255, 255));
driver->setTransform(video::ETS_PROJECTION, m_csm->getProjectionMatrices(i));
driver->setTransform(video::ETS_VIEW, m_csm->getViewMatrices(i));

Expand Down

0 comments on commit 54ad961

Please sign in to comment.