GL1: Particle improvements

* When using gl_pointparameters, the particles always had the same size
  regardless of resolution, i.e. they look bigger (use bigger part of
  screen) at lower resolutions. Now I scale gl_particle_size according
  to the resolution, assuming the configured size looks good at 800x600
  (or generally 600px vertical)
* When not using gl_pointparameters, a textured triangle is rendered.
  The texture had a resolution of 8x8 pixels and looked like a cross,
  now it's 16x16 and has rounded ages, looking more like a circle.
  So particles with "gl_pointparameters 0" should look much better now.
This commit is contained in:
Daniel Gibson 2017-02-26 00:10:34 +01:00
parent c4c21075a4
commit b7bf822e6d
2 changed files with 42 additions and 25 deletions

View file

@ -533,7 +533,8 @@ R_DrawParticles(void)
glEnable(GL_BLEND); glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glPointSize(LittleFloat(gl_particle_size->value)); // assume the particle size looks good with window height 600px and scale according to real resolution
glPointSize(gl_particle_size->value * (float)r_newrefdef.height/600.0f);
for ( i = 0, p = r_newrefdef.particles; i < r_newrefdef.num_particles; i++, p++ ) for ( i = 0, p = r_newrefdef.particles; i < r_newrefdef.num_particles; i++, p++ )
{ {

View file

@ -26,15 +26,30 @@
#include "header/local.h" #include "header/local.h"
byte dottexture[8][8] = { static byte dottexture[16][16] = {
{0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 0, 0}, {0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 0, 0, 0}, {0, 1, 3, 3, 3, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 0, 0, 0}, {0, 2, 3, 3, 3, 3, 3, 3, 2, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 0, 0}, {0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}, {0, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}, {0, 2, 3, 3, 3, 3, 3, 3, 2, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 3, 3, 3, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
static byte notex[4][4] = {
{0, 0, 0, 0},
{0, 0, 1, 1},
{0, 1, 1, 1},
{0, 1, 1, 1}
}; };
typedef struct _TargaHeader typedef struct _TargaHeader
@ -50,37 +65,38 @@ void
R_InitParticleTexture(void) R_InitParticleTexture(void)
{ {
int x, y; int x, y;
byte data[8][8][4]; byte partData[16][16][4];
byte notexData[8][8][4];
/* particle texture */ /* particle texture */
for (x = 0; x < 8; x++) for (x = 0; x < 16; x++)
{ {
for (y = 0; y < 8; y++) for (y = 0; y < 16; y++)
{ {
data[y][x][0] = 255; partData[y][x][0] = 255;
data[y][x][1] = 255; partData[y][x][1] = 255;
data[y][x][2] = 255; partData[y][x][2] = 255;
data[y][x][3] = dottexture[x][y] * 255; partData[y][x][3] = dottexture[x][y] * 85;
} }
} }
r_particletexture = R_LoadPic("***particle***", (byte *)data, r_particletexture = R_LoadPic("***particle***", (byte *)partData,
8, 0, 8, 0, it_sprite, 32); 16, 0, 16, 0, it_sprite, 32);
/* also use this for bad textures, but without alpha */ /* also use this for bad textures, but without alpha */
for (x = 0; x < 8; x++) for (x = 0; x < 8; x++)
{ {
for (y = 0; y < 8; y++) for (y = 0; y < 8; y++)
{ {
data[y][x][0] = dottexture[x & 3][y & 3] * 255; notexData[y][x][0] = notex[x & 3][y & 3] * 255;
data[y][x][1] = 0; notexData[y][x][1] = 0;
data[y][x][2] = 0; notexData[y][x][2] = 0;
data[y][x][3] = 255; notexData[y][x][3] = 255;
} }
} }
r_notexture = R_LoadPic("***r_notexture***", (byte *)data, r_notexture = R_LoadPic("***r_notexture***", (byte *)notexData,
8, 0, 8, 0, it_wall, 32); 8, 0, 8, 0, it_wall, 32);
} }
void void