From f723a764fc846b9c874292e7d465efe57c80d567 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Fri, 11 Jul 2014 00:39:20 +0200 Subject: [PATCH] Factorize Unlit material --- src/graphics/render.cpp | 27 ++------------------------- src/graphics/stkanimatedmesh.cpp | 4 +--- src/graphics/stkmesh.cpp | 3 ++- src/graphics/stkmesh.hpp | 6 ++++++ src/graphics/stkmeshscenenode.cpp | 4 +--- 5 files changed, 12 insertions(+), 32 deletions(-) diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 9bb4943ba..e5e6c51af 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -670,11 +670,8 @@ void IrrDriver::renderSolidSecondPass() ListDefaultTangentSM::Arguments.clear(); ListAlphaRefSM::Arguments.clear(); ListSphereMapSM::Arguments.clear(); - GroupedSM::reset(); - GroupedSM::reset(); - GroupedSM::reset(); + ListUnlitSM::Arguments.clear(); GroupedSM::reset(); - GroupedSM::reset(); GroupedSM::reset(); setTexture(0, m_rtts->getRenderTarget(RTT_TMP1), GL_NEAREST, GL_NEAREST); setTexture(1, m_rtts->getRenderTarget(RTT_TMP2), GL_NEAREST, GL_NEAREST); @@ -689,33 +686,13 @@ void IrrDriver::renderSolidSecondPass() renderMeshes2ndPass(ListDefaultTangentSM::Arguments); renderMeshes2ndPass(ListAlphaRefSM::Arguments); renderMeshes2ndPass(ListSphereMapSM::Arguments); + renderMeshes2ndPass(ListUnlitSM::Arguments); glUseProgram(MeshShader::SplattingShader::Program); glBindVertexArray(getVAO(EVT_2TCOORDS)); for (unsigned i = 0; i < GroupedSM::MeshSet.size(); i++) drawSplatting(*GroupedSM::MeshSet[i], GroupedSM::MVPSet[i]); - glUseProgram(MeshShader::ObjectUnlitShader::Program); - glBindVertexArray(getVAO(EVT_STANDARD)); - for (unsigned i = 0; i < GroupedSM::MeshSet.size(); i++) - { - GLMesh &mesh = *GroupedSM::MeshSet[i]; - assert(mesh.VAOType == EVT_STANDARD); - compressTexture(mesh.textures[0], true); - setTexture(MeshShader::ObjectUnlitShader::TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); - if (irr_driver->getLightViz()) - { - GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } - else - { - GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } - draw(&mesh, GroupedSM::MVPSet[i]); - } - glUseProgram(MeshShader::DetailledObjectPass2Shader::Program); glBindVertexArray(getVAO(EVT_2TCOORDS)); for (unsigned i = 0; i < GroupedSM::MeshSet.size(); i++) diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp index bc9f248cc..fc36a6db5 100644 --- a/src/graphics/stkanimatedmesh.cpp +++ b/src/graphics/stkanimatedmesh.cpp @@ -185,9 +185,7 @@ void STKAnimatedMesh::render() for_in (mesh, ShadedMesh[SM_UNLIT]) { - GroupedSM::MeshSet.push_back(mesh); - GroupedSM::MVPSet.push_back(AbsoluteTransformation); - GroupedSM::TIMVSet.push_back(invmodel); + ListUnlitSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation)); } for_in(mesh, ShadedMesh[SM_DETAILS]) diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index bc6b2f709..20aded9d4 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -522,4 +522,5 @@ void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat) std::vector > ListDefaultStandardSM::Arguments; std::vector > ListDefaultTangentSM::Arguments; std::vector > ListAlphaRefSM::Arguments; -std::vector > ListSphereMapSM::Arguments; \ No newline at end of file +std::vector > ListSphereMapSM::Arguments; +std::vector > ListUnlitSM::Arguments; \ No newline at end of file diff --git a/src/graphics/stkmesh.hpp b/src/graphics/stkmesh.hpp index 86bc0f9cc..6304c7659 100644 --- a/src/graphics/stkmesh.hpp +++ b/src/graphics/stkmesh.hpp @@ -133,6 +133,12 @@ public: static std::vector > Arguments; }; +class ListUnlitSM +{ +public: + static std::vector > Arguments; +}; + template class GroupedSM { diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index 1d9d9a6b3..6df8b25cb 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -370,9 +370,7 @@ void STKMeshSceneNode::render() for_in(mesh, ShadedMesh[SM_UNLIT]) { - GroupedSM::MeshSet.push_back(mesh); - GroupedSM::MVPSet.push_back(AbsoluteTransformation); - GroupedSM::TIMVSet.push_back(invmodel); + ListUnlitSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation)); } for_in(mesh, ShadedMesh[SM_DETAILS])