Some cleaning.

This commit is contained in:
vlj 2014-04-08 01:52:19 +02:00
parent c5fd99a096
commit 246d581e4c
6 changed files with 21 additions and 41 deletions

View File

@ -772,17 +772,3 @@ void PostProcessing::render()
glDisable(GL_FRAMEBUFFER_SRGB);
}
} // render
void PostProcessing::drawQuad(u32 cam, const SMaterial &mat)
{
const u16 indices[6] = {0, 1, 2, 3, 0, 2};
IVideoDriver * const drv = irr_driver->getVideoDriver();
drv->setTransform(ETS_WORLD, core::IdentityMatrix);
drv->setTransform(ETS_VIEW, core::IdentityMatrix);
drv->setTransform(ETS_PROJECTION, core::IdentityMatrix);
drv->setMaterial(mat);
drv->drawIndexedTriangleList(&(m_vertices[cam].v0),
4, indices, 2);
}

View File

@ -94,9 +94,6 @@ public:
/** Render the post-processed scene */
void render();
/** Draw the quad for this camera */
void drawQuad(u32 cam, const video::SMaterial &mat);
/** Use motion blur for a short time */
void giveBoost(unsigned int cam_index);

View File

@ -167,6 +167,12 @@ void IrrDriver::renderGLSL(float dt)
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, true);
}*/
// Get Projection and view matrix
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
m_scene_manager->drawAll(scene::ESNRP_CAMERA);
irr_driver->setProjMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION));
irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW));
// Fire up the MRT
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
renderSolidFirstPass();
@ -431,24 +437,25 @@ void IrrDriver::renderSolidFirstPass()
void IrrDriver::renderSolidSecondPass()
{
glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getFBO(FBO_COLORS));
SColor clearColor = World::getWorld()->getClearColor();
glClearColor(clearColor.getRed() / 255., clearColor.getGreen() / 255., clearColor.getBlue() / 255., clearColor.getAlpha() / 255.);
glClear(GL_COLOR_BUFFER_BIT);
glDepthMask(GL_FALSE);
irr_driver->setPhase(SOLID_LIT_PASS);
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
setTexture(0, m_rtts->getRenderTarget(RTT_TMP1), GL_NEAREST, GL_NEAREST);
setTexture(1, m_rtts->getRenderTarget(RTT_TMP2), GL_NEAREST, GL_NEAREST);
setTexture(2, m_rtts->getRenderTarget(RTT_SSAO), GL_NEAREST, GL_NEAREST);
m_scene_manager->drawAll(m_renderpass);
m_scene_manager->drawAll(scene::ESNRP_SOLID);
}
void IrrDriver::renderTransparent()
{
glBindFramebuffer(GL_FRAMEBUFFER, m_rtts->getFBO(FBO_COLORS));
irr_driver->setPhase(TRANSPARENT_PASS);
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT;
glEnable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
@ -456,17 +463,16 @@ void IrrDriver::renderTransparent()
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_CULL_FACE);
m_scene_manager->drawAll(m_renderpass);
m_scene_manager->drawAll(scene::ESNRP_TRANSPARENT);
}
void IrrDriver::renderParticles()
{
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT;
glDepthMask(GL_FALSE);
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
m_scene_manager->drawAll(m_renderpass);
m_scene_manager->drawAll(scene::ESNRP_TRANSPARENT_EFFECT);
}
void IrrDriver::renderShadows(//ShadowImportanceProvider * const sicb,

View File

@ -186,11 +186,8 @@ static void drawFSPMDefault(GLMesh &mesh, const core::matrix4 &ModelViewProjecti
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
core::matrix4 InverseViewMatrix;
irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW).getInverse(InverseViewMatrix);
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::InstancedObjectPass1Shader::setUniforms(ModelViewProjectionMatrix, InverseViewMatrix, 0);
MeshShader::InstancedObjectPass1Shader::setUniforms(ModelViewProjectionMatrix, irr_driver->getInvViewMatrix(), 0);
glBindVertexArray(mesh.vao_first_pass);
glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
@ -218,11 +215,8 @@ static void drawFSPMAlphaRefTexture(GLMesh &mesh, const core::matrix4 &ModelView
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
core::matrix4 InverseViewMatrix;
irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW).getInverse(InverseViewMatrix);
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::InstancedObjectRefPass1Shader::setUniforms(ModelViewProjectionMatrix, InverseViewMatrix, 0);
MeshShader::InstancedObjectRefPass1Shader::setUniforms(ModelViewProjectionMatrix, irr_driver->getInvViewMatrix(), 0);
glBindVertexArray(mesh.vao_first_pass);
glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
@ -252,11 +246,8 @@ static void drawFSPMGrass(GLMesh &mesh, const core::matrix4 &ModelViewProjection
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
core::matrix4 InverseViewMatrix;
irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW).getInverse(InverseViewMatrix);
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::InstancedGrassPass1Shader::setUniforms(ModelViewProjectionMatrix, InverseViewMatrix, windDir, 0);
MeshShader::InstancedGrassPass1Shader::setUniforms(ModelViewProjectionMatrix, irr_driver->getInvViewMatrix(), windDir, 0);
glBindVertexArray(mesh.vao_first_pass);
glDrawElementsInstanced(ptype, count, itype, 0, instance_count);
@ -321,8 +312,8 @@ void STKInstancedSceneNode::render()
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS)
{
ModelViewProjectionMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION);
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
ModelViewProjectionMatrix = irr_driver->getProjMatrix();
ModelViewProjectionMatrix *= irr_driver->getViewMatrix();
if (!GeometricMesh[FPSM_DEFAULT].empty())
glUseProgram(MeshShader::InstancedObjectPass1Shader::Program);

View File

@ -195,14 +195,14 @@ GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
void computeMVP(core::matrix4 &ModelViewProjectionMatrix)
{
ModelViewProjectionMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION);
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
ModelViewProjectionMatrix = irr_driver->getProjMatrix();
ModelViewProjectionMatrix *= irr_driver->getViewMatrix();
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
}
void computeTIMV(core::matrix4 &TransposeInverseModelView)
{
TransposeInverseModelView = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
TransposeInverseModelView = irr_driver->getViewMatrix();
TransposeInverseModelView *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
TransposeInverseModelView.makeInverse();
TransposeInverseModelView = TransposeInverseModelView.getTransposed();

View File

@ -142,7 +142,7 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
size_t count = mesh.IndexCount;
computeMVP(ModelViewProjectionMatrix);
core::matrix4 ModelViewMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
core::matrix4 ModelViewMatrix = irr_driver->getViewMatrix();
ModelViewMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
// Generate displace mask