- added a new render style 'Shadow'. Essentially it's just a black translucent stencil with an alpha of 0.3. The purpose of this style is to be used as a software renderer approximation of GZDoom's spectre effect.

- allow setting 'Shadow' as default fuzz effect
- changed CVAR conversion that strings 'false' and 'true' get evaluated as integers 0 and 1 respectively so that changing boolean CVARs to int does not destroy their values.


SVN r3076 (trunk)
This commit is contained in:
Christoph Oelckers 2010-12-25 23:27:26 +00:00
parent e46183d836
commit 231e7a1c6d
9 changed files with 81 additions and 16 deletions

View file

@ -221,7 +221,16 @@ int FBaseCVar::ToInt (UCVarValue value, ECVarType type)
#else
case CVAR_Float: res = (int)value.Float; break;
#endif
case CVAR_String: res = strtol (value.String, NULL, 0); break;
case CVAR_String:
{
if (stricmp (value.String, "true") == 0)
res = 1;
else if (stricmp (value.String, "false") == 0)
res = 0;
else
res = strtol (value.String, NULL, 0);
break;
}
case CVAR_GUID: res = 0; break;
default: res = 0; break;
}
@ -444,7 +453,12 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type)
break;
case CVAR_Int:
ret.Int = strtol (value, NULL, 0);
if (stricmp (value, "true") == 0)
ret.Int = 1;
else if (stricmp (value, "false") == 0)
ret.Int = 0;
else
ret.Int = strtol (value, NULL, 0);
break;
case CVAR_Float:

View file

@ -36,8 +36,6 @@ static FRandom pr_torch ("Torch");
#define TIMEFREEZE_TICS ( 12 * TICRATE )
*/
EXTERN_CVAR (Bool, r_drawfuzz);
IMPLEMENT_CLASS (APowerup)
// Powerup-Giver -------------------------------------------------------------

View file

@ -81,7 +81,6 @@ static void PlayerLandedOnThing (AActor *mo, AActor *onmobj);
extern cycle_t BotSupportCycles;
extern int BotWTG;
EXTERN_CVAR (Bool, r_drawfuzz);
EXTERN_CVAR (Int, cl_rockettrails)
// PRIVATE DATA DEFINITIONS ------------------------------------------------

View file

@ -48,6 +48,7 @@ enum ERenderStyle
STYLE_Add, // Draw additive
STYLE_Shaded, // Treat patch data as alpha values for alphacolor
STYLE_TranslucentStencil,
STYLE_Shadow,
STYLE_Count
};
@ -63,6 +64,9 @@ enum ERenderOp
STYLEOP_FuzzOrAdd, // Draw fuzzy or add, based on user preference
STYLEOP_FuzzOrSub, // Draw fuzzy or subtract, based on user preference
STYLEOP_FuzzOrRevSub, // Draw fuzzy or reverse subtract, based on user preference
// special styles
STYLEOP_Shadow,
};
enum ERenderAlpha

View file

@ -141,6 +141,7 @@ FRenderStyle LegacyRenderStyles[STYLE_Count] =
/* STYLE_Add */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, 0 }},
/* STYLE_Shaded */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_RedIsAlpha | STYLEF_ColorIsFixed }},
/* STYLE_TranslucentStencil */{{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_ColorIsFixed }},
/* STYLE_Shadow */{{ STYLEOP_Shadow, 0, 0, 0 }},
};
#else
FRenderStyle LegacyRenderStyles[STYLE_Count];
@ -157,6 +158,7 @@ static const BYTE Styles[STYLE_Count * 4] =
STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, 0,
STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_RedIsAlpha | STYLEF_ColorIsFixed,
STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_ColorIsFixed,
STYLEOP_Shadow, 0, 0, 0
};
static struct LegacyInit
@ -2068,7 +2070,7 @@ void R_InitColumnDrawers ()
}
// [RH] Choose column drawers in a single place
EXTERN_CVAR (Bool, r_drawfuzz)
EXTERN_CVAR (Int, r_drawfuzz)
EXTERN_CVAR (Float, transsouls)
CVAR (Bool, r_drawtrans, true, 0)
@ -2235,6 +2237,13 @@ ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation,
style.CheckFuzz();
if (style.BlendOp == STYLEOP_Shadow)
{
style = LegacyRenderStyles[STYLE_TranslucentStencil];
alpha = FRACUNIT*3/10;
color = 0;
}
if (style.Flags & STYLEF_TransSoulsAlpha)
{
alpha = fixed_t(transsouls * FRACUNIT);
@ -2390,16 +2399,42 @@ bool FRenderStyle::IsVisible(fixed_t alpha) const throw()
void FRenderStyle::CheckFuzz()
{
if (BlendOp == STYLEOP_FuzzOrAdd)
switch (BlendOp)
{
BlendOp = (r_drawfuzz || !r_drawtrans) ? STYLEOP_Fuzz : STYLEOP_Add;
default:
return;
case STYLEOP_FuzzOrAdd:
if (r_drawtrans && r_drawfuzz == 0)
{
BlendOp = STYLEOP_Add;
return;
}
break;
case STYLEOP_FuzzOrSub:
if (r_drawtrans && r_drawfuzz == 0)
{
BlendOp = STYLEOP_Sub;
return;
}
break;
case STYLEOP_FuzzOrRevSub:
if (r_drawtrans && r_drawfuzz == 0)
{
BlendOp = STYLEOP_RevSub;
return;
}
break;
}
else if (BlendOp == STYLEOP_FuzzOrSub)
if (r_drawfuzz == 2)
{
BlendOp = (r_drawfuzz || !r_drawtrans) ? STYLEOP_Fuzz : STYLEOP_Sub;
BlendOp = STYLEOP_Shadow;
}
else if (BlendOp == STYLEOP_FuzzOrRevSub)
else
{
BlendOp = (r_drawfuzz || !r_drawtrans) ? STYLEOP_Fuzz : STYLEOP_RevSub;
BlendOp = STYLEOP_Fuzz;
}
}

View file

@ -61,7 +61,7 @@ extern fixed_t globaluclip, globaldclip;
#define BASEYCENTER (100)
EXTERN_CVAR (Bool, st_scale)
CVAR (Bool, r_drawfuzz, true, CVAR_ARCHIVE)
CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE)
//

View file

@ -601,11 +601,11 @@ DEFINE_PROPERTY(renderstyle, S, Actor)
{
PROP_STRING_PARM(str, 0);
static const char * renderstyles[]={
"NONE","NORMAL","FUZZY","SOULTRANS","OPTFUZZY","STENCIL","TRANSLUCENT", "ADD","SHADED", NULL};
"NONE","NORMAL","FUZZY","SOULTRANS","OPTFUZZY","STENCIL","TRANSLUCENT", "ADD", "SHADED", "SHADOW", NULL};
static const int renderstyle_values[]={
STYLE_None, STYLE_Normal, STYLE_Fuzzy, STYLE_SoulTrans, STYLE_OptFuzzy,
STYLE_TranslucentStencil, STYLE_Translucent, STYLE_Add, STYLE_Shaded};
STYLE_TranslucentStencil, STYLE_Translucent, STYLE_Add, STYLE_Shaded, STYLE_Shadow};
// make this work for old style decorations, too.
if (!strnicmp(str, "style_", 6)) str+=6;

View file

@ -3677,6 +3677,14 @@ bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &
alpha = clamp<fixed_t> (parms.alpha, 0, FRACUNIT) / 65536.f;
}
style.CheckFuzz();
if (style.BlendOp == STYLEOP_Shadow)
{
style = LegacyRenderStyles[STYLE_TranslucentStencil];
alpha = 0.3f;
parms.fillcolor = 0;
}
// FIXME: Fuzz effect is not written
if (style.BlendOp == STYLEOP_FuzzOrAdd || style.BlendOp == STYLEOP_Fuzz)
{

View file

@ -640,6 +640,13 @@ OptionValue Contrast
2.0, "Smooth"
}
OptionValue Fuzziness
{
0.0, "Translucent"
1.0, "Fuzz"
2.0, "Shadow"
}
OptionMenu "VideoOptions"
{
Title "DISPLAY OPTIONS"
@ -662,7 +669,7 @@ OptionMenu "VideoOptions"
}
Option "Stretch short skies", "r_stretchsky", "OnOff"
Option "Use fuzz effect", "r_drawfuzz", "YesNo"
Option "Use fuzz effect", "r_drawfuzz", "Fuzziness"
Slider "Lost Soul translucency", "transsouls", 0.25, 1.0, 0.05, 2
Option "Use fake contrast", "r_fakecontrast", "Contrast"
Option "Rocket Trails", "cl_rockettrails", "RocketTrailTypes"