From c45f50c439e8241a460b5a75d9c9f0a09ac0ec62 Mon Sep 17 00:00:00 2001 From: micuat Date: Sat, 31 Oct 2020 20:24:50 +0100 Subject: [PATCH] test --- zoneb/bin/data/shaders/particles/draw.frag | 3 +- zoneb/bin/data/shaders/particles/draw.geom | 29 +++++++++++--------- zoneb/bin/data/shaders/particles/update.frag | 9 +++--- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/zoneb/bin/data/shaders/particles/draw.frag b/zoneb/bin/data/shaders/particles/draw.frag index 3e4d0a6..07b347f 100755 --- a/zoneb/bin/data/shaders/particles/draw.frag +++ b/zoneb/bin/data/shaders/particles/draw.frag @@ -104,6 +104,7 @@ float simplex3d_fractal(vec3 m) { void main() { + if(gAge >= 1) discard; vec2 palette = vec2(gTemperature*3425, 0.5); vec3 remapedColorW = texture(warm1, palette).xyz; vec3 remapedColorC = texture(cold2, palette).xyz; @@ -113,7 +114,7 @@ void main() float rate = 1-smoothstep(D - d, D + d, length(gPos.x + uBetween.x) + n); rate *= uAreThereTwoPeopleTween; vec3 remapedColor = mix(remapedColorC, remapedColorW, rate); - float alpha = max(0, 1 - pow(gAge,4)) * .03; + float alpha = max(0, 1 - pow(gAge,4)) * 0.1; // if(vTemperature < 0.5) { // alpha *= vTemperature * 2; diff --git a/zoneb/bin/data/shaders/particles/draw.geom b/zoneb/bin/data/shaders/particles/draw.geom index dea28cf..e050498 100644 --- a/zoneb/bin/data/shaders/particles/draw.geom +++ b/zoneb/bin/data/shaders/particles/draw.geom @@ -1,7 +1,7 @@ layout (points) in; -layout (triangle_strip) out; -layout (max_vertices = 4) out; +layout (line_strip) out; +layout (max_vertices = 16) out; // OF handled uniforms and attributes. uniform mat4 projectionMatrix; @@ -39,28 +39,31 @@ void main() gTemperature = vTemperature[0]; gAge = vAge[0]; - + if(gAge >= 1) return; for (int i = 0; i < gl_in.length(); ++i) { - vec3 vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz) * 4; - vOffset += normalize(vOffset) * 10; + vec3 vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz) * (gAge * 5); + vOffset += normalize(vOffset) * 5; // if(length(vOffset) < 4) { // vOffset = normalize(vOffset) * 4; // } - vec4 shiftPos = vec4(vOffset, 1) + vPosition[i]; + vec4 shiftPos = vec4(vOffset, 0) + vPosition[i]; - gl_Position = projectionMatrix * (vPosition[i] + vec4(0.0, 1.0, 0.0, 0.0) * uSpriteSize); + gl_Position = projectionMatrix * (vPosition[i] + vec4(0.0, 0.0, 0.0, 0.0) * uSpriteSize); EmitVertex(); if (u_time > 10) { // hack - gl_Position = projectionMatrix * (shiftPos + vec4(0.0, 1.0, 0.0, 0.0) * uSpriteSize); + gl_Position = projectionMatrix * (shiftPos + vec4(0.0, 0.0, 0.0, 0.0) * uSpriteSize); EmitVertex(); - gl_Position = projectionMatrix * (vPosition[i] + vec4(0.0, -1.0, 0.0, 0.0) * uSpriteSize); - EmitVertex(); - - gl_Position = projectionMatrix * (shiftPos + vec4(0.0, -1.0, 0.0, 0.0) * uSpriteSize); - EmitVertex(); + if(gAge > 0 && gTarget.w > 0) { + for(int j = 0; j < 3; j++) { + gl_Position = projectionMatrix * (vPosition[i] + vec4(0.0, float(j+1), 0.0, 0.0) * uSpriteSize); + EmitVertex(); + gl_Position = projectionMatrix * (shiftPos + vec4(0.0, float(j+1), 0.0, 0.0) * uSpriteSize); + EmitVertex(); + } + } } diff --git a/zoneb/bin/data/shaders/particles/update.frag b/zoneb/bin/data/shaders/particles/update.frag index fb881f5..62df613 100755 --- a/zoneb/bin/data/shaders/particles/update.frag +++ b/zoneb/bin/data/shaders/particles/update.frag @@ -17,6 +17,7 @@ uniform ivec2 uDepthFrameSize; uniform vec3 mouse; uniform float radiusSquared; uniform float elapsed; +uniform float u_time; uniform vec3 uHottest0; uniform vec3 uHottest1; @@ -163,7 +164,7 @@ void main() thermo = misc.x; } else { // wandering - age += 0.02; + age += 01.02; thermo = misc.x; } @@ -192,7 +193,7 @@ void main() if(age < 0.001) { // targetting target.w = 0; - if(random3(pos).x > 2*pow(length(texCoordVarying.st/fraction - uHottest0.st)/15,1)) { + if(random3(pos + vec3(u_time, 0, 0)).x > 2*pow(length(texCoordVarying.st/fraction - uHottest0.st)/25,0.5)) { vec2 h = uHottest1.st; vec4 hray = texture(u_world, h); float hdepth = -depth * 65535.0; @@ -201,7 +202,7 @@ void main() target.xyz = H + random3(pos) * 3; target.w = 1; } - else if(random3(pos).x > 2*pow(length(texCoordVarying.st/fraction - uHottest1.st)/15,1)) { + else if(random3(pos + vec3(u_time, 0, 0)).x > 2*pow(length(texCoordVarying.st/fraction - uHottest1.st)/25,0.5)) { vec2 h = uHottest0.st; vec4 hray = texture(u_world, h); float hdepth = -depth * 65535.0; @@ -220,7 +221,7 @@ void main() force.x = cos(th) * cos(phi); force.y = sin(th) * cos(phi); force.z = sin(phi); - force *= 200 + 200 * simplex3d_fractal(vec3(texCoordVarying, 0.0)); + force *= 100 + 200 * simplex3d_fractal(vec3(texCoordVarying, 0.0)); } // damping