From 7d602225fbcff7350ff44664eb1642ffcf0702f7 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Wed, 22 Oct 2014 22:05:09 +0200 Subject: [PATCH] Use InitTexture for transparents too --- src/graphics/render_geometry.cpp | 18 +----------------- src/graphics/stkanimatedmesh.cpp | 2 ++ src/graphics/stkmesh.cpp | 17 +++++++++++++++++ src/graphics/stkmesh.hpp | 1 + src/graphics/stkmeshscenenode.cpp | 2 ++ 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index 803b24428..eb366b07d 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -723,25 +723,9 @@ void renderTransparenPass(const std::vector &TexUnits, std::vectorgetVAO(VertexType)); for (unsigned i = 0; i < meshes->size(); i++) { - std::vector Handles; GLMesh &mesh = *(STK::tuple_get<0>(meshes->at(i))); if (!irr_driver->hasARB_base_instance()) glBindVertexArray(mesh.vao); - for (unsigned j = 0; j < TexUnits.size(); j++) - { - if (!mesh.textures[TexUnits[j].m_id]) - mesh.textures[TexUnits[j].m_id] = getUnicolorTexture(video::SColor(255, 255, 255, 255)); - compressTexture(mesh.textures[TexUnits[j].m_id], TexUnits[j].m_premul_alpha); - if (UserConfigParams::m_azdo) - { - if (!mesh.TextureHandles[TexUnits[j].m_id]) - mesh.TextureHandles[TexUnits[j].m_id] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[TexUnits[j].m_id]), Shader::getInstance()->SamplersId[Handles.size()]); - if (!glIsTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id])) - glMakeTextureHandleResidentARB(mesh.TextureHandles[TexUnits[j].m_id]); - Handles.push_back(mesh.TextureHandles[TexUnits[j].m_id]); - } - } - if (mesh.VAOType != VertexType) { #ifdef DEBUG @@ -751,7 +735,7 @@ void renderTransparenPass(const std::vector &TexUnits, std::vectorSetTextureHandles(Handles[0]); + Shader::getInstance()->SetTextureHandles(mesh.TextureHandles[0]); else Shader::getInstance()->SetTextureUnits(getTextureGLuint(mesh.textures[0])); custom_unroll_args::template exec(Shader::getInstance(), meshes->at(i)); diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp index 7f168c2db..d12d71dbd 100644 --- a/src/graphics/stkanimatedmesh.cpp +++ b/src/graphics/stkanimatedmesh.cpp @@ -149,6 +149,8 @@ void STKAnimatedMesh::updateGL() Material::ShaderType MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material, material2); InitTextures(mesh, MatType); } + else + InitTexturesTransparent(mesh); if (irr_driver->hasARB_base_instance()) { diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index 6dd3c3114..380bddf92 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -349,4 +349,21 @@ void InitTextures(GLMesh &mesh, Material::ShaderType Mat) SetTexture(mesh, 6, false, getShaderTypeName(Mat)); break; } +} + +void InitTexturesTransparent(GLMesh &mesh) +{ + if (!mesh.textures[0]) + { + Log::fatal("STKMesh", "Missing texture for material transparent"); + return; + } + compressTexture(mesh.textures[0], true); + if (UserConfigParams::m_azdo) + { + if (!mesh.TextureHandles[0]) + mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[0]), MeshShader::ObjectPass1Shader::getInstance()->SamplersId[0]); + if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0])) + glMakeTextureHandleResidentARB(mesh.TextureHandles[0]); + } } \ No newline at end of file diff --git a/src/graphics/stkmesh.hpp b/src/graphics/stkmesh.hpp index df533c031..8e9c3ea7b 100644 --- a/src/graphics/stkmesh.hpp +++ b/src/graphics/stkmesh.hpp @@ -179,5 +179,6 @@ Material::ShaderType MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialT TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE, f32 MaterialTypeParam, Material* material); void InitTextures(GLMesh &mesh, Material::ShaderType); +void InitTexturesTransparent(GLMesh &mesh); #endif // STKMESH_H diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index 470adc051..6f9818300 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -189,6 +189,8 @@ void STKMeshSceneNode::updateGL() if (!immediate_draw) InitTextures(mesh, MatType); } + else if (!immediate_draw) + InitTexturesTransparent(mesh); if (!immediate_draw && irr_driver->hasARB_base_instance()) {