16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 12:29:18 +02:00

opacity bugfix

This commit is contained in:
milek7
2018-07-17 17:45:06 +02:00
parent a29379ed8b
commit 61bbfe667b
10 changed files with 101 additions and 58 deletions

View File

@@ -117,6 +117,23 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c
return true; // return value marks a key: value pair was extracted, nothing about whether it's recognized
}
float opengl_material::get_or_guess_opacity()
{
if (!std::isnan(opacity))
return opacity;
if (textures[0] != null_handle)
{
opengl_texture &tex = GfxRenderer.Texture(textures[0]);
if (tex.has_alpha)
return 0.0f;
else
return 0.5f;
}
return 0.0f;
}
std::unordered_map<gl::shader::components_e, GLint> material_manager::components_mapping =
{
{ gl::shader::components_e::R, GL_RED },
@@ -183,13 +200,6 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
GfxRenderer.Texture(handle).set_components_hint(components_mapping[entry.components]);
}
if (std::isnan(material.opacity))
{
material.opacity = 1.0f;
if (material.textures[0] != null_handle)
material.opacity = GfxRenderer.Texture( material.textures[0] ).has_alpha ? 0.0f : 1.0f;
}
material_handle handle = m_materials.size();
m_materials.emplace_back( material );
m_materialmappings.emplace( material.name, handle );