diff --git a/src/crispy.c b/src/crispy.c index e2544d498..ce647f2ce 100644 --- a/src/crispy.c +++ b/src/crispy.c @@ -31,6 +31,7 @@ static crispy_t crispy_s = { #ifdef CRISPY_TRUECOLOR .smoothlight = 1, .truecolor = 1, + .blendquality = 1, #endif .vsync = 1, .widescreen = 1, // match screen by default diff --git a/src/crispy.h b/src/crispy.h index de6e702cc..7ec248cb9 100644 --- a/src/crispy.h +++ b/src/crispy.h @@ -81,6 +81,7 @@ typedef struct int translucency; #ifdef CRISPY_TRUECOLOR int truecolor; + int blendquality; #endif int uncapped; int vsync; diff --git a/src/doom/d_main.c b/src/doom/d_main.c index 5b782bfa8..3e0c0dec4 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -483,6 +483,7 @@ void D_BindVariables(void) M_BindIntVariable("crispy_translucency", &crispy->translucency); #ifdef CRISPY_TRUECOLOR M_BindIntVariable("crispy_truecolor", &crispy->truecolor); + M_BindIntVariable("crispy_blendquality", &crispy->blendquality); #endif M_BindIntVariable("crispy_uncapped", &crispy->uncapped); M_BindIntVariable("crispy_vsync", &crispy->vsync); diff --git a/src/doom/r_things.c b/src/doom/r_things.c index 6f1e31a68..f23cbe5ea 100644 --- a/src/doom/r_things.c +++ b/src/doom/r_things.c @@ -817,7 +817,7 @@ void R_ProjectSprite (mobj_t* thing) // [crispy] translucent sprites if (thing->flags & MF_TRANSLUCENT) { - vis->blendfunc = (thing->frame & FF_FULLBRIGHT) ? I_BlendAdd : I_BlendOverTranmap; + vis->blendfunc = (thing->frame & FF_FULLBRIGHT) ? I_BlendAddFunc : I_BlendOverTranmap; } #endif } diff --git a/src/i_truecolor.c b/src/i_truecolor.c index debd726bc..f7f419099 100644 --- a/src/i_truecolor.c +++ b/src/i_truecolor.c @@ -42,6 +42,10 @@ static uint32_t blendAddLUT[512][512]; // Additive blending static uint32_t blendOverLUT[512][512]; // Overlay blending static uint32_t blendOverAltLUT[512][512]; // Overlay "alt" blending +const uint32_t (*I_BlendAddFunc) (const uint32_t bg_i, const uint32_t fg_i); +const uint32_t (*I_BlendOverFunc) (const uint32_t bg_i, const uint32_t fg_i, const int amount); +//const uint32_t (*I_BlendOverAltFunc) (const uint32_t bg_i, const uint32_t fg_i); + // [JN] Different blending alpha values for different games #define OVERLAY_ALPHA_TRANMAP 168 // Doom: TRANMAP, 66% opacity #define OVERLAY_ALPHA_TINTTAB 96 // Raven: TINTTAB, 38% opacity @@ -176,7 +180,7 @@ const uint32_t I_BlendOverLow (const uint32_t bg_i, const uint32_t fg_i, const i // [crispy] TRANMAP blending emulation, used for Doom const uint32_t I_BlendOverTranmap (const uint32_t bg, const uint32_t fg) { - return I_BlendOver(bg, fg, 0xA8); // 168 (66% opacity) + return I_BlendOverFunc(bg, fg, 0xA8); // 168 (66% opacity) } // [crispy] TINTTAB blending emulation, used for Heretic and Hexen @@ -203,4 +207,21 @@ const uint32_t I_BlendOverAltXlatab (const uint32_t bg, const uint32_t fg) return I_BlendOver(bg, fg, 0x40); // 64 (25% opacity) } +// [JN] Set pointers to blending functions. +void R_InitBlendQuality (void) +{ + if (crispy->blendquality) + { + I_BlendAddFunc = I_BlendAdd; + I_BlendOverFunc = I_BlendOver; + // I_BlendOverAltFunc = I_BlendOverAlt; + } + else + { + I_BlendAddFunc = I_BlendAddLow; + I_BlendOverFunc = I_BlendOverLow; + // I_BlendOverAltFunc = I_BlendOverAltLow; + } +} + #endif diff --git a/src/i_truecolor.h b/src/i_truecolor.h index 969707510..148eaf1ec 100644 --- a/src/i_truecolor.h +++ b/src/i_truecolor.h @@ -29,6 +29,9 @@ extern const uint32_t (*blendfunc) (const uint32_t fg, const uint32_t bg); extern void R_InitBlendMaps (void); +extern void R_InitBlendQuality (void); +extern const uint32_t (*I_BlendAddFunc) (const uint32_t bg_i, const uint32_t fg_i); +extern const uint32_t (*I_BlendOverFunc) (const uint32_t bg_i, const uint32_t fg_i, const int amount); const uint32_t I_BlendAdd (const uint32_t bg_i, const uint32_t fg_i); const uint32_t I_BlendDark (const uint32_t bg_i, const int d); diff --git a/src/m_config.c b/src/m_config.c index 1bdff289b..eb36ab5b0 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -2606,6 +2606,14 @@ static default_t extra_defaults_list[] = // CONFIG_VARIABLE_INT(crispy_truecolor), + + //! + // @game doom + // + // Quality of translucency blending. + // + + CONFIG_VARIABLE_INT(crispy_blendquality), #endif //! diff --git a/src/setup/compatibility.c b/src/setup/compatibility.c index d8a2d3a64..3346d3d6b 100644 --- a/src/setup/compatibility.c +++ b/src/setup/compatibility.c @@ -91,6 +91,7 @@ void BindCompatibilityVariables(void) M_BindIntVariable("crispy_translucency", &crispy->translucency); #ifdef CRISPY_TRUECOLOR M_BindIntVariable("crispy_truecolor", &crispy->truecolor); + M_BindIntVariable("crispy_blendquality", &crispy->blendquality); #endif M_BindIntVariable("crispy_uncapped", &crispy->uncapped); M_BindIntVariable("crispy_vsync", &crispy->vsync);