mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +00:00
- add support for choosing the particle style in the software renderer
This commit is contained in:
parent
5f44bc4d5f
commit
ad992d2ffd
4 changed files with 15 additions and 6 deletions
|
@ -64,7 +64,7 @@ namespace swrenderer
|
||||||
int fuzzpos;
|
int fuzzpos;
|
||||||
int fuzzviewheight;
|
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 zeroarray[MAXWIDTH];
|
||||||
short screenheightarray[MAXWIDTH];
|
short screenheightarray[MAXWIDTH];
|
||||||
|
@ -139,6 +139,8 @@ namespace swrenderer
|
||||||
|
|
||||||
void R_InitParticleTexture()
|
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;
|
double center = PARTICLE_TEXTURE_SIZE * 0.5f;
|
||||||
for (int y = 0; y < PARTICLE_TEXTURE_SIZE; y++)
|
for (int y = 0; y < PARTICLE_TEXTURE_SIZE; y++)
|
||||||
{
|
{
|
||||||
|
@ -147,9 +149,12 @@ namespace swrenderer
|
||||||
double dx = (center - x - 0.5f) / center;
|
double dx = (center - x - 0.5f) / center;
|
||||||
double dy = (center - y - 0.5f) / center;
|
double dy = (center - y - 0.5f) / center;
|
||||||
double dist2 = dx * dx + dy * dy;
|
double dist2 = dx * dx + dy * dy;
|
||||||
double alpha = clamp<double>(1.1f - dist2 * 1.1f, 0.0f, 1.0f);
|
double round_alpha = clamp<double>(1.7f - dist2 * 1.7f, 0.0f, 1.0f);
|
||||||
|
double smooth_alpha = clamp<double>(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,9 @@ namespace swrenderer
|
||||||
extern int fuzzpos;
|
extern int fuzzpos;
|
||||||
extern int fuzzviewheight;
|
extern int fuzzviewheight;
|
||||||
|
|
||||||
|
#define NUM_PARTICLE_TEXTURES 3
|
||||||
#define PARTICLE_TEXTURE_SIZE 64
|
#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
|
class SWPixelFormatDrawers
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
|
|
||||||
// [SP] r_blendmethod - false = rgb555 matching (ZDoom classic), true = rgb666 (refactored)
|
// [SP] r_blendmethod - false = rgb555 matching (ZDoom classic), true = rgb666 (refactored)
|
||||||
CVAR(Bool, r_blendmethod, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
|
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
|
[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);
|
uint8_t *dest = thread->dest_for_thread(_dest_y, pitch, _dest);
|
||||||
pitch = pitch * thread->num_cores;
|
pitch = pitch * thread->num_cores;
|
||||||
|
|
||||||
const uint32_t *source = &particle_texture[(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE];
|
int particle_texture_index = MIN<int>(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 particle_alpha = _alpha;
|
||||||
|
|
||||||
uint32_t fracstep = PARTICLE_TEXTURE_SIZE * FRACUNIT / _count;
|
uint32_t fracstep = PARTICLE_TEXTURE_SIZE * FRACUNIT / _count;
|
||||||
|
|
|
@ -780,7 +780,8 @@ 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) * PARTICLE_TEXTURE_SIZE];
|
int particle_texture_index = MIN<int>(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 particle_alpha = _alpha;
|
||||||
|
|
||||||
uint32_t fracstep = PARTICLE_TEXTURE_SIZE * FRACUNIT / _count;
|
uint32_t fracstep = PARTICLE_TEXTURE_SIZE * FRACUNIT / _count;
|
||||||
|
|
Loading…
Reference in a new issue