1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-02-24 15:32:30 +01:00

fix pre-multiply alpha for atlas borders (sprites only)

This commit is contained in:
XProger 2019-02-19 00:35:13 +03:00
parent 48e2bcf9e7
commit c8cfff82a4
3 changed files with 24 additions and 17 deletions

View File

@ -1195,11 +1195,11 @@ struct Level : IGame {
// oxygen bar
{ 0xFF647464, 0xFFA47848, 0xFF647464, 0xFF4C504C, 0xFF303030 },
// option bar
{ 0x00FFFFFF, 0x20FFFFFF, 0x20FFFFFF, 0x20FFFFFF, 0x00FFFFFF,
0x00FFFFFF, 0x60FFFFFF, 0x60FFFFFF, 0x60FFFFFF, 0x00FFFFFF,
0x00FFFFFF, 0x80FFFFFF, 0x80FFFFFF, 0x80FFFFFF, 0x00FFFFFF,
0x00FFFFFF, 0x60FFFFFF, 0x60FFFFFF, 0x60FFFFFF, 0x00FFFFFF,
0x00FFFFFF, 0x20FFFFFF, 0x20FFFFFF, 0x20FFFFFF, 0x00FFFFFF },
{ 0x00000000, 0x20202020, 0x20202020, 0x20202020, 0x00000000,
0x00000000, 0x60606060, 0x60606060, 0x60606060, 0x00000000,
0x00000000, 0x80808080, 0x80808080, 0x80808080, 0x00000000,
0x00000000, 0x60606060, 0x60606060, 0x60606060, 0x00000000,
0x00000000, 0x20202020, 0x20202020, 0x20202020, 0x00000000 },
// white bar (white tile)
{ 0xFFFFFFFF },
};
@ -1213,25 +1213,30 @@ struct Level : IGame {
Color32 *src, *dst = (Color32*)data;
short4 mm;
bool isSprite = false;
if (id < level->objectTexturesCount) { // textures
TR::TextureInfo &t = level->objectTextures[id];
mm = t.getMinMax();
src = owner->tileData->color;
uv = t.texCoordAtlas;
uvCount = 4;
if (data)
if (data) {
level->fillObjectTexture(owner->tileData, tile.uv, tile.tex);
}
} else {
id -= level->objectTexturesCount;
if (id < level->spriteTexturesCount) { // sprites
TR::TextureInfo &t = level->spriteTextures[id];
mm = t.getMinMax();
src = owner->tileData->color;
uv = t.texCoordAtlas;
uvCount = 2;
if (data)
mm = t.getMinMax();
src = owner->tileData->color;
uv = t.texCoordAtlas;
uvCount = 2;
isSprite = true;
if (data) {
level->fillObjectTexture(owner->tileData, tile.uv, tile.tex);
}
} else { // common (generated) textures
id -= level->spriteTexturesCount;
@ -1281,7 +1286,12 @@ struct Level : IGame {
ASSERT((y + ATLAS_BORDER + tileY) >= 0 && (y + ATLAS_BORDER + tileY) < atlasHeight);
p += clamp(x, 0, w - 1);
p += clamp(y, 0, h - 1) * stride;
dst[x + ATLAS_BORDER] = *p;
if (isSprite && (y < 0 || y >= h || x < 0 || x >= w)) {
dst[x + ATLAS_BORDER] = Color32(0, 0, 0, 0);
} else {
dst[x + ATLAS_BORDER] = *p;
}
}
dst += atlasWidth;
}

View File

@ -151,7 +151,7 @@ varying vec4 vTexCoord; // xy - atlas coords, zw - trapezoidal correction
#ifdef TYPE_FLASH
vDiffuse.xyz += uMaterial.w;
#else
vDiffuse.w = uMaterial.w;
vDiffuse *= uMaterial.w;
#endif
#ifdef TYPE_SPRITE
@ -465,8 +465,6 @@ varying vec4 vTexCoord; // xy - atlas coords, zw - trapezoidal correction
fragColor = color;
#ifdef TYPE_FLASH
fragColor.w = 0.0;
#else
fragColor.xyz *= fragColor.w;
#endif
}

View File

@ -20,7 +20,6 @@ varying vec4 vColor;
void main() {
fragColor = texture2D(sDiffuse, vTexCoord) * vColor;
fragColor.rgb *= fragColor.a;
}
#endif
)===="