mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-12 08:04:09 +02:00
fix pre-multiply alpha for atlas borders (sprites only)
This commit is contained in:
24
src/level.h
24
src/level.h
@@ -1195,11 +1195,11 @@ struct Level : IGame {
|
|||||||
// oxygen bar
|
// oxygen bar
|
||||||
{ 0xFF647464, 0xFFA47848, 0xFF647464, 0xFF4C504C, 0xFF303030 },
|
{ 0xFF647464, 0xFFA47848, 0xFF647464, 0xFF4C504C, 0xFF303030 },
|
||||||
// option bar
|
// option bar
|
||||||
{ 0x00FFFFFF, 0x20FFFFFF, 0x20FFFFFF, 0x20FFFFFF, 0x00FFFFFF,
|
{ 0x00000000, 0x20202020, 0x20202020, 0x20202020, 0x00000000,
|
||||||
0x00FFFFFF, 0x60FFFFFF, 0x60FFFFFF, 0x60FFFFFF, 0x00FFFFFF,
|
0x00000000, 0x60606060, 0x60606060, 0x60606060, 0x00000000,
|
||||||
0x00FFFFFF, 0x80FFFFFF, 0x80FFFFFF, 0x80FFFFFF, 0x00FFFFFF,
|
0x00000000, 0x80808080, 0x80808080, 0x80808080, 0x00000000,
|
||||||
0x00FFFFFF, 0x60FFFFFF, 0x60FFFFFF, 0x60FFFFFF, 0x00FFFFFF,
|
0x00000000, 0x60606060, 0x60606060, 0x60606060, 0x00000000,
|
||||||
0x00FFFFFF, 0x20FFFFFF, 0x20FFFFFF, 0x20FFFFFF, 0x00FFFFFF },
|
0x00000000, 0x20202020, 0x20202020, 0x20202020, 0x00000000 },
|
||||||
// white bar (white tile)
|
// white bar (white tile)
|
||||||
{ 0xFFFFFFFF },
|
{ 0xFFFFFFFF },
|
||||||
};
|
};
|
||||||
@@ -1213,14 +1213,17 @@ struct Level : IGame {
|
|||||||
Color32 *src, *dst = (Color32*)data;
|
Color32 *src, *dst = (Color32*)data;
|
||||||
short4 mm;
|
short4 mm;
|
||||||
|
|
||||||
|
bool isSprite = false;
|
||||||
|
|
||||||
if (id < level->objectTexturesCount) { // textures
|
if (id < level->objectTexturesCount) { // textures
|
||||||
TR::TextureInfo &t = level->objectTextures[id];
|
TR::TextureInfo &t = level->objectTextures[id];
|
||||||
mm = t.getMinMax();
|
mm = t.getMinMax();
|
||||||
src = owner->tileData->color;
|
src = owner->tileData->color;
|
||||||
uv = t.texCoordAtlas;
|
uv = t.texCoordAtlas;
|
||||||
uvCount = 4;
|
uvCount = 4;
|
||||||
if (data)
|
if (data) {
|
||||||
level->fillObjectTexture(owner->tileData, tile.uv, tile.tex);
|
level->fillObjectTexture(owner->tileData, tile.uv, tile.tex);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
id -= level->objectTexturesCount;
|
id -= level->objectTexturesCount;
|
||||||
|
|
||||||
@@ -1230,8 +1233,10 @@ struct Level : IGame {
|
|||||||
src = owner->tileData->color;
|
src = owner->tileData->color;
|
||||||
uv = t.texCoordAtlas;
|
uv = t.texCoordAtlas;
|
||||||
uvCount = 2;
|
uvCount = 2;
|
||||||
if (data)
|
isSprite = true;
|
||||||
|
if (data) {
|
||||||
level->fillObjectTexture(owner->tileData, tile.uv, tile.tex);
|
level->fillObjectTexture(owner->tileData, tile.uv, tile.tex);
|
||||||
|
}
|
||||||
} else { // common (generated) textures
|
} else { // common (generated) textures
|
||||||
id -= level->spriteTexturesCount;
|
id -= level->spriteTexturesCount;
|
||||||
|
|
||||||
@@ -1281,8 +1286,13 @@ struct Level : IGame {
|
|||||||
ASSERT((y + ATLAS_BORDER + tileY) >= 0 && (y + ATLAS_BORDER + tileY) < atlasHeight);
|
ASSERT((y + ATLAS_BORDER + tileY) >= 0 && (y + ATLAS_BORDER + tileY) < atlasHeight);
|
||||||
p += clamp(x, 0, w - 1);
|
p += clamp(x, 0, w - 1);
|
||||||
p += clamp(y, 0, h - 1) * stride;
|
p += clamp(y, 0, h - 1) * stride;
|
||||||
|
|
||||||
|
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[x + ATLAS_BORDER] = *p;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
dst += atlasWidth;
|
dst += atlasWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -151,7 +151,7 @@ varying vec4 vTexCoord; // xy - atlas coords, zw - trapezoidal correction
|
|||||||
#ifdef TYPE_FLASH
|
#ifdef TYPE_FLASH
|
||||||
vDiffuse.xyz += uMaterial.w;
|
vDiffuse.xyz += uMaterial.w;
|
||||||
#else
|
#else
|
||||||
vDiffuse.w = uMaterial.w;
|
vDiffuse *= uMaterial.w;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TYPE_SPRITE
|
#ifdef TYPE_SPRITE
|
||||||
@@ -465,8 +465,6 @@ varying vec4 vTexCoord; // xy - atlas coords, zw - trapezoidal correction
|
|||||||
fragColor = color;
|
fragColor = color;
|
||||||
#ifdef TYPE_FLASH
|
#ifdef TYPE_FLASH
|
||||||
fragColor.w = 0.0;
|
fragColor.w = 0.0;
|
||||||
#else
|
|
||||||
fragColor.xyz *= fragColor.w;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,7 +20,6 @@ varying vec4 vColor;
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
fragColor = texture2D(sDiffuse, vTexCoord) * vColor;
|
fragColor = texture2D(sDiffuse, vTexCoord) * vColor;
|
||||||
fragColor.rgb *= fragColor.a;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
)===="
|
)===="
|
Reference in New Issue
Block a user