diff --git a/src/swrenderer/drawers/r_draw.cpp b/src/swrenderer/drawers/r_draw.cpp index a4467266e3..1f7b2d560d 100644 --- a/src/swrenderer/drawers/r_draw.cpp +++ b/src/swrenderer/drawers/r_draw.cpp @@ -64,7 +64,7 @@ namespace swrenderer int fuzzpos; int fuzzviewheight; - uint32_t particle_texture[PARTICLE_TEXTURE_SIZE * PARTICLE_TEXTURE_SIZE]; + uint32_t particle_texture[NUM_PARTICLE_TEXTURES][PARTICLE_TEXTURE_SIZE * PARTICLE_TEXTURE_SIZE]; short zeroarray[MAXWIDTH]; short screenheightarray[MAXWIDTH]; @@ -139,6 +139,8 @@ namespace swrenderer void R_InitParticleTexture() { + static_assert(NUM_PARTICLE_TEXTURES == 3, "R_InitParticleTexture must be updated if NUM_PARTICLE_TEXTURES is changed"); + double center = PARTICLE_TEXTURE_SIZE * 0.5f; for (int y = 0; y < PARTICLE_TEXTURE_SIZE; y++) { @@ -147,9 +149,12 @@ namespace swrenderer double dx = (center - x - 0.5f) / center; double dy = (center - y - 0.5f) / center; double dist2 = dx * dx + dy * dy; - double alpha = clamp(1.1f - dist2 * 1.1f, 0.0f, 1.0f); + double round_alpha = clamp(1.7f - dist2 * 1.7f, 0.0f, 1.0f); + double smooth_alpha = clamp(1.1f - dist2 * 1.1f, 0.0f, 1.0f); - particle_texture[x + y * PARTICLE_TEXTURE_SIZE] = (int)(alpha * 128.0f + 0.5f); + particle_texture[0][x + y * PARTICLE_TEXTURE_SIZE] = 128; + particle_texture[1][x + y * PARTICLE_TEXTURE_SIZE] = (int)(round_alpha * 128.0f + 0.5f); + particle_texture[2][x + y * PARTICLE_TEXTURE_SIZE] = (int)(smooth_alpha * 128.0f + 0.5f); } } } diff --git a/src/swrenderer/drawers/r_draw.h b/src/swrenderer/drawers/r_draw.h index 5c37873c85..e9b893aba6 100644 --- a/src/swrenderer/drawers/r_draw.h +++ b/src/swrenderer/drawers/r_draw.h @@ -44,8 +44,9 @@ namespace swrenderer extern int fuzzpos; extern int fuzzviewheight; + #define NUM_PARTICLE_TEXTURES 3 #define PARTICLE_TEXTURE_SIZE 64 - extern uint32_t particle_texture[PARTICLE_TEXTURE_SIZE * PARTICLE_TEXTURE_SIZE]; + extern uint32_t particle_texture[NUM_PARTICLE_TEXTURES][PARTICLE_TEXTURE_SIZE * PARTICLE_TEXTURE_SIZE]; class SWPixelFormatDrawers { diff --git a/src/swrenderer/drawers/r_draw_pal.cpp b/src/swrenderer/drawers/r_draw_pal.cpp index 522eb51b15..3f75a30ac8 100644 --- a/src/swrenderer/drawers/r_draw_pal.cpp +++ b/src/swrenderer/drawers/r_draw_pal.cpp @@ -48,6 +48,7 @@ // [SP] r_blendmethod - false = rgb555 matching (ZDoom classic), true = rgb666 (refactored) CVAR(Bool, r_blendmethod, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE) +EXTERN_CVAR(Int, gl_particles_style) /* [RH] This translucency algorithm is based on DOSDoom 0.65's, but uses @@ -2946,7 +2947,8 @@ namespace swrenderer uint8_t *dest = thread->dest_for_thread(_dest_y, pitch, _dest); pitch = pitch * thread->num_cores; - const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE]; + int particle_texture_index = MIN(gl_particles_style, NUM_PARTICLE_TEXTURES - 1); + const uint32_t *source = &particle_texture[particle_texture_index][(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE]; uint32_t particle_alpha = _alpha; uint32_t fracstep = PARTICLE_TEXTURE_SIZE * FRACUNIT / _count; diff --git a/src/swrenderer/drawers/r_draw_rgba.cpp b/src/swrenderer/drawers/r_draw_rgba.cpp index 453071eaef..3dbd38f46b 100644 --- a/src/swrenderer/drawers/r_draw_rgba.cpp +++ b/src/swrenderer/drawers/r_draw_rgba.cpp @@ -780,7 +780,8 @@ namespace swrenderer uint32_t *dest = thread->dest_for_thread(_dest_y, _pitch, _dest); int pitch = _pitch * thread->num_cores; - const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE]; + int particle_texture_index = MIN(gl_particles_style, NUM_PARTICLE_TEXTURES - 1); + const uint32_t *source = &particle_texture[particle_texture_index][(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE]; uint32_t particle_alpha = _alpha; uint32_t fracstep = PARTICLE_TEXTURE_SIZE * FRACUNIT / _count;