Disable backface culling when set in the material.

This commit is contained in:
Benau 2016-11-23 15:16:19 +08:00
parent eb84de2666
commit a2bb0487b1
3 changed files with 17 additions and 10 deletions

View File

@ -298,10 +298,13 @@ public:
#endif
TexExpander<typename T::InstancedFirstPassShader>::template
expandTex(*mesh, T::FirstPassTextures);
if (!mesh->mb->getMaterial().BackfaceCulling)
glDisable(GL_CULL_FACE);
glDrawElementsIndirect(GL_TRIANGLES,
GL_UNSIGNED_SHORT,
(const void*)((m_offset[T::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
if (!mesh->mb->getMaterial().BackfaceCulling)
glEnable(GL_CULL_FACE);
}
} //drawIndirectFirstPass
@ -366,11 +369,13 @@ public:
(mesh->m_render_info->getHue(),
mesh->m_material->getColorizationFactor());
}
if (!mesh->mb->getMaterial().BackfaceCulling)
glDisable(GL_CULL_FACE);
glDrawElementsIndirect(GL_TRIANGLES,
GL_UNSIGNED_SHORT,
(const void*)((m_offset[T::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
if (!mesh->mb->getMaterial().BackfaceCulling)
glEnable(GL_CULL_FACE);
if (need_change_hue)
{
// Reset after changing

View File

@ -77,15 +77,17 @@ struct CustomUnrollArgs<>
{
S::getInstance()->changeableColor(mesh->m_render_info->getHue(),
mesh->m_material->getColorizationFactor());
}
}
if (!mesh->mb->getMaterial().BackfaceCulling)
glDisable(GL_CULL_FACE);
S::getInstance()->setUniforms(args...);
glDrawElementsBaseVertex(mesh->PrimitiveType,
(int)mesh->IndexCount,
mesh->IndexType,
(GLvoid *)mesh->vaoOffset,
(int)mesh->vaoBaseVertex);
if (!mesh->mb->getMaterial().BackfaceCulling)
glEnable(GL_CULL_FACE);
if (need_change_hue)
{
// Reset after changing

View File

@ -716,6 +716,10 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
m_texname.c_str());
}
// Backface culling
if(!m_backface_culling)
m->setFlag(video::EMF_BACK_FACE_CULLING, false);
if (CVS->isGLSL())
{
ITexture *tex;
@ -992,10 +996,6 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
}
}
// Backface culling
if(!m_backface_culling)
m->setFlag(video::EMF_BACK_FACE_CULLING, false);
// Material color
m->ColorMaterial = video::ECM_DIFFUSE_AND_AMBIENT;