mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 05:01:24 +00:00
Use multi-octave simplex noise for the smoke trails.
It looks ok-ish, but still needs a lot of work.
This commit is contained in:
parent
77fa66b2e8
commit
f8b5fc2842
2 changed files with 48 additions and 11 deletions
|
@ -115,7 +115,10 @@ static const char *particle_trail_vert_effects[] =
|
|||
|
||||
static const char *particle_trail_frag_effects[] =
|
||||
{
|
||||
"QuakeForge.Fragment.barycentric",
|
||||
"QuakeForge.Math.InvSqrt",
|
||||
"QuakeForge.Math.permute",
|
||||
"QuakeForge.Noise.simplex",
|
||||
"QuakeForge.Fragment.particle.trail",
|
||||
0
|
||||
};
|
||||
|
||||
|
@ -164,7 +167,8 @@ static struct {
|
|||
shaderparam_t next;
|
||||
shaderparam_t barycentric;
|
||||
shaderparam_t texoff;
|
||||
shaderparam_t smoke;
|
||||
shaderparam_t colora;
|
||||
shaderparam_t colorb;
|
||||
} trail = {
|
||||
0,
|
||||
{"proj", 1},
|
||||
|
@ -176,7 +180,8 @@ static struct {
|
|||
{"next", 0},
|
||||
{"barycentric", 0},
|
||||
{"texoff", 0},
|
||||
{"smoke", 1},
|
||||
{"vcolora", 0},
|
||||
{"vcolorb", 0},
|
||||
};
|
||||
|
||||
typedef struct trail_s {
|
||||
|
@ -192,6 +197,8 @@ typedef struct trailvtx_s {
|
|||
quat_t vertex;
|
||||
vec3_t bary;
|
||||
float texoff;
|
||||
quat_t colora;
|
||||
quat_t colorb;
|
||||
} trailvtx_t;
|
||||
|
||||
static trail_t *trails_freelist;
|
||||
|
@ -369,7 +376,8 @@ glsl_R_InitParticles (void)
|
|||
GLSL_ResolveShaderParam (trail.program, &trail.next);
|
||||
GLSL_ResolveShaderParam (trail.program, &trail.barycentric);
|
||||
GLSL_ResolveShaderParam (trail.program, &trail.texoff);
|
||||
GLSL_ResolveShaderParam (trail.program, &trail.smoke);
|
||||
GLSL_ResolveShaderParam (trail.program, &trail.colora);
|
||||
GLSL_ResolveShaderParam (trail.program, &trail.colorb);
|
||||
GLSL_FreeShader (vert_shader);
|
||||
GLSL_FreeShader (frag_shader);
|
||||
|
||||
|
@ -754,19 +762,20 @@ R_RocketTrail_trail (entity_t *ent)
|
|||
pscale = 1.5 + qfrandom (1.5);
|
||||
|
||||
while (len < maxlen) {
|
||||
int ramp;
|
||||
pscalenext = 1.5 + qfrandom (1.5);
|
||||
dist = (pscale + pscalenext) * 3.0;
|
||||
percent = len * origlen;
|
||||
|
||||
point = new_point ();
|
||||
VectorCopy (old_origin, point->org);
|
||||
point->color = 12 + (mtwist_rand (&mt) & 3);
|
||||
point->color = ramp3[ramp = mtwist_rand (&mt) & 3];
|
||||
point->tex = part_tex_smoke;
|
||||
point->scale = pscale + percent * 4.0;
|
||||
point->alpha = 0.5 + qfrandom (0.125) - percent * 0.40;
|
||||
VectorCopy (vec3_origin, point->vel);
|
||||
point->die = vr_data.realtime + 2.0 - percent * 2.0;
|
||||
point->ramp = 0.0;
|
||||
point->ramp = ramp;
|
||||
point->physics = R_ParticlePhysics ("pt_fire");
|
||||
|
||||
*ent->trail->head = point;
|
||||
|
@ -1718,10 +1727,15 @@ static inline void
|
|||
set_vertex (trailvtx_t *v, const particle_t *point, float w, const vec3_t bary,
|
||||
float off)
|
||||
{
|
||||
byte *color = (byte *) &d_8to24table[(byte) point->color];
|
||||
|
||||
VectorCopy (point->org, v->vertex);
|
||||
VectorCopy (bary, v->bary);
|
||||
v->vertex[3] = w;
|
||||
v->vertex[3] = w * point->scale;
|
||||
v->texoff = off;
|
||||
VectorScale (color, 1.5 / 255, v->colora);
|
||||
v->colora[3] = point->alpha * 1.2;
|
||||
QuatSet (-1, -1, -1, -0.5, v->colorb);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1818,6 +1832,8 @@ draw_trails (void)
|
|||
if (trail.barycentric.location >= 0)
|
||||
qfeglEnableVertexAttribArray (trail.barycentric.location);
|
||||
qfeglEnableVertexAttribArray (trail.texoff.location);
|
||||
qfeglEnableVertexAttribArray (trail.colora.location);
|
||||
qfeglEnableVertexAttribArray (trail.colorb.location);
|
||||
|
||||
qfeglUniformMatrix4fv (trail.proj.location, 1, false, glsl_projection);
|
||||
qfeglUniformMatrix4fv (trail.view.location, 1, false, glsl_view);
|
||||
|
@ -1836,6 +1852,10 @@ draw_trails (void)
|
|||
0, sizeof (trailvtx_t), &verts[2].bary);
|
||||
qfeglVertexAttribPointer (trail.texoff.location, 1, GL_FLOAT,
|
||||
0, sizeof (trailvtx_t), &verts[0].texoff);
|
||||
qfeglVertexAttribPointer (trail.colora.location, 4, GL_FLOAT,
|
||||
0, sizeof (trailvtx_t), &verts[0].colora);
|
||||
qfeglVertexAttribPointer (trail.colorb.location, 4, GL_FLOAT,
|
||||
0, sizeof (trailvtx_t), &verts[0].colorb);
|
||||
|
||||
for (trl = trails_active; trl; trl = trl->next) {
|
||||
int count;
|
||||
|
@ -1853,6 +1873,8 @@ draw_trails (void)
|
|||
if (trail.barycentric.location >= 0)
|
||||
qfeglDisableVertexAttribArray (trail.barycentric.location);
|
||||
qfeglDisableVertexAttribArray (trail.texoff.location);
|
||||
qfeglDisableVertexAttribArray (trail.colora.location);
|
||||
qfeglDisableVertexAttribArray (trail.colorb.location);
|
||||
|
||||
expire_trails ();
|
||||
}
|
||||
|
|
|
@ -584,6 +584,8 @@ main (void)
|
|||
attribute vec4 last, current, next;
|
||||
attribute vec3 barycentric;
|
||||
attribute float texoff;
|
||||
attribute vec4 vcolora;
|
||||
attribute vec4 vcolorb;
|
||||
|
||||
uniform mat4 proj, view;
|
||||
uniform vec2 viewport;
|
||||
|
@ -591,6 +593,8 @@ uniform float width;
|
|||
|
||||
varying vec2 texcoord;
|
||||
varying vec3 vbarycentric;
|
||||
varying vec4 colora;
|
||||
varying vec4 colorb;
|
||||
|
||||
vec4
|
||||
transform (vec3 coord)
|
||||
|
@ -634,7 +638,9 @@ main (void)
|
|||
vec2 sCurrent = project (dCurrent);
|
||||
float off = current.w;
|
||||
|
||||
texcoord = vec2 (texoff * 0.7, off * 0.5 + 0.5);
|
||||
colora = vcolora;
|
||||
colorb = vcolorb;
|
||||
texcoord = vec2 (texoff * 0.7, off);// * 0.5 + 0.5);
|
||||
vbarycentric = barycentric;
|
||||
|
||||
t = sLast - sCurrent;
|
||||
|
@ -663,14 +669,23 @@ main (void)
|
|||
|
||||
-- Fragment.particle.trail
|
||||
|
||||
uniform sampler2D smoke;
|
||||
|
||||
varying vec2 texcoord;
|
||||
varying vec4 colora;
|
||||
varying vec4 colorb;
|
||||
|
||||
void
|
||||
main (void)
|
||||
{
|
||||
gl_FragColor = texture2D (smoke, texcoord) * vec4 (1.0, 1.0, 1.0, 0.7);
|
||||
//gl_FragColor = texture2D (smoke, texcoord) * vec4 (1.0, 1.0, 1.0, 0.7);
|
||||
vec3 tex3 = vec3 (texcoord, 0.5);
|
||||
float n = abs(snoise(tex3));
|
||||
float a = sqrt(1.0 - texcoord.y * texcoord.y);
|
||||
n += 0.5 * abs(snoise(tex3 * 2.0));
|
||||
n += 0.25 * abs(snoise(tex3 * 4.0));
|
||||
n += 0.125 * abs(snoise(tex3 * 8.0));
|
||||
vec4 c = colora + colorb * n;
|
||||
c.a *= a;
|
||||
gl_FragColor = c;
|
||||
}
|
||||
|
||||
-- Fragment.barycentric
|
||||
|
|
Loading…
Reference in a new issue