diff --git a/src/d_main.c b/src/d_main.c index ff63d296382e588069912a07ce71ce86ae473e8f..de588b6e149b7c37026a8155b1607f35d225db96 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -709,7 +709,7 @@ void D_CheckColorDepth(INT32 newbitdepth, INT32 oldbitdepth) if (newbitdepth != oldbitdepth) { // Reload every texture. - R_LoadTextures(); + R_FlushTextureCache(); // Also free levelflat pictures. R_ClearLevelFlats(); diff --git a/src/r_draw8.c b/src/r_draw8.c index 79cdbd5d1fd57c294b28bb4850d2ea9b20c495d5..7ab2f3e9cb089b2738f1474b511d7f2dfab05915 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -529,10 +529,23 @@ void R_DrawDropShadowColumn_8(void) dest = &topleft[dc_yl*vid.width + dc_x]; - { #define DSCOLOR 31 // palette index for the color of the shadow + + if (!dc_transmap) + { + while ((count -= 2) >= 0) + { + R_AlphaBlend_8(DSCOLOR, dc_alpha, dest); + dest += vid.width; + R_AlphaBlend_8(DSCOLOR, dc_alpha, dest); + dest += vid.width; + } + if (count & 1) + R_AlphaBlend_8(DSCOLOR, dc_alpha, dest); + } + else + { register const UINT8 *transmap_offset = dc_transmap + (dc_colormap[DSCOLOR] << 8); -#undef DSCOLOR while ((count -= 2) >= 0) { *dest = *(transmap_offset + (*dest)); @@ -543,6 +556,8 @@ void R_DrawDropShadowColumn_8(void) if (count & 1) *dest = *(transmap_offset + (*dest)); } + +#undef DSCOLOR } void R_DrawAlphaColumn_8(void) diff --git a/src/r_plane.c b/src/r_plane.c index c72db651ebf8215b55c8e9be3a6dbc3feae50a59..788b820efab12c13426617618e2e415e7d0a0ad9 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -992,7 +992,8 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->ffloor->fofflags & FOF_TRANSLUCENT) { INT32 alpha = pl->ffloor->alpha; - INT32 blendmode = pl->ffloor->blend; + INT32 blendmode = pl->ffloor->blend ? pl->ffloor->blend : AST_TRANSLUCENT; + boolean splat = false; spanfunctype = (pl->ffloor->fofflags & FOF_SPLAT) ? span_translu_splat : span_translu; @@ -1001,7 +1002,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (alpha >= 255) // Opaque, but allow transparent flat pixels { if (blendmode != AST_TRANSLUCENT && blendmode != AST_COPY) - spanfunctype = SPAN_SPLAT; + splat = true; ds_alpha = 0xFF; } else if (alpha < 1 && (blendmode == AST_TRANSLUCENT || blendmode == AST_ADD)) @@ -1014,19 +1015,24 @@ void R_DrawSinglePlane(visplane_t *pl) else { INT32 transnum = R_AlphaToTransnum(alpha); - if (transnum == -1) + if (transnum == -1 && (blendmode == AST_TRANSLUCENT || blendmode == AST_COPY)) return; // Don't even draw it - else if (transnum > 0) + else if (transnum >= 0) { ds_transmap = R_GetBlendTable(blendmode, transnum); if (!ds_transmap) - spanfunctype = SPAN_SPLAT; + splat = true; } else // Opaque, but allow transparent flat pixels - spanfunctype = SPAN_SPLAT; + splat = true; } - if ((spanfunctype == SPAN_SPLAT) || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG))) + if (splat) + { + spanfunctype = SPAN_SPLAT; + } + + if (splat || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG))) light = (pl->lightlevel >> LIGHTSEGSHIFT); else light = LIGHTLEVELS-1; @@ -1126,7 +1132,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (ds_solidcolor) { - // can't possibly have fog and solid color at the same time + // NOTE: can't possibly have fog and solid color at the same time if (spanfunctype == span_water) spanfunctype = span_water_solidcolor; else if (spanfunctype == span_translu) @@ -1178,23 +1184,22 @@ void R_DrawSinglePlane(visplane_t *pl) else R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs); - if (!ds_solidcolor) - { - if (spanfunctype == span_water) - spanfunctype = span_water_tilted; - else if (spanfunctype == span_water_solidcolor) - spanfunctype = span_water_tilted_solidcolor; - else if (spanfunctype == span_translu) - spanfunctype = span_translu_tilted; - else if (spanfunctype == span_translu_solidcolor) - spanfunctype = span_translu_tilted_solidcolor; - else if (spanfunctype == SPAN_SPLAT) - spanfunctype = SPAN_SPLAT_TILTED; - else if (spanfunctype == SPAN_FOG) - spanfunctype = SPAN_FOG_TILTED; - else - spanfunctype = SPAN_TILTED; - } + if (spanfunctype == span_water) + spanfunctype = span_water_tilted; + else if (spanfunctype == span_water_solidcolor) + spanfunctype = span_water_tilted_solidcolor; + else if (spanfunctype == span_translu) + spanfunctype = span_translu_tilted; + else if (spanfunctype == span_translu_solidcolor) + spanfunctype = span_translu_tilted_solidcolor; + else if (spanfunctype == SPAN_SOLIDCOLOR) + spanfunctype = SPAN_SOLIDCOLOR_TILTED; + else if (spanfunctype == SPAN_SPLAT) + spanfunctype = SPAN_SPLAT_TILTED; + else if (spanfunctype == SPAN_FOG) + spanfunctype = SPAN_FOG_TILTED; + else + spanfunctype = SPAN_TILTED; #ifdef TRUECOLOR if (tc_colormaps) diff --git a/src/r_segs.c b/src/r_segs.c index a8923e9559f0339bdf27183fe411444f305c7aa9..4b784b4ea9b66bcc9d138393294dc05139fbcc9e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -734,14 +734,14 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (pfloor->fofflags & FOF_TRANSLUCENT) { INT32 alpha = pfloor->alpha; - INT32 blendmode = pfloor->blend; - boolean fuzzy = true; + INT32 blendmode = pfloor->blend ? pfloor->blend : AST_TRANSLUCENT; + boolean translucent = true; if (!usetranstables) { if (alpha >= 255) // Opaque { - fuzzy = blendmode != AST_TRANSLUCENT && blendmode != AST_COPY; + translucent = blendmode != AST_TRANSLUCENT && blendmode != AST_COPY; dc_alpha = 0xFF; } else if (alpha < 1 && (blendmode == AST_TRANSLUCENT || blendmode == AST_ADD)) @@ -749,7 +749,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else dc_alpha = alpha; - if (fuzzy) + if (translucent) R_SetColumnBlendingFunction(blendmode); } else @@ -757,17 +757,17 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) INT32 transnum = R_AlphaToTransnum(alpha); if (transnum == -1 && (blendmode == AST_TRANSLUCENT || blendmode == AST_ADD)) return; // Don't even draw it - else if (transnum > 0) + else if (transnum >= 0) { dc_transmap = R_GetBlendTable(blendmode, transnum); if (!dc_transmap) - fuzzy = false; + translucent = false; } else - fuzzy = false; // Opaque + translucent = false; // Opaque } - if (fuzzy) + if (translucent) colfunc = colfuncs[column_translu]; } else if (pfloor->fofflags & FOF_FOG) diff --git a/src/r_textures.c b/src/r_textures.c index 7d8d34e2a5cb02fc417c2530521065398386b851..d80fe2ea2aa67bea45024ceead32a65edacb9d91 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -196,7 +196,7 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, tex // // R_DrawBlendColumnInCache -// Draws a translucent column into the cache, applying a half-cooked equation to get a proper translucency value (Needs code in R_GenerateTexture()). +// Draws a translucent column into the cache. // static inline void R_DrawBlendColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight, pictureformat_t format) { @@ -362,7 +362,7 @@ static inline void R_DrawBlendFlippedColumnInCache(column_t *patch, UINT8 *cache // Allocate space for full size texture, either single patch or 'composite' // Build the full textures from patches. // The texture caching system is a little more hungry of memory, but has -// been simplified for the sake of highcolor (lol), dynamic ligthing, & speed. +// been simplified for the sake of highcolor, dynamic ligthing, & speed. // // This is not optimised, but it's supposed to be executed only once // per level, when enough memory is available. @@ -490,8 +490,7 @@ UINT8 *R_GenerateTexture(size_t texnum) pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); lumplength = W_LumpLengthPwad(wadnum, lumpnum); - // If this patch is a PNG, this means that - // the entire texture is 32bpp. + // If this patch is a PNG, this means that the entire texture becomes 32bpp. if (Picture_IsLumpPNG(pdata, lumplength)) { texture->format = PICFMT_PATCH32;