finally fixed the particle system.
This commit is contained in:
parent
185f7d2748
commit
067cfb6203
8 changed files with 100 additions and 47 deletions
|
|
@ -1,16 +1,27 @@
|
|||
#version 120
|
||||
varying vec2 vertex;
|
||||
varying vec2 velocity;
|
||||
uniform float maxAge;
|
||||
uniform float time;
|
||||
varying float decay;
|
||||
|
||||
vec3 hsv2rgb(vec3 c)
|
||||
{
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
//gl_FragColor = vec4(0.5+0.5*vertex.x, 0.5+0.5*vertex.y, 0.0, 1.0);
|
||||
if (length(vertex) > 1.0) {
|
||||
discard;
|
||||
gl_FragColor = vec4(0.5+0.5*vertex.x, 0.5+0.5*vertex.y, 0.0, 1.0);
|
||||
float r = length(vertex);
|
||||
if (r > 1.0) {
|
||||
discard;
|
||||
}
|
||||
float decay = time / maxAge;
|
||||
decay = 5.0*decay*decay;
|
||||
// (length(10.0*velocity));
|
||||
gl_FragColor = vec4(1.0/max(1.0, decay), 1.0/max(1.0, 6.0*decay), 0.0, 1.0);
|
||||
float d = decay;
|
||||
float h = (1.0-d)/6.0;
|
||||
float v = max(0.0, (1.0-d/2.0) - 0.1*(d*d*d));
|
||||
float s = 1.0;
|
||||
gl_FragColor = vec4(hsv2rgb(vec3(h, s, v)), 1.0);
|
||||
|
||||
//gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
|
||||
}
|
||||
|
|
@ -2,17 +2,25 @@
|
|||
attribute vec2 in_vertex;
|
||||
attribute vec2 in_position;
|
||||
attribute vec2 in_velocity;
|
||||
|
||||
uniform float maxAge;
|
||||
varying float decay;
|
||||
varying vec2 velocity;
|
||||
varying vec2 vertex;
|
||||
uniform float time;
|
||||
uniform float size;
|
||||
void main()
|
||||
{
|
||||
vec2 p = size*in_vertex;
|
||||
//decay = min(1.0, time+5.0*length(velocity)) / maxAge;
|
||||
//decay = max(decay*decay, sqrt(decay));
|
||||
decay = time / maxAge;
|
||||
|
||||
vec2 base = in_vertex;
|
||||
vec2 p = size*base;
|
||||
p += log(1.0+time) * in_velocity;
|
||||
p += in_position;
|
||||
gl_Position = vec4(p, 0.0, 1.0);
|
||||
|
||||
vertex = in_vertex;
|
||||
vertex = base;
|
||||
velocity = in_velocity;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue