GL3: gl3_particle_fade_factor cvar to configure particle softness

the higher it is, the less soft (more like in GL1) the particles look

While at it, I removed lmOffset from uni3D, as it's not used.
This commit is contained in:
Daniel Gibson 2017-04-10 19:04:59 +02:00
parent e510bfc281
commit b916d11662
3 changed files with 27 additions and 10 deletions

View file

@ -98,6 +98,7 @@ cvar_t *gl_texturemode;
cvar_t *gl_drawbuffer;
cvar_t *gl_clear;
cvar_t *gl3_particle_size;
cvar_t *gl3_particle_fade_factor;
cvar_t *gl_lefthand;
cvar_t *gl_farsee;
@ -208,6 +209,7 @@ GL3_Register(void)
gl_customwidth = ri.Cvar_Get("gl_customwidth", "1024", CVAR_ARCHIVE);
gl_customheight = ri.Cvar_Get("gl_customheight", "768", CVAR_ARCHIVE);
gl3_particle_size = ri.Cvar_Get("gl3_particle_size", "60", CVAR_ARCHIVE);
gl3_particle_fade_factor = ri.Cvar_Get("gl3_particle_fade_factor", "1.2", CVAR_ARCHIVE);
gl_norefresh = ri.Cvar_Get("gl_norefresh", "0", 0);
gl_drawentities = ri.Cvar_Get("gl_drawentities", "1", 0);
@ -1640,6 +1642,14 @@ GL3_BeginFrame(float camera_separation)
GL3_UpdateUBO3D();
}
if(gl3_particle_fade_factor->modified)
{
gl3_particle_fade_factor->modified = false;
gl3state.uni3DData.particleFadeFactor = gl3_particle_fade_factor->value;
GL3_UpdateUBO3D();
}
/* go into 2D mode */
GL3_SetGL2D();

View file

@ -273,12 +273,15 @@ static const char* vertexCommon3D = MULTILINE_STRING(#version 150\n
mat4 transProj;
mat4 transView;
mat4 transModel;
vec2 lmOffset;
float scroll; // for SURF_FLOWING
float time;
float alpha;
float overbrightbits;
vec2 _padding; // AMDs legacy windows driver needs this, otherwise uni3D has wrong size
float particleFadeFactor;
float _pad_1; // AMDs legacy windows driver needs this, otherwise uni3D has wrong size
float _pad_2;
float _pad_3;
};
);
@ -303,12 +306,15 @@ static const char* fragmentCommon3D = MULTILINE_STRING(#version 150\n
mat4 transProj;
mat4 transView;
mat4 transModel;
vec2 lmOffset;
float scroll; // for SURF_FLOWING
float time;
float alpha;
float overbrightbits;
vec2 _padding; // AMDs legacy windows driver needs this, otherwise uni3D has wrong size
float particleFadeFactor;
float _pad_1; // AMDs legacy windows driver needs this, otherwise uni3D has wrong size
float _pad_2;
float _pad_3;
};
);
@ -676,7 +682,7 @@ static const char* fragmentSrcParticles = MULTILINE_STRING(
outColor.rgb = pow(texel.rgb, vec3(gamma));
// I want the particles to fade out towards the edge, the following seems to look nice
texel.a *= min(1.0, 1.2*(1.0 - distSquared));
texel.a *= min(1.0, particleFadeFactor*(1.0 - distSquared));
outColor.a = texel.a; // I think alpha shouldn't be modified by gamma and intensity
}
@ -848,6 +854,7 @@ initShader3D(gl3ShaderInfo_t* shaderInfo, const char* vertSrc, const char* fragS
if(blockSize != sizeof(gl3state.uni3DData))
{
R_Printf(PRINT_ALL, "WARNING: OpenGL driver disagrees with us about UBO size of 'uni3D'\n");
R_Printf(PRINT_ALL, " driver says %d, we expect %d\n", blockSize, (int)sizeof(gl3state.uni3DData));
goto err_cleanup;
}
@ -948,12 +955,12 @@ static void initUBOs(void)
gl3state.uni3DData.transProjMat4 = HMM_Mat4();
gl3state.uni3DData.transViewMat4 = HMM_Mat4();
gl3state.uni3DData.transModelMat4 = gl3_identityMat4;
gl3state.uni3DData.lmOffset = HMM_Vec2(0.0f, 0.0f);
gl3state.uni3DData.scroll = 0.0f;
gl3state.uni3DData.time = 0.0f;
gl3state.uni3DData.alpha = 1.0f;
// gl_overbrightbits 0 means "no scaling" which is equivalent to multiplying with 1
gl3state.uni3DData.overbrightbits = (gl3_overbrightbits->value <= 0.0f) ? 1.0f : gl3_overbrightbits->value;
gl3state.uni3DData.particleFadeFactor = gl3_particle_fade_factor->value;
glGenBuffers(1, &gl3state.uni3DUBO);
glBindBuffer(GL_UNIFORM_BUFFER, gl3state.uni3DUBO);

View file

@ -141,14 +141,13 @@ typedef struct
hmm_mat4 transViewMat4;
hmm_mat4 transModelMat4;
hmm_vec2 lmOffset;
GLfloat scroll; // for SURF_FLOWING
GLfloat time; // for warping surfaces like water & possibly other things
GLfloat alpha; // for translucent surfaces (water, glass, ..)
GLfloat overbrightbits; // gl_overbrightbits, applied to lightmaps (and elsewhere to models)
GLfloat overbrightbits; // gl3_overbrightbits, applied to lightmaps (and elsewhere to models)
GLfloat particleFadeFactor; // gl3_particle_fade_factor, higher => less fading out towards edges
GLfloat _padding[2]; // again, some padding to ensure this has right size
GLfloat _padding[3]; // again, some padding to ensure this has right size
} gl3Uni3D_t;
extern const hmm_mat4 gl3_identityMat4;
@ -502,6 +501,7 @@ extern cvar_t *gl_anisotropic;
extern cvar_t *gl_lightlevel;
extern cvar_t *gl3_overbrightbits;
extern cvar_t *gl3_particle_fade_factor;
extern cvar_t *gl_modulate;
extern cvar_t *gl_lightmap;