diff --git a/source/core/rendering/scene/hw_drawlistadd.cpp b/source/core/rendering/scene/hw_drawlistadd.cpp index 26ef3da57..69fb35222 100644 --- a/source/core/rendering/scene/hw_drawlistadd.cpp +++ b/source/core/rendering/scene/hw_drawlistadd.cpp @@ -95,7 +95,7 @@ void HWDrawInfo::AddFlat(HWFlat *flat) { int list;; - if (flat->RenderStyle != LegacyRenderStyles[STYLE_Translucent] || flat->alpha < 1.f - FLT_EPSILON) // flat->texture->GetTranslucency() - fixme + if (flat->RenderStyle != LegacyRenderStyles[STYLE_Translucent] || flat->alpha < 1.f - FLT_EPSILON || checkTranslucentReplacement(flat->texture->GetID(), flat->palette)) { // translucent portals go into the translucent border list. list = flat->sprite? GLDL_TRANSLUCENT : GLDL_TRANSLUCENTBORDER; diff --git a/source/core/rendering/scene/hw_drawstructs.h b/source/core/rendering/scene/hw_drawstructs.h index 1c7416553..252a15b16 100644 --- a/source/core/rendering/scene/hw_drawstructs.h +++ b/source/core/rendering/scene/hw_drawstructs.h @@ -375,3 +375,18 @@ inline bool spriteHasTranslucency(const spritetype* tspr) return checkTranslucentReplacement(tileGetTexture(tspr->picnum)->GetID(), tspr->pal); } +inline void SetSpriteTranslucency(const spritetype* sprite, float& alpha, FRenderStyle& RenderStyle) +{ + bool trans = (sprite->cstat & CSTAT_SPRITE_TRANSLUCENT); + if (trans) + { + RenderStyle = GetRenderStyle(0, !!(sprite->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT)); + alpha = GetAlphaFromBlend((sprite->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0); + } + else + { + RenderStyle = LegacyRenderStyles[STYLE_Translucent]; + alpha = 1.f; + } + alpha *= 1.f - spriteext[sprite->owner].alpha; +} diff --git a/source/core/rendering/scene/hw_flats.cpp b/source/core/rendering/scene/hw_flats.cpp index f7d61fd0e..a99d9b13e 100644 --- a/source/core/rendering/scene/hw_flats.cpp +++ b/source/core/rendering/scene/hw_flats.cpp @@ -380,17 +380,8 @@ void HWFlat::ProcessFlatSprite(HWDrawInfo* di, spritetype* sprite, sectortype* s palette = sprite->pal; fade = lookups.getFade(sector[sprite->sectnum].floorpal); // fog is per sector. - bool trans = (sprite->cstat & CSTAT_SPRITE_TRANSLUCENT); - if (trans) - { - RenderStyle = GetRenderStyle(0, !!(sprite->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT)); - alpha = GetAlphaFromBlend((sprite->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0); - } - else - { - RenderStyle = LegacyRenderStyles[STYLE_Translucent]; - alpha = 1.f; - } + SetSpriteTranslucency(sprite, alpha, RenderStyle); + PutFlat(di, 0); } } diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index 888a8b429..66f96865f 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -353,17 +353,7 @@ void HWSprite::Process(HWDrawInfo* di, spritetype* spr, sectortype* sector, int fade = lookups.getFade(sector->floorpal); // fog is per sector. visibility = sectorVisibility(sector); - bool trans = (spr->cstat & CSTAT_SPRITE_TRANSLUCENT); - if (trans) - { - RenderStyle = GetRenderStyle(0, !!(spr->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT)); - alpha = GetAlphaFromBlend((spr->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0); - } - else - { - RenderStyle = LegacyRenderStyles[STYLE_Translucent]; - alpha = 1.f; - } + SetSpriteTranslucency(spr, alpha, RenderStyle); x = spr->x * (1 / 16.f); z = spr->z * (1 / -256.f); @@ -466,7 +456,7 @@ void HWSprite::Process(HWDrawInfo* di, spritetype* spr, sectortype* sector, int } #endif - PutSprite(di, alpha < 1.f-FLT_EPSILON || modelframe == 0); + PutSprite(di, true); rendered_sprites++; } @@ -500,17 +490,7 @@ bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, spritetype* spr, se if (!vox || (spr->cstat & CSTAT_SPRITE_ALIGNMENT) == CSTAT_SPRITE_ALIGNMENT_FLOOR) return false; - bool trans = (spr->cstat & CSTAT_SPRITE_TRANSLUCENT); - if (trans) - { - RenderStyle = GetRenderStyle(0, !!(spr->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT)); - alpha = GetAlphaFromBlend((spr->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0); - } - else - { - RenderStyle = LegacyRenderStyles[STYLE_Translucent]; - alpha = 1.f; - } + SetSpriteTranslucency(spr, alpha, RenderStyle); auto sprext = &spriteext[spr->owner]; @@ -575,7 +555,7 @@ bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, spritetype* spr, se auto vp = di->Viewpoint; depth = (float)((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin); - PutSprite(di, alpha < 1.f - FLT_EPSILON); + PutSprite(di, spriteHasTranslucency(sprite)); rendered_sprites++; return true; } diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 7117bbac1..466979155 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -749,7 +749,7 @@ void HWWall::DoTexture(HWDrawInfo* di, walltype* wal, walltype* refwall, float r tcs[UPRGT].v = setv(topleft, topright, glseg.fracright); tcs[LORGT].v = setv(bottomleft, bottomright, glseg.fracright); if (th == pow2size) CheckTexturePosition(); // for NPOT textures this adjustment can break things. - bool trans = type == RENDERWALL_M2S && (wal->cstat & CSTAT_WALL_TRANSLUCENT); + bool trans = type == RENDERWALL_M2S && maskWallHasTranslucency(wal); if (trans) { RenderStyle = GetRenderStyle(0, !!(wal->cstat & CSTAT_WALL_TRANS_FLIP)); @@ -1086,18 +1086,7 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect fade = lookups.getFade(sector->floorpal); // fog is per sector. visibility = sectorVisibility(sector); - bool trans = (sprite->cstat & CSTAT_SPRITE_TRANSLUCENT); - if (trans) - { - RenderStyle = GetRenderStyle(0, !!(sprite->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT)); - alpha = GetAlphaFromBlend((sprite->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT) ? DAMETH_TRANS2 : DAMETH_TRANS1, 0); - } - else - { - RenderStyle = LegacyRenderStyles[STYLE_Translucent]; - alpha = 1.f; - } - + SetSpriteTranslucency(sprite, alpha, RenderStyle); int height, topofs; if (hw_hightile && TileFiles.tiledata[spr->picnum].hiofs.xsize) @@ -1156,5 +1145,5 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect zbottom[0] = zbottom[1] = floorz; } } - PutWall(di, trans); + PutWall(di, spriteHasTranslucency(sprite)); } \ No newline at end of file