Merged https://github.com/ZDoom/gzdoom/pull/1394 (CVars to fade sprite shadows)

This commit is contained in:
Major Cooke 2023-01-21 11:04:50 -06:00
parent 3b46327493
commit 07349dcc70
2 changed files with 22 additions and 2 deletions

View file

@ -67,7 +67,8 @@ const float LARGE_VALUE = 1e19f;
EXTERN_CVAR(Bool, r_debug_disable_vis_filter) EXTERN_CVAR(Bool, r_debug_disable_vis_filter)
EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Float, transsouls)
EXTERN_CVAR(Float, r_actorspriteshadowalpha)
EXTERN_CVAR(Float, r_actorspriteshadowfadeheight)
//========================================================================== //==========================================================================
// //
@ -1174,7 +1175,12 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
{ {
RenderStyle = STYLE_Stencil; RenderStyle = STYLE_Stencil;
ThingColor = MAKEARGB(255, 0, 0, 0); ThingColor = MAKEARGB(255, 0, 0, 0);
trans *= 0.5f; // fade shadow progressively as the thing moves higher away from the floor
if (r_actorspriteshadowfadeheight > 0.0) {
trans *= clamp(0.0f, float(r_actorspriteshadowalpha - (thingpos.Z - thing->floorz) * (1.0 / r_actorspriteshadowfadeheight)), float(r_actorspriteshadowalpha));
} else {
trans *= r_actorspriteshadowalpha;
}
hw_styleflags = STYLEHW_NoAlphaTest; hw_styleflags = STYLEHW_NoAlphaTest;
} }

View file

@ -121,6 +121,20 @@ CUSTOM_CVARD(Float, r_actorspriteshadowdist, 1500.0, CVAR_ARCHIVE | CVAR_GLOBALC
else if (self > 8192.f) else if (self > 8192.f)
self = 8192.f; self = 8192.f;
} }
CUSTOM_CVARD(Float, r_actorspriteshadowalpha, 0.5, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "maximum sprite shadow opacity, only effective with hardware renderers (0.0 = fully transparent, 1.0 = opaque)")
{
if (self < 0.f)
self = 0.f;
else if (self > 1.f)
self = 1.f;
}
CUSTOM_CVARD(Float, r_actorspriteshadowfadeheight, 0.0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "distance over which sprite shadows should fade, only effective with hardware renderers (0 = infinite)")
{
if (self < 0.f)
self = 0.f;
else if (self > 8192.f)
self = 8192.f;
}
int viewwindowx; int viewwindowx;
int viewwindowy; int viewwindowy;