mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-17 01:31:25 +00:00
Add cvars to sprite shadows progressively according to thing <-> floor distance
This also adds the `r_actorspriteshadowalpha` and `r_actorspriteshadowfadeheight` cvars for greater control (only effective in hardware renderers). These are set to 0.5 and 0 by default, which means this fading behavior is disabled by default. When enabled, this has two benefits: - It becomes easier for the player to judge an entity's height since the shadow opacity now gives this information. - Entities that are far high above the ground no longer cast a shadow, which looked strange.
This commit is contained in:
parent
2d94321887
commit
ad49d52b1c
2 changed files with 22 additions and 2 deletions
|
@ -67,7 +67,8 @@ const float LARGE_VALUE = 1e19f;
|
|||
|
||||
EXTERN_CVAR(Bool, r_debug_disable_vis_filter)
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,6 +121,20 @@ CUSTOM_CVARD(Float, r_actorspriteshadowdist, 1500.0, CVAR_ARCHIVE | CVAR_GLOBALC
|
|||
else if (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 viewwindowy;
|
||||
|
|
Loading…
Reference in a new issue