mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-03-14 13:20:59 +00:00
NOISSUE fix various skin rendering issues
This commit is contained in:
parent
c7bf4fee76
commit
538c943f10
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user