Make particle texture slightly higher quality

This commit is contained in:
Magnus Norddahl 2017-01-13 16:12:43 +01:00
parent edd9b6c69c
commit ca046d26c5
5 changed files with 18 additions and 16 deletions

View File

@ -65,7 +65,7 @@ namespace swrenderer
int fuzzpos; int fuzzpos;
int fuzzviewheight; int fuzzviewheight;
uint32_t particle_texture[16 * 16]; uint32_t particle_texture[PARTICLE_TEXTURE_SIZE * PARTICLE_TEXTURE_SIZE];
short zeroarray[MAXWIDTH]; short zeroarray[MAXWIDTH];
short screenheightarray[MAXWIDTH]; short screenheightarray[MAXWIDTH];
@ -237,16 +237,17 @@ namespace swrenderer
void R_InitParticleTexture() void R_InitParticleTexture()
{ {
for (int y = 0; y < 16; y++) float center = PARTICLE_TEXTURE_SIZE * 0.5f;
for (int y = 0; y < PARTICLE_TEXTURE_SIZE; y++)
{ {
for (int x = 0; x < 16; x++) for (int x = 0; x < PARTICLE_TEXTURE_SIZE; x++)
{ {
float dx = (8 - x) / 8.0f; float dx = (center - x - 0.5f) / center;
float dy = (8 - y) / 8.0f; float dy = (center - y - 0.5f) / center;
float dist = sqrt(dx * dx + dy * dy); float dist2 = dx * dx + dy * dy;
float alpha = clamp(3.0f - dist * 3.0f, 0.0f, 1.0f); float alpha = clamp(1.1f - dist2 * 1.1f, 0.0f, 1.0f);
particle_texture[x + y * 16] = (int)(alpha * 64.0f + 0.5f); particle_texture[x + y * PARTICLE_TEXTURE_SIZE] = (int)(alpha * 128.0f + 0.5f);
} }
} }
} }

View File

@ -121,7 +121,8 @@ namespace swrenderer
extern int fuzzpos; extern int fuzzpos;
extern int fuzzviewheight; extern int fuzzviewheight;
extern uint32_t particle_texture[16 * 16]; #define PARTICLE_TEXTURE_SIZE 64
extern uint32_t particle_texture[PARTICLE_TEXTURE_SIZE * PARTICLE_TEXTURE_SIZE];
extern bool r_swtruecolor; extern bool r_swtruecolor;

View File

@ -2788,10 +2788,10 @@ namespace swrenderer
uint8_t *dest = thread->dest_for_thread(_dest_y, _pitch, _dest); uint8_t *dest = thread->dest_for_thread(_dest_y, _pitch, _dest);
int pitch = _pitch * thread->num_cores; int pitch = _pitch * thread->num_cores;
const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * 16]; const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE];
uint32_t particle_alpha = _alpha; uint32_t particle_alpha = _alpha;
uint32_t fracstep = 16 * FRACUNIT / _count; uint32_t fracstep = PARTICLE_TEXTURE_SIZE * FRACUNIT / _count;
uint32_t fracpos = fracstep * thread->skipped_by_thread(_dest_y) + fracstep / 2; uint32_t fracpos = fracstep * thread->skipped_by_thread(_dest_y) + fracstep / 2;
fracstep *= thread->num_cores; fracstep *= thread->num_cores;
@ -2801,7 +2801,7 @@ namespace swrenderer
for (int y = 0; y < count; y++) for (int y = 0; y < count; y++)
{ {
uint32_t alpha = (source[fracpos >> FRACBITS] * particle_alpha) >> 6; uint32_t alpha = (source[fracpos >> FRACBITS] * particle_alpha) >> 7;
uint32_t inv_alpha = 256 - alpha; uint32_t inv_alpha = 256 - alpha;
int bg = *dest; int bg = *dest;

View File

@ -962,10 +962,10 @@ namespace swrenderer
uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, _dest); uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, _dest);
int pitch = _pitch * thread->num_cores; int pitch = _pitch * thread->num_cores;
const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * 16]; const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE];
uint32_t particle_alpha = _alpha; uint32_t particle_alpha = _alpha;
uint32_t fracstep = 16 * FRACUNIT / _count; uint32_t fracstep = PARTICLE_TEXTURE_SIZE * FRACUNIT / _count;
uint32_t fracpos = fracstep * thread->skipped_by_thread(_dest_y) + fracstep / 2; uint32_t fracpos = fracstep * thread->skipped_by_thread(_dest_y) + fracstep / 2;
fracstep *= thread->num_cores; fracstep *= thread->num_cores;
@ -975,7 +975,7 @@ namespace swrenderer
for (int y = 0; y < count; y++) for (int y = 0; y < count; y++)
{ {
uint32_t alpha = (source[fracpos >> FRACBITS] * particle_alpha) >> 6; uint32_t alpha = (source[fracpos >> FRACBITS] * particle_alpha) >> 7;
uint32_t inv_alpha = 256 - alpha; uint32_t inv_alpha = 256 - alpha;
uint32_t bg_red = (*dest >> 16) & 0xff; uint32_t bg_red = (*dest >> 16) & 0xff;

View File

@ -249,7 +249,7 @@ namespace swrenderer
spacing = RenderTarget->GetPitch(); spacing = RenderTarget->GetPitch();
uint32_t fracstepx = 16 * FRACUNIT / countbase; uint32_t fracstepx = PARTICLE_TEXTURE_SIZE * FRACUNIT / countbase;
uint32_t fracposx = fracstepx / 2; uint32_t fracposx = fracstepx / 2;
if (r_swtruecolor) if (r_swtruecolor)