diff --git a/launcher/skins/SkinRenderer.cpp b/launcher/skins/SkinRenderer.cpp index aa8a6f52..c49b9dd1 100644 --- a/launcher/skins/SkinRenderer.cpp +++ b/launcher/skins/SkinRenderer.cpp @@ -424,14 +424,12 @@ void Skins::RenderContext::setTextures(const QImage& skin, const QImage& cape) m_skinTexture = new QOpenGLTexture(skin); m_skinTexture->setMinificationFilter(QOpenGLTexture::NearestMipMapNearest); m_skinTexture->setMagnificationFilter(QOpenGLTexture::Nearest); - m_skinShader->setUniformValue(m_uniforms[1].id, 0); if(!cape.isNull()) { m_capeTexture = new QOpenGLTexture(cape); m_capeTexture->setMinificationFilter(QOpenGLTexture::NearestMipMapNearest); m_capeTexture->setMagnificationFilter(QOpenGLTexture::Nearest); - m_skinShader->setUniformValue(m_uniforms[2].id, 1); } m_skinShader->release(); } @@ -480,6 +478,8 @@ void Skins::RenderContext::render(QMatrix4x4 viewMatrix, QVector3D baseColor, QV GL.glEnable(GL_DEPTH_TEST); m_skinShader->bind(); m_skinShader->setUniformValue(m_uniforms[0].id, viewMatrix); + m_skinShader->setUniformValue(m_uniforms[1].id, 0); + m_skinShader->setUniformValue(m_uniforms[2].id, 1); m_skinTexture->bind(0); if(m_capeTexture) { diff --git a/launcher/skins/SkinTypes.cpp b/launcher/skins/SkinTypes.cpp index 1ee07de9..0abe83f1 100644 --- a/launcher/skins/SkinTypes.cpp +++ b/launcher/skins/SkinTypes.cpp @@ -138,11 +138,19 @@ const QImage & SkinData::getListTexture(Model model) const auto paintFront = [&](int x, int y, const Skins::TextureMapping& part) { auto partTexture = texture.copy(part.front.x, part.front.y, part.front.w, part.front.h); + if(!part.transparent) + { + painter.fillRect(x, y, part.front.w, part.front.w, Qt::black); + } painter.drawImage(x, y, partTexture.mirrored(part.front.flipX, part.front.flipY)); }; auto paintBack = [&](int x, int y, const Skins::TextureMapping& part) { auto partTexture = texture.copy(part.back.x, part.back.y, part.back.w, part.back.h); + if(!part.transparent) + { + painter.fillRect(x, y, part.back.w, part.back.w, Qt::black); + } painter.drawImage(x, y, partTexture.mirrored(part.back.flipX, part.back.flipY)); }; paintFront(4, 2, head); diff --git a/launcher/skins/SkinUtils.cpp b/launcher/skins/SkinUtils.cpp index 305d792a..429faa85 100644 --- a/launcher/skins/SkinUtils.cpp +++ b/launcher/skins/SkinUtils.cpp @@ -85,17 +85,14 @@ bool readSkinFromData(const QByteArray& data, QImage& imageOut, QString& texture return false; } - imageOut = img; - if(img.hasAlphaChannel()) + auto maskOut = img.pixel(0,0); + if(qAlpha(maskOut) == 0xff) { - textureIDOut = hashSkin(imageOut); - return true; + auto alphaChannel = img.createMaskFromColor(maskOut, Qt::MaskMode::MaskOutColor); + img.setAlphaChannel(alphaChannel); } - // No alpha channel -> take top left pixel and replace all matching pixels with transparency - auto alphaChannel = imageOut.createMaskFromColor(imageOut.pixel(0,0), Qt::MaskMode::MaskOutColor); - imageOut.setAlphaChannel(alphaChannel); - - textureIDOut = hashSkin(imageOut); + textureIDOut = hashSkin(img); + imageOut = img; return true; }