mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
Merge branch 'master' of https://github.com/coelckers/gzdoom
This commit is contained in:
commit
734f5104dd
10 changed files with 88 additions and 73 deletions
|
@ -702,6 +702,7 @@ set ( SWRENDER_SOURCES
|
|||
swrenderer/r_swrenderer.cpp
|
||||
swrenderer/r_memory.cpp
|
||||
swrenderer/r_renderthread.cpp
|
||||
swrenderer/drawers/r_draw.cpp
|
||||
swrenderer/drawers/r_draw_pal.cpp
|
||||
swrenderer/drawers/r_draw_rgba.cpp
|
||||
swrenderer/drawers/r_thread.cpp
|
||||
|
|
|
@ -938,7 +938,7 @@ int FGLRenderer::PTM_BestColor (const uint32_t *pal_in, int r, int g, int b, int
|
|||
static bool firstTime = true;
|
||||
static float trackpowtable = 0.;
|
||||
|
||||
double fbestdist, fdist;
|
||||
double fbestdist = DBL_MAX, fdist;
|
||||
int bestcolor = 0;
|
||||
|
||||
if (firstTime || trackpowtable != gl_paltonemap_powtable)
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace TriScreenDrawerModes
|
|||
}
|
||||
|
||||
template<typename SamplerT>
|
||||
FORCEINLINE unsigned int SampleShade32(int32_t u, int32_t v, const uint32_t *texPixels, int texWidth, int texHeight, int &fuzzpos)
|
||||
FORCEINLINE unsigned int SampleShade32(int32_t u, int32_t v, const uint32_t *texPixels, int texWidth, int texHeight, int x, int y)
|
||||
{
|
||||
if (SamplerT::Mode == (int)Samplers::Shaded)
|
||||
{
|
||||
|
@ -140,12 +140,23 @@ namespace TriScreenDrawerModes
|
|||
}
|
||||
else if (SamplerT::Mode == (int)Samplers::Fuzz)
|
||||
{
|
||||
using namespace swrenderer;
|
||||
|
||||
uint32_t texelX = ((((uint32_t)u << 8) >> 16) * texWidth) >> 16;
|
||||
uint32_t texelY = ((((uint32_t)v << 8) >> 16) * texHeight) >> 16;
|
||||
unsigned int sampleshadeout = APART(texPixels[texelX * texHeight + texelY]);
|
||||
sampleshadeout += sampleshadeout >> 7; // 255 -> 256
|
||||
sampleshadeout = (sampleshadeout * fuzzcolormap[fuzzpos++]) >> 5;
|
||||
if (fuzzpos >= FUZZTABLE) fuzzpos = 0;
|
||||
|
||||
fixed_t fuzzscale = (200 << FRACBITS) / viewheight;
|
||||
|
||||
int scaled_x = (x * fuzzscale) >> FRACBITS;
|
||||
int fuzz_x = fuzz_random_x_offset[scaled_x % FUZZ_RANDOM_X_SIZE] + fuzzpos;
|
||||
|
||||
fixed_t fuzzcount = FUZZTABLE << FRACBITS;
|
||||
fixed_t fuzz = ((fuzz_x << FRACBITS) + y * fuzzscale) % fuzzcount;
|
||||
unsigned int alpha = fuzzoffset[fuzz >> FRACBITS];
|
||||
|
||||
sampleshadeout = (sampleshadeout * alpha) >> 5;
|
||||
return sampleshadeout;
|
||||
}
|
||||
else
|
||||
|
@ -373,8 +384,6 @@ private:
|
|||
uint32_t srcalpha = args->uniforms->SrcAlpha();
|
||||
uint32_t destalpha = args->uniforms->DestAlpha();
|
||||
|
||||
int fuzzpos = (ScreenTriangle::FuzzStart + destX * 123 + destY) % FUZZTABLE;
|
||||
|
||||
auto lights = args->uniforms->Lights();
|
||||
auto num_lights = args->uniforms->NumLights();
|
||||
FVector3 worldnormal = args->uniforms->Normal();
|
||||
|
@ -505,7 +514,7 @@ private:
|
|||
// Sample fgcolor
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = dest[ix];
|
||||
unsigned int ifgcolor = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
unsigned int ifgshade = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
unsigned int ifgshade = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + ix, destY + y);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
|
@ -608,7 +617,7 @@ private:
|
|||
// Sample fgcolor
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary && (mask0 & (1 << 31))) color = dest[x];
|
||||
unsigned int ifgcolor = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
unsigned int ifgshade = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
unsigned int ifgshade = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + x, destY + y);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
|
@ -711,7 +720,7 @@ private:
|
|||
// Sample fgcolor
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary && (mask1 & (1 << 31))) color = dest[x];
|
||||
unsigned int ifgcolor = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
unsigned int ifgshade = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
unsigned int ifgshade = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + x, destY + 4 + y);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
|
@ -773,7 +782,11 @@ public:
|
|||
{
|
||||
using namespace TriScreenDrawerModes;
|
||||
|
||||
if (args->SimpleShade())
|
||||
if (SamplerT::Mode == (int)Samplers::Fuzz)
|
||||
{
|
||||
Loop<NoShade, NearestFilter>(destOrg, destWidth, destHeight, destPitch, args, thread);
|
||||
}
|
||||
else if (args->SimpleShade())
|
||||
{
|
||||
Loop<SimpleShade, NearestFilter>(destOrg, destWidth, destHeight, destPitch, args, thread);
|
||||
}
|
||||
|
@ -869,15 +882,12 @@ private:
|
|||
|
||||
int count = x1 - x0;
|
||||
|
||||
int fuzzpos = (ScreenTriangle::FuzzStart + x0 * 123 + y0) % FUZZTABLE;
|
||||
|
||||
uint32_t posV = startV;
|
||||
for (int y = y0; y < y1; y++, posV += stepV)
|
||||
{
|
||||
int coreBlock = y / 8;
|
||||
if (coreBlock % thread->num_cores != thread->core)
|
||||
{
|
||||
fuzzpos = (fuzzpos + count) % FUZZTABLE;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -896,7 +906,7 @@ private:
|
|||
// Sample fgcolor
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = *dest;
|
||||
unsigned int ifgcolor = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
unsigned int ifgshade = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
unsigned int ifgshade = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, x0 + i, y);
|
||||
posU += stepU;
|
||||
|
||||
// Shade and blend
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace TriScreenDrawerModes
|
|||
}
|
||||
|
||||
template<typename SamplerT>
|
||||
FORCEINLINE unsigned int VECTORCALL SampleShade32(int32_t u, int32_t v, const uint32_t *texPixels, int texWidth, int texHeight, int &fuzzpos)
|
||||
FORCEINLINE unsigned int VECTORCALL SampleShade32(int32_t u, int32_t v, const uint32_t *texPixels, int texWidth, int texHeight, int x, int y)
|
||||
{
|
||||
if (SamplerT::Mode == (int)Samplers::Shaded)
|
||||
{
|
||||
|
@ -128,12 +128,23 @@ namespace TriScreenDrawerModes
|
|||
}
|
||||
else if (SamplerT::Mode == (int)Samplers::Fuzz)
|
||||
{
|
||||
using namespace swrenderer;
|
||||
|
||||
uint32_t texelX = ((((uint32_t)u << 8) >> 16) * texWidth) >> 16;
|
||||
uint32_t texelY = ((((uint32_t)v << 8) >> 16) * texHeight) >> 16;
|
||||
unsigned int sampleshadeout = APART(texPixels[texelX * texHeight + texelY]);
|
||||
sampleshadeout += sampleshadeout >> 7; // 255 -> 256
|
||||
sampleshadeout = (sampleshadeout * fuzzcolormap[fuzzpos++]) >> 5;
|
||||
if (fuzzpos >= FUZZTABLE) fuzzpos = 0;
|
||||
|
||||
fixed_t fuzzscale = (200 << FRACBITS) / viewheight;
|
||||
|
||||
int scaled_x = (x * fuzzscale) >> FRACBITS;
|
||||
int fuzz_x = fuzz_random_x_offset[scaled_x % FUZZ_RANDOM_X_SIZE] + fuzzpos;
|
||||
|
||||
fixed_t fuzzcount = FUZZTABLE << FRACBITS;
|
||||
fixed_t fuzz = ((fuzz_x << FRACBITS) + y * fuzzscale) % fuzzcount;
|
||||
unsigned int alpha = fuzzoffset[fuzz >> FRACBITS];
|
||||
|
||||
sampleshadeout = (sampleshadeout * alpha) >> 5;
|
||||
return sampleshadeout;
|
||||
}
|
||||
else
|
||||
|
@ -392,8 +403,6 @@ private:
|
|||
uint32_t srcalpha = args->uniforms->SrcAlpha();
|
||||
uint32_t destalpha = args->uniforms->DestAlpha();
|
||||
|
||||
int fuzzpos = (ScreenTriangle::FuzzStart + destX * 123 + destY) % FUZZTABLE;
|
||||
|
||||
auto lights = args->uniforms->Lights();
|
||||
auto num_lights = args->uniforms->NumLights();
|
||||
__m128 worldnormal = _mm_setr_ps(args->uniforms->Normal().X, args->uniforms->Normal().Y, args->uniforms->Normal().Z, 0.0f);
|
||||
|
@ -518,13 +527,13 @@ private:
|
|||
unsigned int ifgcolor[2], ifgshade[2];
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = dest[ix * 2];
|
||||
ifgcolor[0] = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
ifgshade[0] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + ix * 2, destY + y);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = dest[ix * 2 + 1];
|
||||
ifgcolor[1] = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[1] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
ifgshade[1] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + ix * 2 + 1, destY + y);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
|
@ -626,13 +635,13 @@ private:
|
|||
unsigned int ifgcolor[2], ifgshade[2];
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = dest[x * 2];
|
||||
ifgcolor[0] = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
ifgshade[0] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + x * 2, destY + y);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = dest[x * 2 + 1];
|
||||
ifgcolor[1] = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[1] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
ifgshade[1] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + x * 2 + 1, destY + y);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
|
@ -736,13 +745,13 @@ private:
|
|||
unsigned int ifgcolor[2], ifgshade[2];
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary && (mask1 & (1 << 31))) color = dest[x * 2];
|
||||
ifgcolor[0] = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
ifgshade[0] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + x * 2, destY + 4 + y);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary && (mask1 & (1 << 30))) color = dest[x * 2 + 1];
|
||||
ifgcolor[1] = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[1] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
ifgshade[1] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + x * 2 + 1, destY + 4 + y);
|
||||
posU += stepU;
|
||||
posV += stepV;
|
||||
|
||||
|
@ -889,15 +898,12 @@ private:
|
|||
int count = x1 - x0;
|
||||
int sseCount = count / 2;
|
||||
|
||||
int fuzzpos = (ScreenTriangle::FuzzStart + x0 * 123 + y0) % FUZZTABLE;
|
||||
|
||||
uint32_t posV = startV;
|
||||
for (int y = y0; y < y1; y++, posV += stepV)
|
||||
{
|
||||
int coreBlock = y / 8;
|
||||
if (coreBlock % thread->num_cores != thread->core)
|
||||
{
|
||||
fuzzpos = (fuzzpos + count) % FUZZTABLE;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -917,12 +923,12 @@ private:
|
|||
unsigned int ifgcolor[2], ifgshade[2];
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = dest[0];
|
||||
ifgcolor[0] = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
ifgshade[0] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, x0 + i * 2, y);
|
||||
posU += stepU;
|
||||
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = dest[1];
|
||||
ifgcolor[1] = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[1] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
ifgshade[1] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, x0 + i * 2 + 1, y);
|
||||
posU += stepU;
|
||||
|
||||
// Shade and blend
|
||||
|
@ -948,7 +954,7 @@ private:
|
|||
unsigned int ifgcolor[2], ifgshade[2];
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = *dest;
|
||||
ifgcolor[0] = Sample32<SamplerT, FilterModeT>(posU, posV, texPixels, texWidth, texHeight, oneU, oneV, color, translation);
|
||||
ifgshade[0] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
ifgshade[0] = SampleShade32<SamplerT>(posU, posV, texPixels, texWidth, texHeight, x0 + sseCount * 2, y);
|
||||
ifgcolor[1] = 0;
|
||||
ifgshade[1] = 0;
|
||||
posU += stepU;
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace TriScreenDrawerModes
|
|||
}
|
||||
|
||||
template<typename SamplerT>
|
||||
FORCEINLINE unsigned int SampleShade8(int32_t u, int32_t v, const uint8_t *texPixels, int texWidth, int texHeight, int &fuzzpos)
|
||||
FORCEINLINE unsigned int SampleShade8(int32_t u, int32_t v, const uint8_t *texPixels, int texWidth, int texHeight, int x, int y)
|
||||
{
|
||||
if (SamplerT::Mode == (int)Samplers::Shaded)
|
||||
{
|
||||
|
@ -97,11 +97,22 @@ namespace TriScreenDrawerModes
|
|||
}
|
||||
else if (SamplerT::Mode == (int)Samplers::Fuzz)
|
||||
{
|
||||
using namespace swrenderer;
|
||||
|
||||
uint32_t texelX = ((((uint32_t)u << 8) >> 16) * texWidth) >> 16;
|
||||
uint32_t texelY = ((((uint32_t)v << 8) >> 16) * texHeight) >> 16;
|
||||
unsigned int sampleshadeout = (texPixels[texelX * texHeight + texelY] != 0) ? 256 : 0;
|
||||
sampleshadeout = (sampleshadeout * fuzzcolormap[fuzzpos++]) >> 5;
|
||||
if (fuzzpos >= FUZZTABLE) fuzzpos = 0;
|
||||
|
||||
fixed_t fuzzscale = (200 << FRACBITS) / viewheight;
|
||||
|
||||
int scaled_x = (x * fuzzscale) >> FRACBITS;
|
||||
int fuzz_x = fuzz_random_x_offset[scaled_x % FUZZ_RANDOM_X_SIZE] + fuzzpos;
|
||||
|
||||
fixed_t fuzzcount = FUZZTABLE << FRACBITS;
|
||||
fixed_t fuzz = ((fuzz_x << FRACBITS) + y * fuzzscale) % fuzzcount;
|
||||
unsigned int alpha = fuzzoffset[fuzz >> FRACBITS];
|
||||
|
||||
sampleshadeout = (sampleshadeout * alpha) >> 5;
|
||||
return sampleshadeout;
|
||||
}
|
||||
else
|
||||
|
@ -228,8 +239,6 @@ public:
|
|||
uint32_t srcalpha = args->uniforms->SrcAlpha();
|
||||
uint32_t destalpha = args->uniforms->DestAlpha();
|
||||
|
||||
int fuzzpos = (ScreenTriangle::FuzzStart + destX * 123 + destY) % FUZZTABLE;
|
||||
|
||||
// Calculate gradients
|
||||
const ShadedTriVertex &v1 = *args->v1;
|
||||
ScreenTriangleStepVariables gradientX = args->gradientX;
|
||||
|
@ -292,7 +301,7 @@ public:
|
|||
uint8_t bgcolor = dest[ix];
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
||||
uint8_t fgcolor = Sample8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
||||
uint32_t fgshade = SampleShade8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
uint32_t fgshade = SampleShade8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + ix, destY + y);
|
||||
if (SamplerT::Mode == (int)Samplers::Fuzz) lightshade = 256;
|
||||
dest[ix] = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||
posU += stepU;
|
||||
|
@ -342,7 +351,7 @@ public:
|
|||
uint8_t bgcolor = dest[x];
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
||||
uint8_t fgcolor = Sample8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
||||
uint32_t fgshade = SampleShade8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
uint32_t fgshade = SampleShade8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + x, destY + y);
|
||||
if (SamplerT::Mode == (int)Samplers::Fuzz) lightshade = 256;
|
||||
dest[x] = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||
}
|
||||
|
@ -394,7 +403,7 @@ public:
|
|||
uint8_t bgcolor = dest[x];
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
||||
uint8_t fgcolor = Sample8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
||||
uint32_t fgshade = SampleShade8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
uint32_t fgshade = SampleShade8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, destX + x, destY + 4 + y);
|
||||
if (SamplerT::Mode == (int)Samplers::Fuzz) lightshade = 256;
|
||||
dest[x] = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||
}
|
||||
|
@ -458,15 +467,12 @@ public:
|
|||
|
||||
int count = x1 - x0;
|
||||
|
||||
int fuzzpos = (ScreenTriangle::FuzzStart + x0 * 123 + y0) % FUZZTABLE;
|
||||
|
||||
uint32_t posV = startV;
|
||||
for (int y = y0; y < y1; y++, posV += stepV)
|
||||
{
|
||||
int coreBlock = y / 8;
|
||||
if (coreBlock % thread->num_cores != thread->core)
|
||||
{
|
||||
fuzzpos = (fuzzpos + count) % FUZZTABLE;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -478,7 +484,7 @@ public:
|
|||
uint8_t bgcolor = *dest;
|
||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
||||
uint8_t fgcolor = Sample8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
||||
uint32_t fgshade = SampleShade8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, fuzzpos);
|
||||
uint32_t fgshade = SampleShade8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, x0 + i, y);
|
||||
*dest = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||
|
||||
posU += stepU;
|
||||
|
|
|
@ -119,6 +119,8 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
|||
P_FindParticleSubsectors();
|
||||
PO_LinkToSubsectors();
|
||||
|
||||
swrenderer::R_UpdateFuzzPosFrameStart();
|
||||
|
||||
if (APART(R_OldBlend)) NormalLight.Maps = realcolormaps.Maps;
|
||||
else NormalLight.Maps = realcolormaps.Maps + NUMCOLORMAPS * 256 * R_OldBlend;
|
||||
|
||||
|
|
|
@ -57,18 +57,17 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right)
|
|||
double thingxscalemul = spriteScale.X / tex->Scale.X;
|
||||
double thingyscalemul = spriteScale.Y / tex->Scale.Y;
|
||||
|
||||
if (flipTextureX)
|
||||
pos.X -= (tex->GetWidth() - tex->LeftOffset) * thingxscalemul;
|
||||
else
|
||||
pos.X -= tex->LeftOffset * thingxscalemul;
|
||||
|
||||
double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5;
|
||||
double spriteWidth = thingxscalemul * tex->GetWidth();
|
||||
double spriteHeight = thingyscalemul * tex->GetHeight();
|
||||
|
||||
pos.X += spriteHalfWidth;
|
||||
double offsetX;
|
||||
if (flipTextureX)
|
||||
offsetX = (tex->GetWidth() - tex->LeftOffset) * thingxscalemul;
|
||||
else
|
||||
offsetX = tex->LeftOffset * thingxscalemul;
|
||||
|
||||
left = DVector2(pos.X - viewpoint.Sin * spriteHalfWidth, pos.Y + viewpoint.Cos * spriteHalfWidth);
|
||||
right = DVector2(pos.X + viewpoint.Sin * spriteHalfWidth, pos.Y - viewpoint.Cos * spriteHalfWidth);
|
||||
left = DVector2(pos.X - viewpoint.Sin * offsetX, pos.Y + viewpoint.Cos * offsetX);
|
||||
right = DVector2(left.X + viewpoint.Sin * spriteWidth, left.Y - viewpoint.Cos * spriteWidth);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -81,36 +80,26 @@ void RenderPolySprite::Render(PolyRenderThread *thread, const TriMatrix &worldTo
|
|||
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||
DVector3 thingpos = thing->InterpolatedPosition(viewpoint.TicFrac);
|
||||
|
||||
DVector3 pos = thingpos;
|
||||
double posZ = thingpos.Z;
|
||||
|
||||
uint32_t spritetype = (thing->renderflags & RF_SPRITETYPEMASK);
|
||||
|
||||
if (spritetype == RF_FACESPRITE)
|
||||
pos.Z -= thing->Floorclip;
|
||||
posZ -= thing->Floorclip;
|
||||
|
||||
if (thing->flags2 & MF2_FLOATBOB)
|
||||
pos.Z += thing->GetBobOffset(viewpoint.TicFrac);
|
||||
posZ += thing->GetBobOffset(viewpoint.TicFrac);
|
||||
|
||||
bool flipTextureX = false;
|
||||
FTexture *tex = GetSpriteTexture(thing, flipTextureX);
|
||||
if (tex == nullptr || tex->UseType == FTexture::TEX_Null)
|
||||
return;
|
||||
|
||||
DVector2 spriteScale = thing->Scale;
|
||||
double thingxscalemul = spriteScale.X / tex->Scale.X;
|
||||
double thingyscalemul = spriteScale.Y / tex->Scale.Y;
|
||||
double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5;
|
||||
double thingyscalemul = thing->Scale.Y / tex->Scale.Y;
|
||||
double spriteHeight = thingyscalemul * tex->GetHeight();
|
||||
|
||||
if (flipTextureX)
|
||||
pos.X -= (tex->GetWidth() - tex->LeftOffset) * thingxscalemul;
|
||||
else
|
||||
pos.X -= tex->LeftOffset * thingxscalemul;
|
||||
|
||||
pos.X += spriteHalfWidth;
|
||||
|
||||
pos.Z -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul;
|
||||
pos.Z = PerformSpriteClipAdjustment(thing, thingpos, spriteHeight, pos.Z);
|
||||
posZ -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul;
|
||||
posZ = PerformSpriteClipAdjustment(thing, thingpos, spriteHeight, posZ);
|
||||
|
||||
//double depth = 1.0;
|
||||
//visstyle_t visstyle = GetSpriteVisStyle(thing, depth);
|
||||
|
@ -142,7 +131,7 @@ void RenderPolySprite::Render(PolyRenderThread *thread, const TriMatrix &worldTo
|
|||
|
||||
vertices[i].x = (float)p.X;
|
||||
vertices[i].y = (float)p.Y;
|
||||
vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second);
|
||||
vertices[i].z = (float)(posZ + spriteHeight * offsets[i].second);
|
||||
vertices[i].w = 1.0f;
|
||||
vertices[i].u = (float)(offsets[i].first * tex->Scale.X);
|
||||
vertices[i].v = (float)((1.0f - offsets[i].second) * tex->Scale.Y);
|
||||
|
|
|
@ -193,9 +193,9 @@ namespace swrenderer
|
|||
|
||||
void R_UpdateFuzzPosFrameStart()
|
||||
{
|
||||
if (r_fuzzscale)
|
||||
if (r_fuzzscale || r_polyrenderer)
|
||||
{
|
||||
int next_random = 0;
|
||||
static int next_random = 0;
|
||||
|
||||
fuzzpos = (fuzzpos + fuzz_random_x_offset[next_random] * FUZZTABLE / 100) % FUZZTABLE;
|
||||
|
||||
|
@ -207,7 +207,7 @@ namespace swrenderer
|
|||
|
||||
void R_UpdateFuzzPos(const SpriteDrawerArgs &args)
|
||||
{
|
||||
if (!r_fuzzscale)
|
||||
if (!r_fuzzscale && !r_polyrenderer)
|
||||
{
|
||||
int yl = MAX(args.FuzzY1(), 1);
|
||||
int yh = MIN(args.FuzzY2(), fuzzviewheight);
|
||||
|
|
|
@ -651,6 +651,7 @@ struct TVector3
|
|||
TVector3 &operator ^= (const TVector3 &other)
|
||||
{
|
||||
*this = *this ^ other;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1223,7 +1223,7 @@ void D3DFB::Flip()
|
|||
{
|
||||
RECT box;
|
||||
GetClientRect(Window, &box);
|
||||
if (box.right > 0 && box.right > 0 && (Width != box.right || Height != box.bottom))
|
||||
if (box.right > 0 && box.bottom > 0 && (Width != box.right || Height != box.bottom))
|
||||
{
|
||||
Resize(box.right, box.bottom);
|
||||
|
||||
|
|
Loading…
Reference in a new issue