Skip to content

Commit

Permalink
Use BaseVertex for details too.
Browse files Browse the repository at this point in the history
Also forget to use basevertex for animated mesh first pass.
  • Loading branch information
Vincent Lejeune committed Jun 30, 2014
1 parent 87a9410 commit 075aa7f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/graphics/render.cpp
Expand Up @@ -650,6 +650,7 @@ void IrrDriver::renderSolidSecondPass()
drawObjectUnlit(*GroupedSM<SM_UNLIT>::MeshSet[i], GroupedSM<SM_UNLIT>::MVPSet[i]);

glUseProgram(MeshShader::DetailledObjectPass2Shader::Program);
glBindVertexArray(getVAO(EVT_2TCOORDS));
for (unsigned i = 0; i < GroupedSM<SM_DETAILS>::MeshSet.size(); i++)
drawDetailledObjectPass2(*GroupedSM<SM_DETAILS>::MeshSet[i], GroupedSM<SM_DETAILS>::MVPSet[i]);

Expand Down
15 changes: 14 additions & 1 deletion src/graphics/stkanimatedmesh.cpp
Expand Up @@ -104,9 +104,22 @@ void STKAnimatedMesh::render()
GeometricMesh[GeometricType].push_back(&mesh);
ShadedMesh[ShadedType].push_back(&mesh);
glBindVertexArray(0);
switch (GeometricType)
{
case FPSM_NORMAL_MAP: {
std::pair<unsigned, unsigned> p = getVAOOffsetAndBase(mb);
mesh.vaoBaseVertex = p.first;
mesh.vaoOffset = p.second;
mesh.VAOType = mb->getVertexType();
break;
}
default:
break;
}
switch (ShadedType)
{
case SM_ALPHA_REF_TEXTURE: {
case SM_ALPHA_REF_TEXTURE:
case SM_DETAILS: {
std::pair<unsigned, unsigned> p = getVAOOffsetAndBase(mb);
mesh.vaoBaseVertex = p.first;
mesh.vaoOffset = p.second;
Expand Down
41 changes: 19 additions & 22 deletions src/graphics/stkmesh.cpp
Expand Up @@ -481,30 +481,27 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
{
irr_driver->IncreaseObjectCount();
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
GLenum ptype = mesh.PrimitiveType;
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;

compressTexture(mesh.textures[0], true);
setTexture(MeshShader::DetailledObjectPass2Shader::TU_Albedo, 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);
}
compressTexture(mesh.textures[1], true);
setTexture(MeshShader::DetailledObjectPass2Shader::TU_detail, getTextureGLuint(mesh.textures[1]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);

MeshShader::DetailledObjectPass2Shader::setUniforms(ModelViewProjectionMatrix);
compressTexture(mesh.textures[0], true);
setTexture(MeshShader::DetailledObjectPass2Shader::TU_Albedo, 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);
}
compressTexture(mesh.textures[1], true);
setTexture(MeshShader::DetailledObjectPass2Shader::TU_detail, getTextureGLuint(mesh.textures[1]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);

assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);
MeshShader::DetailledObjectPass2Shader::setUniforms(ModelViewProjectionMatrix);
glDrawElementsBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, mesh.vaoBaseVertex);
}

void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
Expand Down
3 changes: 2 additions & 1 deletion src/graphics/stkmeshscenenode.cpp
Expand Up @@ -87,7 +87,8 @@ void STKMeshSceneNode::setFirstTimeMaterial()
{
case SM_SPLATTING:
case SM_SPHEREMAP:
case SM_ALPHA_REF_TEXTURE: {
case SM_ALPHA_REF_TEXTURE:
case SM_DETAILS: {
std::pair<unsigned, unsigned> p = getVAOOffsetAndBase(mb);
mesh.vaoBaseVertex = p.first;
mesh.vaoOffset = p.second;
Expand Down

0 comments on commit 075aa7f

Please sign in to comment.