diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 8375fc748..ed0663658 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -191,14 +191,10 @@ void IrrDriver::renderGLSL(float dt) // Fire up the MRT m_video_driver->setRenderTarget(m_mrt, false, false); + PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00); m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID; irr_driver->setPhase(0); - glEnable(GL_DEPTH_TEST); - glDisable(GL_ALPHA_TEST); - glDepthMask(GL_TRUE); - glDisable(GL_BLEND); - glDepthFunc(GL_LEQUAL); m_scene_manager->drawAll(m_renderpass); irr_driver->setProjMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION)); irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW)); @@ -229,10 +225,6 @@ void IrrDriver::renderGLSL(float dt) PROFILER_POP_CPU_MARKER(); PROFILER_PUSH_CPU_MARKER("- Solid Pass 2", 0x00, 0x00, 0xFF); - glEnable(GL_DEPTH_TEST); - glDisable(GL_ALPHA_TEST); - glDepthMask(GL_FALSE); - glDisable(GL_BLEND); irr_driver->setPhase(1); m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID; m_scene_manager->drawAll(m_renderpass); @@ -297,11 +289,10 @@ void IrrDriver::renderGLSL(float dt) } PROFILER_POP_CPU_MARKER(); + // We need to re-render camera due to the per-cam-node hack. PROFILER_PUSH_CPU_MARKER("- Transparent Pass", 0xFF, 0x00, 0x00); irr_driver->setPhase(3); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT; m_scene_manager->drawAll(m_renderpass); PROFILER_POP_CPU_MARKER(); diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp index ae059dfa7..5316df464 100644 --- a/src/graphics/stkanimatedmesh.cpp +++ b/src/graphics/stkanimatedmesh.cpp @@ -165,7 +165,7 @@ void STKAnimatedMesh::render() driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); else if (Mesh->getMeshType() == scene::EAMT_SKINNED) driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((scene::SSkinMeshBuffer*)mb)->Transformation); - if (isObjectPass(material.MaterialType) && !transparent) + if (isObjectPass(material.MaterialType)) { initvaostate(GLmeshes[i], material.MaterialType); if (irr_driver->getPhase() == 0) @@ -174,10 +174,18 @@ void STKAnimatedMesh::render() glBufferSubData(GL_ARRAY_BUFFER, 0, mb->getVertexCount() * GLmeshes[i].Stride, mb->getVertices()); } drawSolid(GLmeshes[i], material.MaterialType); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + video::SMaterial material; + material.MaterialType = irr_driver->getShader(ES_RAIN); + material.BlendOperation = video::EBO_NONE; + material.ZWriteEnable = true; + material.Lighting = false; + irr_driver->getVideoDriver()->setMaterial(material); + static_cast(irr_driver->getVideoDriver())->setRenderStates3DMode(); } else { - continue; driver->setMaterial(material); driver->drawMeshBuffer(mb); } diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index 3b7d6a0f0..7dd30ce01 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -602,9 +602,6 @@ void STKMesh::drawTransparent(const GLMesh &mesh, video::E_MATERIAL_TYPE type) drawTransparentObject(mesh); if (type == irr_driver->getShader(ES_BUBBLES)) drawBubble(mesh); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); return; } @@ -617,6 +614,11 @@ void STKMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type) windDir = getWind(); irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false); + glEnable(GL_DEPTH_TEST); + glDisable(GL_ALPHA_TEST); + glDepthMask(GL_TRUE); + glDisable(GL_BLEND); + computeMVP(ModelViewProjectionMatrix); computeTIMV(TransposeInverseModelView); @@ -634,7 +636,12 @@ void STKMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type) case 1: { irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false); - + + glEnable(GL_DEPTH_TEST); + glDisable(GL_ALPHA_TEST); + glDepthMask(GL_FALSE); + glDisable(GL_BLEND); + if (type == irr_driver->getShader(ES_SPHERE_MAP)) drawSphereMap(mesh, ModelViewProjectionMatrix, TransposeInverseModelView); else if (type == irr_driver->getShader(ES_SPLATTING)) @@ -808,9 +815,9 @@ void STKMesh::render() } if (!isObject(material.MaterialType)) { - continue; driver->setMaterial(material); driver->drawMeshBuffer(mb); + continue; } // only render transparent buffer if this is the transparent render pass @@ -827,6 +834,15 @@ void STKMesh::render() drawTransparent(GLmeshes[i], material.MaterialType); else drawSolid(GLmeshes[i], material.MaterialType); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + video::SMaterial material; + material.MaterialType = irr_driver->getShader(ES_RAIN); + material.BlendOperation = video::EBO_NONE; + material.ZWriteEnable = true; + material.Lighting = false; + irr_driver->getVideoDriver()->setMaterial(material); + static_cast(irr_driver->getVideoDriver())->setRenderStates3DMode(); } } }