Skip to content

Commit

Permalink
- moved alpha threshold determination for sprites to the setup pass.
Browse files Browse the repository at this point in the history
Overall this is not much, but it can be easily offloaded to a worker thread later.
  • Loading branch information
coelckers committed Jan 13, 2022
1 parent 37e7f92 commit 899ced5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions source/core/rendering/scene/hw_drawstructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ class HWSprite : public HWFlatOrSprite
VSMatrix rotmat;
};
int dynlightindex;
float alphaThreshold;

FGameTexture *texture;
DRotator Angles;
Expand Down
13 changes: 7 additions & 6 deletions source/core/rendering/scene/hw_sprites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,22 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent)

state.SetRenderStyle(RenderStyle);
state.SetTextureMode(RenderStyle);

if (texture && (hw_int_useindexedcolortextures || !checkTranslucentReplacement(texture->GetID(), palette))) state.AlphaFunc(Alpha_GEqual, texture->alphaThreshold);
else state.AlphaFunc(Alpha_Greater, 0.f);
state.AlphaFunc(Alpha_Greater, alphaThreshold);

if (RenderStyle.BlendOp == STYLEOP_Add && RenderStyle.DestAlpha == STYLEALPHA_One)
{
additivefog = true;
}
}

#if 0
if (dynlightindex == -1) // only set if we got no light buffer index. This covers all cases where sprite lighting is used.
{
float out[3] = {};
//di->GetDynSpriteLight(gl_light_sprites ? actor : nullptr, gl_light_particles ? particle : nullptr, out);
//state.SetDynLight(out[0], out[1], out[2]);
}
#endif


if (RenderStyle.Flags & STYLEF_FadeToBlack)
Expand Down Expand Up @@ -287,7 +287,9 @@ void HWSprite::CreateVertices(HWDrawInfo* di)

inline void HWSprite::PutSprite(HWDrawInfo* di, bool translucent)
{
// That's a lot of checks...
if (translucent && texture && (hw_int_useindexedcolortextures || !checkTranslucentReplacement(texture->GetID(), palette))) alphaThreshold = texture->alphaThreshold;
else alphaThreshold = 0;

/*
if (modelframe == 1 && gl_light_sprites)
{
Expand All @@ -297,6 +299,7 @@ inline void HWSprite::PutSprite(HWDrawInfo* di, bool translucent)
else*/
dynlightindex = -1;

rendered_sprites++;
vertexindex = -1;
if (!screen->BuffersArePersistent())
{
Expand Down Expand Up @@ -435,7 +438,6 @@ void HWSprite::Process(HWDrawInfo* di, tspritetype* spr, sectortype* sector, int
#endif

PutSprite(di, true);
rendered_sprites++;
}


Expand Down Expand Up @@ -534,6 +536,5 @@ bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, tspritetype* spr, s
auto vp = di->Viewpoint;
depth = (float)((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin);
PutSprite(di, spriteHasTranslucency(Sprite));
rendered_sprites++;
return true;
}

0 comments on commit 899ced5

Please sign in to comment.