Stip stippled transparency

This commit is contained in:
Anders Jenbo 2021-12-20 01:47:49 +01:00
commit b6bdbcfc98
7 changed files with 23 additions and 228 deletions

View file

@ -239,111 +239,6 @@ const std::uint32_t LeftMaskTransparent[TILE_HEIGHT] = {
0xFFFFFFFF,
0xFFFFFFFF
};
/** Specifies the draw masks used to render transparency of the right side of tiles. */
const std::uint32_t RightMask[TILE_HEIGHT] = {
0xEAAAAAAA,
0xF5555555,
0xFEAAAAAA,
0xFF555555,
0xFFEAAAAA,
0xFFF55555,
0xFFFEAAAA,
0xFFFF5555,
0xFFFFEAAA,
0xFFFFF555,
0xFFFFFEAA,
0xFFFFFF55,
0xFFFFFFEA,
0xFFFFFFF5,
0xFFFFFFFE,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF
};
/** Specifies the draw masks used to render transparency of the left side of tiles. */
const std::uint32_t LeftMask[TILE_HEIGHT] = {
0xAAAAAAAB,
0x5555555F,
0xAAAAAABF,
0x555555FF,
0xAAAAABFF,
0x55555FFF,
0xAAAABFFF,
0x5555FFFF,
0xAAABFFFF,
0x555FFFFF,
0xAABFFFFF,
0x55FFFFFF,
0xABFFFFFF,
0x5FFFFFFF,
0xBFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF
};
/** Specifies the draw masks used to render transparency of wall tiles. */
const std::uint32_t WallMask[TILE_HEIGHT] = {
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555,
0xAAAAAAAA,
0x55555555
};
/** Fully opaque mask */
const std::uint32_t SolidMask[TILE_HEIGHT] = {
0xFFFFFFFF,
@ -491,7 +386,6 @@ DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void ForEachSetBit(std::uint32_t mask, const
enum class TransparencyType {
Solid,
Blended,
Stippled,
};
enum class LightType {
@ -558,22 +452,6 @@ DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderLineBlended(std::uint8_t *dst, co
#endif
}
template <LightType Light>
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderLineStippled(std::uint8_t *dst, const std::uint8_t *src, const std::uint8_t *tbl, std::uint32_t mask)
{
if (Light == LightType::FullyDark) {
ForEachSetBit(mask, [=](int i) { dst[i] = 0; });
} else if (Light == LightType::FullyLit) {
#ifndef DEBUG_RENDER_COLOR
ForEachSetBit(mask, [=](int i) { dst[i] = src[i]; });
#else
ForEachSetBit(mask, [=](int i) { dst[i] = DBGCOLOR; });
#endif
} else { // Partially lit
ForEachSetBit(mask, [=](int i) { dst[i] = tbl[src[i]]; });
}
}
template <TransparencyType Transparency, LightType Light>
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderLine(std::uint8_t *dst, const std::uint8_t *src, std::uint_fast8_t n, const std::uint8_t *tbl, std::uint32_t mask)
{
@ -591,8 +469,6 @@ DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderLine(std::uint8_t *dst, const std
RenderLineOpaque<Light>(dst, src, n, tbl);
} else if (Transparency == TransparencyType::Blended) {
RenderLineBlended<Light>(dst, src, n, tbl, mask);
} else {
RenderLineStippled<Light>(dst, src, tbl, mask);
}
}
}
@ -1252,24 +1128,18 @@ const std::uint32_t *GetMask(TileType tile)
if (cel_transparency_active) {
if (arch_draw_type == 0) {
if (*sgOptions.Graphics.blendedTransparancy) // Use a fully transparent mask
return &WallMaskFullyTrasparent[TILE_HEIGHT - 1];
return &WallMask[TILE_HEIGHT - 1];
return &WallMaskFullyTrasparent[TILE_HEIGHT - 1];
}
if (arch_draw_type == 1 && tile != TileType::LeftTriangle) {
const auto c = block_lvid[level_piece_id];
if (c == 1 || c == 3) {
if (*sgOptions.Graphics.blendedTransparancy) // Use a fully transparent mask
return &LeftMaskTransparent[TILE_HEIGHT - 1];
return &LeftMask[TILE_HEIGHT - 1];
return &LeftMaskTransparent[TILE_HEIGHT - 1];
}
}
if (arch_draw_type == 2 && tile != TileType::RightTriangle) {
const auto c = block_lvid[level_piece_id];
if (c == 2 || c == 3) {
if (*sgOptions.Graphics.blendedTransparancy) // Use a fully transparent mask
return &RightMaskTransparent[TILE_HEIGHT - 1];
return &RightMask[TILE_HEIGHT - 1];
return &RightMaskTransparent[TILE_HEIGHT - 1];
}
}
} else if (arch_draw_type != 0 && cel_foliage_active) {
@ -1412,22 +1282,12 @@ void RenderTile(const Surface &out, Point position)
}
} else {
mask -= clip.bottom;
if (*sgOptions.Graphics.blendedTransparancy) {
if (LightTableIndex == LightsMax) {
RenderTileType<TransparencyType::Blended, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip);
} else if (LightTableIndex == 0) {
RenderTileType<TransparencyType::Blended, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
} else {
RenderTileType<TransparencyType::Blended, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
}
if (LightTableIndex == LightsMax) {
RenderTileType<TransparencyType::Blended, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip);
} else if (LightTableIndex == 0) {
RenderTileType<TransparencyType::Blended, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
} else {
if (LightTableIndex == LightsMax) {
RenderTileType<TransparencyType::Stippled, LightType::FullyDark>(tile, dst, dstPitch, src, mask, tbl, clip);
} else if (LightTableIndex == 0) {
RenderTileType<TransparencyType::Stippled, LightType::FullyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
} else {
RenderTileType<TransparencyType::Stippled, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
}
RenderTileType<TransparencyType::Blended, LightType::PartiallyLit>(tile, dst, dstPitch, src, mask, tbl, clip);
}
}
}