Factorize Unlit material

This commit is contained in:
Vincent Lejeune 2014-07-11 00:39:20 +02:00
parent 555b2c433c
commit f723a764fc
5 changed files with 12 additions and 32 deletions

View File

@ -670,11 +670,8 @@ void IrrDriver::renderSolidSecondPass()
ListDefaultTangentSM::Arguments.clear();
ListAlphaRefSM::Arguments.clear();
ListSphereMapSM::Arguments.clear();
GroupedSM<SM_DEFAULT_TANGENT>::reset();
GroupedSM<SM_ALPHA_REF_TEXTURE>::reset();
GroupedSM<SM_SPHEREMAP>::reset();
ListUnlitSM::Arguments.clear();
GroupedSM<SM_SPLATTING>::reset();
GroupedSM<SM_UNLIT>::reset();
GroupedSM<SM_DETAILS>::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<MeshShader::ObjectPass2Shader, video::EVT_TANGENTS>(ListDefaultTangentSM::Arguments);
renderMeshes2ndPass<MeshShader::ObjectRefPass2Shader, video::EVT_STANDARD>(ListAlphaRefSM::Arguments);
renderMeshes2ndPass<MeshShader::SphereMapShader, video::EVT_STANDARD>(ListSphereMapSM::Arguments);
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD>(ListUnlitSM::Arguments);
glUseProgram(MeshShader::SplattingShader::Program);
glBindVertexArray(getVAO(EVT_2TCOORDS));
for (unsigned i = 0; i < GroupedSM<SM_SPLATTING>::MeshSet.size(); i++)
drawSplatting(*GroupedSM<SM_SPLATTING>::MeshSet[i], GroupedSM<SM_SPLATTING>::MVPSet[i]);
glUseProgram(MeshShader::ObjectUnlitShader::Program);
glBindVertexArray(getVAO(EVT_STANDARD));
for (unsigned i = 0; i < GroupedSM<SM_UNLIT>::MeshSet.size(); i++)
{
GLMesh &mesh = *GroupedSM<SM_UNLIT>::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<MeshShader::ObjectUnlitShader>(&mesh, GroupedSM<SM_UNLIT>::MVPSet[i]);
}
glUseProgram(MeshShader::DetailledObjectPass2Shader::Program);
glBindVertexArray(getVAO(EVT_2TCOORDS));
for (unsigned i = 0; i < GroupedSM<SM_DETAILS>::MeshSet.size(); i++)

View File

@ -185,9 +185,7 @@ void STKAnimatedMesh::render()
for_in (mesh, ShadedMesh[SM_UNLIT])
{
GroupedSM<SM_UNLIT>::MeshSet.push_back(mesh);
GroupedSM<SM_UNLIT>::MVPSet.push_back(AbsoluteTransformation);
GroupedSM<SM_UNLIT>::TIMVSet.push_back(invmodel);
ListUnlitSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation));
}
for_in(mesh, ShadedMesh[SM_DETAILS])

View File

@ -522,4 +522,5 @@ void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat)
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListDefaultStandardSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListDefaultTangentSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListAlphaRefSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > ListSphereMapSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > ListSphereMapSM::Arguments;
std::vector<std::tuple<GLMesh *, core::matrix4> > ListUnlitSM::Arguments;

View File

@ -133,6 +133,12 @@ public:
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > Arguments;
};
class ListUnlitSM
{
public:
static std::vector<std::tuple<GLMesh *, core::matrix4> > Arguments;
};
template<enum ShadedMaterial T>
class GroupedSM
{

View File

@ -370,9 +370,7 @@ void STKMeshSceneNode::render()
for_in(mesh, ShadedMesh[SM_UNLIT])
{
GroupedSM<SM_UNLIT>::MeshSet.push_back(mesh);
GroupedSM<SM_UNLIT>::MVPSet.push_back(AbsoluteTransformation);
GroupedSM<SM_UNLIT>::TIMVSet.push_back(invmodel);
ListUnlitSM::Arguments.push_back(std::make_tuple(mesh, AbsoluteTransformation));
}
for_in(mesh, ShadedMesh[SM_DETAILS])