mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 16:07:45 +00:00
- only do shade clamps if needed
This commit is contained in:
parent
52b7a77771
commit
2db433e68f
2 changed files with 26 additions and 12 deletions
|
@ -83,7 +83,7 @@ public:
|
||||||
float worldposZ[MAXWIDTH];
|
float worldposZ[MAXWIDTH];
|
||||||
uint32_t texel[MAXWIDTH];
|
uint32_t texel[MAXWIDTH];
|
||||||
int32_t texelV[MAXWIDTH];
|
int32_t texelV[MAXWIDTH];
|
||||||
fixed_t lightarray[MAXWIDTH];
|
uint16_t lightarray[MAXWIDTH];
|
||||||
uint32_t dynlights[MAXWIDTH];
|
uint32_t dynlights[MAXWIDTH];
|
||||||
|
|
||||||
static PolyTriangleThreadData *Get(DrawerThread *thread);
|
static PolyTriangleThreadData *Get(DrawerThread *thread);
|
||||||
|
|
|
@ -403,7 +403,7 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyT
|
||||||
float *worldposZ = thread->worldposZ;
|
float *worldposZ = thread->worldposZ;
|
||||||
uint32_t *texel = thread->texel;
|
uint32_t *texel = thread->texel;
|
||||||
int32_t *texelV = thread->texelV;
|
int32_t *texelV = thread->texelV;
|
||||||
fixed_t *lightarray = thread->lightarray;
|
uint16_t *lightarray = thread->lightarray;
|
||||||
uint32_t *dynlights = thread->dynlights;
|
uint32_t *dynlights = thread->dynlights;
|
||||||
|
|
||||||
if (!(ModeT::SWFlags & SWSTYLEF_Fill) && !(ModeT::SWFlags & SWSTYLEF_FogBoundary))
|
if (!(ModeT::SWFlags & SWSTYLEF_Fill) && !(ModeT::SWFlags & SWSTYLEF_FogBoundary))
|
||||||
|
@ -463,6 +463,29 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyT
|
||||||
shade = (fixed_t)((2.0f - (light + 12.0f) / 128.0f) * (float)FRACUNIT);
|
shade = (fixed_t)((2.0f - (light + 12.0f) / 128.0f) * (float)FRACUNIT);
|
||||||
lightpos = (fixed_t)(globVis * posW * (float)FRACUNIT);
|
lightpos = (fixed_t)(globVis * posW * (float)FRACUNIT);
|
||||||
lightstep = (fixed_t)(globVis * stepW * (float)FRACUNIT);
|
lightstep = (fixed_t)(globVis * stepW * (float)FRACUNIT);
|
||||||
|
|
||||||
|
fixed_t maxvis = 24 * FRACUNIT / 32;
|
||||||
|
fixed_t maxlight = 31 * FRACUNIT / 32;
|
||||||
|
|
||||||
|
fixed_t lightend = lightpos + lightstep * (x1 - x0);
|
||||||
|
if (lightpos < maxvis && shade >= lightpos && shade - lightpos <= maxlight &&
|
||||||
|
lightend < maxvis && shade >= lightend && shade - lightend <= maxlight)
|
||||||
|
{
|
||||||
|
lightpos += FRACUNIT - shade;
|
||||||
|
for (int x = x0; x < x1; x++)
|
||||||
|
{
|
||||||
|
lightarray[x] = lightpos >> 8;
|
||||||
|
lightpos += lightstep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int x = x0; x < x1; x++)
|
||||||
|
{
|
||||||
|
lightarray[x] = (FRACUNIT - clamp<fixed_t>(shade - MIN(maxvis, lightpos), 0, maxlight)) >> 8;
|
||||||
|
lightpos += lightstep;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = x0; x < x1; x++)
|
for (int x = x0; x < x1; x++)
|
||||||
|
@ -477,15 +500,6 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyT
|
||||||
posWorldY += stepWorldY;
|
posWorldY += stepWorldY;
|
||||||
posWorldZ += stepWorldZ;
|
posWorldZ += stepWorldZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(OptT::Flags & SWOPT_FixedLight))
|
|
||||||
{
|
|
||||||
fixed_t maxvis = 24 * FRACUNIT / 32;
|
|
||||||
fixed_t maxlight = 31 * FRACUNIT / 32;
|
|
||||||
lightarray[x] = (FRACUNIT - clamp<fixed_t>(shade - MIN(maxvis, lightpos), 0, maxlight)) >> 8;
|
|
||||||
lightpos += lightstep;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ModeT::SWFlags & SWSTYLEF_Fill) && !(ModeT::SWFlags & SWSTYLEF_FogBoundary))
|
if (!(ModeT::SWFlags & SWSTYLEF_Fill) && !(ModeT::SWFlags & SWSTYLEF_FogBoundary))
|
||||||
{
|
{
|
||||||
float rcpW = 0x01000000 / posW;
|
float rcpW = 0x01000000 / posW;
|
||||||
|
@ -706,7 +720,7 @@ void DrawSpanOpt32(int y, int x0, int x1, const TriDrawTriangleArgs *args, PolyT
|
||||||
__m128i mfg = _mm_unpacklo_epi8(_mm_setr_epi32(texPixels[texel[x]], texPixels[texel[x + 1]], 0, 0), _mm_setzero_si128());
|
__m128i mfg = _mm_unpacklo_epi8(_mm_setr_epi32(texPixels[texel[x]], texPixels[texel[x + 1]], 0, 0), _mm_setzero_si128());
|
||||||
|
|
||||||
if (!(OptT::Flags & SWOPT_FixedLight))
|
if (!(OptT::Flags & SWOPT_FixedLight))
|
||||||
mlightshade = _mm_shuffle_epi32(_mm_shufflelo_epi16(_mm_loadl_epi64((const __m128i*)&lightarray[x]), _MM_SHUFFLE(2, 2, 0, 0)), _MM_SHUFFLE(1, 1, 0, 0));
|
mlightshade = _mm_shuffle_epi32(_mm_shufflelo_epi16(_mm_cvtsi32_si128(*(int*)&lightarray[x]), _MM_SHUFFLE(1, 1, 0, 0)), _MM_SHUFFLE(1, 1, 0, 0));
|
||||||
|
|
||||||
if (OptT::Flags & SWOPT_DynLights)
|
if (OptT::Flags & SWOPT_DynLights)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue