Add SPF_NOMIPMAP to force actor sprites or particles to have no mipmaps. This makes tiny sprites/particles look more crisp and legible in the distance. Mipmapping causes the sprites/particles to have an inconsistent look where they'd sometimes be clearly visible and sometimes less visible depending on camera distance and movement.

This commit is contained in:
nashmuhandes 2024-07-31 00:41:00 +08:00 committed by Ricardo Luís Vaz Silva
parent 3d3cd88868
commit 593e1c0225
6 changed files with 11 additions and 1 deletions

View file

@ -501,6 +501,7 @@ enum ActorRenderFlag2
RF2_FLIPSPRITEOFFSETX = 0x0010, RF2_FLIPSPRITEOFFSETX = 0x0010,
RF2_FLIPSPRITEOFFSETY = 0x0020, RF2_FLIPSPRITEOFFSETY = 0x0020,
RF2_CAMFOLLOWSPLAYER = 0x0040, // Matches the cam's base position and angles to the main viewpoint. RF2_CAMFOLLOWSPLAYER = 0x0040, // Matches the cam's base position and angles to the main viewpoint.
RF2_NOMIPMAP = 0x0080, // [Nash] forces no mipmapping on sprites. Useful for tiny sprites that need to remain visually crisp
}; };
// This translucency value produces the closest match to Heretic's TINTTAB. // This translucency value produces the closest match to Heretic's TINTTAB.

View file

@ -69,6 +69,7 @@ enum EParticleFlags
SPF_FACECAMERA = 1 << 11, SPF_FACECAMERA = 1 << 11,
SPF_NOFACECAMERA = 1 << 12, SPF_NOFACECAMERA = 1 << 12,
SPF_ROLLCENTER = 1 << 13, SPF_ROLLCENTER = 1 << 13,
SPF_NOMIPMAP = 1 << 14,
}; };
class DVisualThinker; class DVisualThinker;

View file

@ -393,6 +393,7 @@ public:
TArray<lightlist_t> *lightlist; TArray<lightlist_t> *lightlist;
DRotator Angles; DRotator Angles;
bool nomipmap; // force the sprite to have no mipmaps (ensures tiny sprites in the distance stay crisp)
void SplitSprite(HWDrawInfo *di, sector_t * frontsector, bool translucent); void SplitSprite(HWDrawInfo *di, sector_t * frontsector, bool translucent);
void PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight); void PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight);

View file

@ -221,8 +221,10 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
state.SetFog(0, 0); state.SetFog(0, 0);
} }
int clampmode = nomipmap ? CLAMP_XY_NOMIP : CLAMP_XY;
uint32_t spritetype = actor? uint32_t(actor->renderflags & RF_SPRITETYPEMASK) : 0; uint32_t spritetype = actor? uint32_t(actor->renderflags & RF_SPRITETYPEMASK) : 0;
if (texture) state.SetMaterial(texture, UF_Sprite, (spritetype == RF_FACESPRITE) ? CTF_Expand : 0, CLAMP_XY, translation, OverrideShader); if (texture) state.SetMaterial(texture, UF_Sprite, (spritetype == RF_FACESPRITE) ? CTF_Expand : 0, clampmode, translation, OverrideShader);
else if (!modelframe) state.EnableTexture(false); else if (!modelframe) state.EnableTexture(false);
//SetColor(lightlevel, rel, Colormap, trans); //SetColor(lightlevel, rel, Colormap, trans);
@ -771,6 +773,8 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
return; return;
} }
nomipmap = (thing->renderflags2 & RF2_NOMIPMAP);
// check renderrequired vs ~r_rendercaps, if anything matches we don't support that feature, // check renderrequired vs ~r_rendercaps, if anything matches we don't support that feature,
// check renderhidden vs r_rendercaps, if anything matches we do support that feature and should hide it. // check renderhidden vs r_rendercaps, if anything matches we do support that feature and should hide it.
if ((!r_debug_disable_vis_filter && !!(thing->RenderRequired & ~r_renderercaps)) || if ((!r_debug_disable_vis_filter && !!(thing->RenderRequired & ~r_renderercaps)) ||
@ -1325,6 +1329,7 @@ void HWSprite::ProcessParticle(HWDrawInfo *di, particle_t *particle, sector_t *s
actor = nullptr; actor = nullptr;
this->particle = particle; this->particle = particle;
fullbright = particle->flags & SPF_FULLBRIGHT; fullbright = particle->flags & SPF_FULLBRIGHT;
nomipmap = particle->flags & SPF_NOMIPMAP;
if (di->isFullbrightScene()) if (di->isFullbrightScene())
{ {

View file

@ -384,6 +384,7 @@ static FFlagDef ActorFlagDefs[]=
DEFINE_FLAG(RF2, FLIPSPRITEOFFSETX, AActor, renderflags2), DEFINE_FLAG(RF2, FLIPSPRITEOFFSETX, AActor, renderflags2),
DEFINE_FLAG(RF2, FLIPSPRITEOFFSETY, AActor, renderflags2), DEFINE_FLAG(RF2, FLIPSPRITEOFFSETY, AActor, renderflags2),
DEFINE_FLAG(RF2, CAMFOLLOWSPLAYER, AActor, renderflags2), DEFINE_FLAG(RF2, CAMFOLLOWSPLAYER, AActor, renderflags2),
DEFINE_FLAG(RF2, NOMIPMAP, AActor, renderflags2),
// Bounce flags // Bounce flags
DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags), DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags),

View file

@ -718,6 +718,7 @@ enum EParticleFlags
SPF_FACECAMERA = 1 << 11, SPF_FACECAMERA = 1 << 11,
SPF_NOFACECAMERA = 1 << 12, SPF_NOFACECAMERA = 1 << 12,
SPF_ROLLCENTER = 1 << 13, SPF_ROLLCENTER = 1 << 13,
SPF_NOMIPMAP = 1 << 14,
SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG
}; };