- implement anamorphesis proof-of-concept (#2431)

Co-authored-by: Rachael Alexanderson <madame-rachelle@users.noreply.github.com>
This commit is contained in:
Rachael Alexanderson 2024-09-29 18:09:07 -04:00 committed by GitHub
parent 5cc718ec77
commit bbeaea1ea7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 54 additions and 0 deletions

View file

@ -81,6 +81,8 @@ EXTERN_CVAR(Float, r_actorspriteshadowfadeheight)
CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, gl_sprite_blend, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
CVAR(Int, gl_spriteclip, 1, CVAR_ARCHIVE)
CVAR(Bool, r_debug_nolimitanamorphoses, false, 0)
CVAR(Float, r_spriteclipanamorphicminbias, 0.6, CVAR_ARCHIVE)
CVAR(Float, gl_sclipthreshold, 10.0, CVAR_ARCHIVE)
CVAR(Float, gl_sclipfactor, 1.8f, CVAR_ARCHIVE)
CVAR(Int, gl_particles_style, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // 0 = square, 1 = round, 2 = smooth
@ -1117,6 +1119,56 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
if(thing->renderflags2 & RF2_ISOMETRICSPRITES) depth = depth * vp.PitchCos - vp.PitchSin * z2; // Helps with stacking actors with small xy offsets
if (isSpriteShadow) depth += 1.f/65536.f; // always sort shadows behind the sprite.
if (gl_spriteclip == -1 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE) // perform anamorphosis
{
float minbias = r_spriteclipanamorphicminbias;
minbias = clamp(minbias, 0.3f, 1.0f);
float btm = thing->Sector->floorplane.ZatPoint(thing) - thing->Floorclip;
float top = thing->Sector->ceilingplane.ZatPoint(thingpos);
float vbtm = thing->Sector->floorplane.ZatPoint(vp.Pos);
float vtop = thing->Sector->ceilingplane.ZatPoint(vp.Pos);
float vpx = vp.Pos.X;
float vpy = vp.Pos.Y;
float vpz = vp.Pos.Z;
float tpx = thingpos.X;
float tpy = thingpos.Y;
float tpz = thingpos.Z;
if (!(r_debug_nolimitanamorphoses))
{
// this should help prevent clipping through walls ...
float objradiusbias = 1.f - thing->radius / sqrt((vpx - tpx) * (vpx - tpx) + (vpy - tpy) * (vpy - tpy));
minbias = max(minbias, objradiusbias);
}
float bintersect, tintersect;
if (z2 < vpz && vbtm < vpz)
bintersect = min((btm - vpz) / (z2 - vpz), (vbtm - vpz) / (z2 - vpz));
else
bintersect = 1.0;
if (z1 > vpz && vtop > vpz)
tintersect = min((top - vpz) / (z1 - vpz), (vtop - vpz) / (z1 - vpz));
else
tintersect = 1.0;
if (thing->waterlevel >= 1 && thing->waterlevel <= 2)
bintersect = tintersect = 1.0f;
float spbias = clamp(min(bintersect, tintersect), minbias, 1.0f);
float vpbias = 1.0 - spbias;
x1 = x1 * spbias + vpx * vpbias;
y1 = y1 * spbias + vpy * vpbias;
z1 = z1 * spbias + vpz * vpbias;
x2 = x2 * spbias + vpx * vpbias;
y2 = y2 * spbias + vpy * vpbias;
z2 = z2 * spbias + vpz * vpbias;
}
// light calculation
bool enhancedvision = false;
@ -1335,6 +1387,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
{
lightlist = nullptr;
}
PutSprite(di, hw_styleflags != STYLEHW_Solid);
rendered_sprites++;
}

View file

@ -2392,6 +2392,7 @@ OptionValue "SpriteclipModes"
1, "$OPTVAL_SMART"
2, "$OPTVAL_ALWAYS"
3, "$OPTVAL_SMARTER"
-1, "$OPTVAL_ANAMORPHIC"
}
OptionValue "EnhancedStealth"