mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-17 01:31:25 +00:00
- Added scaled fuzz to softpoly pal drawer
This commit is contained in:
parent
f04fca75f7
commit
9052ee6bc8
1 changed files with 18 additions and 18 deletions
|
@ -79,7 +79,7 @@ namespace TriScreenDrawerModes
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename SamplerT>
|
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)
|
if (SamplerT::Mode == (int)Samplers::Shaded)
|
||||||
{
|
{
|
||||||
|
@ -97,11 +97,22 @@ namespace TriScreenDrawerModes
|
||||||
}
|
}
|
||||||
else if (SamplerT::Mode == (int)Samplers::Fuzz)
|
else if (SamplerT::Mode == (int)Samplers::Fuzz)
|
||||||
{
|
{
|
||||||
|
using namespace swrenderer;
|
||||||
|
|
||||||
uint32_t texelX = ((((uint32_t)u << 8) >> 16) * texWidth) >> 16;
|
uint32_t texelX = ((((uint32_t)u << 8) >> 16) * texWidth) >> 16;
|
||||||
uint32_t texelY = ((((uint32_t)v << 8) >> 16) * texHeight) >> 16;
|
uint32_t texelY = ((((uint32_t)v << 8) >> 16) * texHeight) >> 16;
|
||||||
unsigned int sampleshadeout = (texPixels[texelX * texHeight + texelY] != 0) ? 256 : 0;
|
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;
|
return sampleshadeout;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -228,8 +239,6 @@ public:
|
||||||
uint32_t srcalpha = args->uniforms->SrcAlpha();
|
uint32_t srcalpha = args->uniforms->SrcAlpha();
|
||||||
uint32_t destalpha = args->uniforms->DestAlpha();
|
uint32_t destalpha = args->uniforms->DestAlpha();
|
||||||
|
|
||||||
int fuzzpos = (ScreenTriangle::FuzzStart + destX * 123 + destY) % FUZZTABLE;
|
|
||||||
|
|
||||||
// Calculate gradients
|
// Calculate gradients
|
||||||
const ShadedTriVertex &v1 = *args->v1;
|
const ShadedTriVertex &v1 = *args->v1;
|
||||||
ScreenTriangleStepVariables gradientX = args->gradientX;
|
ScreenTriangleStepVariables gradientX = args->gradientX;
|
||||||
|
@ -292,7 +301,7 @@ public:
|
||||||
uint8_t bgcolor = dest[ix];
|
uint8_t bgcolor = dest[ix];
|
||||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
||||||
uint8_t fgcolor = Sample8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
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;
|
if (SamplerT::Mode == (int)Samplers::Fuzz) lightshade = 256;
|
||||||
dest[ix] = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
dest[ix] = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||||
posU += stepU;
|
posU += stepU;
|
||||||
|
@ -342,7 +351,7 @@ public:
|
||||||
uint8_t bgcolor = dest[x];
|
uint8_t bgcolor = dest[x];
|
||||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
||||||
uint8_t fgcolor = Sample8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
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;
|
if (SamplerT::Mode == (int)Samplers::Fuzz) lightshade = 256;
|
||||||
dest[x] = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
dest[x] = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||||
}
|
}
|
||||||
|
@ -394,7 +403,7 @@ public:
|
||||||
uint8_t bgcolor = dest[x];
|
uint8_t bgcolor = dest[x];
|
||||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
||||||
uint8_t fgcolor = Sample8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
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;
|
if (SamplerT::Mode == (int)Samplers::Fuzz) lightshade = 256;
|
||||||
dest[x] = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
dest[x] = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||||
}
|
}
|
||||||
|
@ -458,18 +467,9 @@ public:
|
||||||
|
|
||||||
int count = x1 - x0;
|
int count = x1 - x0;
|
||||||
|
|
||||||
int fuzzpos = (ScreenTriangle::FuzzStart + x0 * 123 + y0) % FUZZTABLE;
|
|
||||||
|
|
||||||
uint32_t posV = startV;
|
uint32_t posV = startV;
|
||||||
for (int y = y0; y < y1; y++, posV += stepV)
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t *dest = ((uint8_t*)destOrg) + y * destPitch + x0;
|
uint8_t *dest = ((uint8_t*)destOrg) + y * destPitch + x0;
|
||||||
|
|
||||||
uint32_t posU = startU;
|
uint32_t posU = startU;
|
||||||
|
@ -478,7 +478,7 @@ public:
|
||||||
uint8_t bgcolor = *dest;
|
uint8_t bgcolor = *dest;
|
||||||
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
if (SamplerT::Mode == (int)Samplers::FogBoundary) color = bgcolor;
|
||||||
uint8_t fgcolor = Sample8<SamplerT>(posU, posV, texPixels, texWidth, texHeight, color, translation);
|
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);
|
*dest = ShadeAndBlend8<BlendT>(fgcolor, bgcolor, fgshade, lightshade, colormaps, srcalpha, destalpha);
|
||||||
|
|
||||||
posU += stepU;
|
posU += stepU;
|
||||||
|
|
Loading…
Reference in a new issue