- change fuzzing to not do any offsetting but keep the shading pattern produced by it

This commit is contained in:
Magnus Norddahl 2017-04-03 19:11:38 +02:00
parent d3ef3b585b
commit 5c5e3bdcba
3 changed files with 79 additions and 3 deletions

View file

@ -131,10 +131,27 @@ namespace swrenderer
1, 1,-1, 1, 1,-1, 1
};
#ifdef ORIGINAL_FUZZ
for (int i = 0; i < FUZZTABLE; i++)
{
fuzzoffset[i] = fuzzinit[i] * fuzzoff;
}
#else
int8_t fuzzcount[FUZZTABLE + 1];
for (int i = 0; i < FUZZTABLE + 1; i++) fuzzcount[i] = 0;
fuzzcount[0] = 1;
for (int i = 1; i < FUZZTABLE; i++)
fuzzcount[i] = fuzzcount[i + fuzzinit[i]] + 1;
for (int i = 0; i < FUZZTABLE; i++)
{
float shade = 1.0f - 6.0f / NUMCOLORMAPS;
float resultshade = 1.0;
for (int j = 0; j < fuzzcount[i]; j++)
resultshade *= shade;
fuzzoffset[i] = clamp((int)((1.0f - resultshade) * NUMCOLORMAPS + 0.5f), 0, NUMCOLORMAPS - 1);
}
#endif
}
void R_InitParticleTexture()

View file

@ -1858,8 +1858,6 @@ namespace swrenderer
if (count <= 0)
return;
uint8_t *map = &NormalLight.Maps[6 * 256];
int pitch = _pitch;
uint8_t *dest = thread->dest_for_thread(yl, pitch, yl * pitch + _x + _destorg);
@ -1867,6 +1865,35 @@ namespace swrenderer
int fuzzstep = thread->num_cores;
int fuzz = (_fuzzpos + thread->skipped_by_thread(yl)) % FUZZTABLE;
#ifndef ORIGINAL_FUZZ
uint8_t *map = NormalLight.Maps;
while (count > 0)
{
int available = (FUZZTABLE - fuzz);
int next_wrap = available / fuzzstep;
if (available % fuzzstep != 0)
next_wrap++;
int cnt = MIN(count, next_wrap);
count -= cnt;
do
{
int offset = fuzzoffset[fuzz] << 8;
*dest = map[offset + *dest];
dest += pitch;
fuzz += fuzzstep;
} while (--cnt);
fuzz %= FUZZTABLE;
}
#else
uint8_t *map = &NormalLight.Maps[6 * 256];
yl += thread->skipped_by_thread(yl);
// Handle the case where we would go out of bounds at the top:
@ -1920,6 +1947,7 @@ namespace swrenderer
*dest = map[*srcdest];
}
#endif
}
/////////////////////////////////////////////////////////////////////////

View file

@ -255,11 +255,41 @@ namespace swrenderer
return;
uint32_t *dest = thread->dest_for_thread(yl, _pitch, _pitch * yl + _x + (uint32_t*)_destorg);
int pitch = _pitch * thread->num_cores;
int fuzzstep = thread->num_cores;
int fuzz = (_fuzzpos + thread->skipped_by_thread(yl)) % FUZZTABLE;
#ifndef ORIGINAL_FUZZ
while (count > 0)
{
int available = (FUZZTABLE - fuzz);
int next_wrap = available / fuzzstep;
if (available % fuzzstep != 0)
next_wrap++;
int cnt = MIN(count, next_wrap);
count -= cnt;
do
{
int alpha = 32 - fuzzoffset[fuzz];
uint32_t bg = *dest;
uint32_t red = (RPART(bg) * alpha) >> 5;
uint32_t green = (GPART(bg) * alpha) >> 5;
uint32_t blue = (BPART(bg) * alpha) >> 5;
*dest = 0xff000000 | (red << 16) | (green << 8) | blue;
dest += pitch;
fuzz += fuzzstep;
} while (--cnt);
fuzz %= FUZZTABLE;
}
#else
yl += thread->skipped_by_thread(yl);
// Handle the case where we would go out of bounds at the top:
@ -331,6 +361,7 @@ namespace swrenderer
*dest = 0xff000000 | (red << 16) | (green << 8) | blue;
}
#endif
}
FString DrawFuzzColumnRGBACommand::DebugInfo()