whatever
This commit is contained in:
parent
c3c55ae4c7
commit
5726baafe0
5 changed files with 35 additions and 13 deletions
|
@ -113,7 +113,7 @@ void main()
|
||||||
float rate = 1-smoothstep(D - d, D + d, length(gPos.x + uBetween.x) + n);
|
float rate = 1-smoothstep(D - d, D + d, length(gPos.x + uBetween.x) + n);
|
||||||
rate *= uAreThereTwoPeopleTween;
|
rate *= uAreThereTwoPeopleTween;
|
||||||
vec3 remapedColor = mix(remapedColorC, remapedColorW, rate);
|
vec3 remapedColor = mix(remapedColorC, remapedColorW, rate);
|
||||||
float alpha = max(0, 1 - pow(gAge,4)) * .2;
|
float alpha = max(0, 1 - pow(gAge,4)) * .03;
|
||||||
|
|
||||||
// if(vTemperature < 0.5) {
|
// if(vTemperature < 0.5) {
|
||||||
// alpha *= vTemperature * 2;
|
// alpha *= vTemperature * 2;
|
||||||
|
|
|
@ -6,10 +6,13 @@ layout (max_vertices = 4) out;
|
||||||
// OF handled uniforms and attributes.
|
// OF handled uniforms and attributes.
|
||||||
uniform mat4 projectionMatrix;
|
uniform mat4 projectionMatrix;
|
||||||
|
|
||||||
|
uniform float u_time;
|
||||||
|
|
||||||
// App specific uniforms and attributes.
|
// App specific uniforms and attributes.
|
||||||
// uniform float uSpriteSize;
|
// uniform float uSpriteSize;
|
||||||
|
|
||||||
in vec4 vPosition[];
|
in vec4 vPosition[];
|
||||||
|
in vec4 vPrevPosition[];
|
||||||
in vec2 vTexCoord[];
|
in vec2 vTexCoord[];
|
||||||
flat in int vValid[];
|
flat in int vValid[];
|
||||||
|
|
||||||
|
@ -27,7 +30,7 @@ out float gAge;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float uSpriteSize = 1.5;
|
float uSpriteSize = 1;
|
||||||
// if (vValid[0] == 0) return;
|
// if (vValid[0] == 0) return;
|
||||||
|
|
||||||
texCoordVarying = vTexCoord[0];
|
texCoordVarying = vTexCoord[0];
|
||||||
|
@ -36,19 +39,30 @@ void main()
|
||||||
gTemperature = vTemperature[0];
|
gTemperature = vTemperature[0];
|
||||||
gAge = vAge[0];
|
gAge = vAge[0];
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < gl_in.length(); ++i)
|
for (int i = 0; i < gl_in.length(); ++i)
|
||||||
{
|
{
|
||||||
gl_Position = projectionMatrix * (vPosition[i] + vec4(1.0, -1.0, 0.0, 0.0) * uSpriteSize);
|
vec3 vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz) * 4;
|
||||||
|
vOffset += normalize(vOffset) * 10;
|
||||||
|
// if(length(vOffset) < 4) {
|
||||||
|
// vOffset = normalize(vOffset) * 4;
|
||||||
|
// }
|
||||||
|
vec4 shiftPos = vec4(vOffset, 1) + vPosition[i];
|
||||||
|
|
||||||
|
gl_Position = projectionMatrix * (vPosition[i] + vec4(0.0, 1.0, 0.0, 0.0) * uSpriteSize);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
gl_Position = projectionMatrix * (vPosition[i] + vec4(1.0, 1.0, 0.0, 0.0) * uSpriteSize);
|
if (u_time > 10) { // hack
|
||||||
EmitVertex();
|
gl_Position = projectionMatrix * (shiftPos + vec4(0.0, 1.0, 0.0, 0.0) * uSpriteSize);
|
||||||
|
EmitVertex();
|
||||||
|
|
||||||
gl_Position = projectionMatrix * (vPosition[i] + vec4(-1.0, -1.0, 0.0, 0.0) * uSpriteSize);
|
gl_Position = projectionMatrix * (vPosition[i] + vec4(0.0, -1.0, 0.0, 0.0) * uSpriteSize);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|
||||||
|
gl_Position = projectionMatrix * (shiftPos + vec4(0.0, -1.0, 0.0, 0.0) * uSpriteSize);
|
||||||
|
EmitVertex();
|
||||||
|
}
|
||||||
|
|
||||||
gl_Position = projectionMatrix * (vPosition[i] + vec4(-1.0, 1.0, 0.0, 0.0) * uSpriteSize);
|
|
||||||
EmitVertex();
|
|
||||||
|
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ uniform sampler2DRect particles0;
|
||||||
uniform sampler2DRect particles1;
|
uniform sampler2DRect particles1;
|
||||||
uniform sampler2DRect particles2;
|
uniform sampler2DRect particles2;
|
||||||
uniform sampler2DRect particles3;
|
uniform sampler2DRect particles3;
|
||||||
|
uniform sampler2DRect particles4;
|
||||||
|
|
||||||
in vec4 position;
|
in vec4 position;
|
||||||
in vec2 texcoord;
|
in vec2 texcoord;
|
||||||
|
@ -14,6 +15,7 @@ out vec4 vTarget;
|
||||||
out float vTemperature;
|
out float vTemperature;
|
||||||
out float vAge;
|
out float vAge;
|
||||||
out vec4 vPosition;
|
out vec4 vPosition;
|
||||||
|
out vec4 vPrevPosition;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -25,4 +27,5 @@ void main()
|
||||||
vAge = misc.y;
|
vAge = misc.y;
|
||||||
vPos = texture(particles0, vTexCoord).xyz;
|
vPos = texture(particles0, vTexCoord).xyz;
|
||||||
vPosition = modelViewMatrix * vec4(vPos, 1.0);
|
vPosition = modelViewMatrix * vec4(vPos, 1.0);
|
||||||
|
vPrevPosition = modelViewMatrix * vec4(texture(particles4, vTexCoord).xyz, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ uniform sampler2DRect particles0;
|
||||||
uniform sampler2DRect particles1;
|
uniform sampler2DRect particles1;
|
||||||
uniform sampler2DRect particles2;
|
uniform sampler2DRect particles2;
|
||||||
uniform sampler2DRect particles3;
|
uniform sampler2DRect particles3;
|
||||||
|
uniform sampler2DRect particles4;
|
||||||
|
|
||||||
uniform sampler2DRect u_depth;
|
uniform sampler2DRect u_depth;
|
||||||
uniform sampler2DRect u_world;
|
uniform sampler2DRect u_world;
|
||||||
|
@ -28,6 +29,7 @@ layout(location = 0) out vec4 posOut;
|
||||||
layout(location = 1) out vec4 velOut;
|
layout(location = 1) out vec4 velOut;
|
||||||
layout(location = 2) out vec4 misOut;
|
layout(location = 2) out vec4 misOut;
|
||||||
layout(location = 3) out vec4 tarOut;
|
layout(location = 3) out vec4 tarOut;
|
||||||
|
layout(location = 4) out vec4 prevPosOut;
|
||||||
|
|
||||||
|
|
||||||
vec3 random3(vec3 c) {
|
vec3 random3(vec3 c) {
|
||||||
|
@ -111,6 +113,7 @@ void main()
|
||||||
vec3 vel = texture(particles1, texCoordVarying.st).xyz;
|
vec3 vel = texture(particles1, texCoordVarying.st).xyz;
|
||||||
vec3 misc = texture(particles2, texCoordVarying.st).xyz;
|
vec3 misc = texture(particles2, texCoordVarying.st).xyz;
|
||||||
vec4 target = texture(particles3, texCoordVarying.st).xyzw;
|
vec4 target = texture(particles3, texCoordVarying.st).xyzw;
|
||||||
|
vec3 prevPos = pos;//texture(particles4, texCoordVarying.st).xyz;
|
||||||
|
|
||||||
float fraction = 8;
|
float fraction = 8;
|
||||||
float thermo = texture2D(u_v4l2cam, texCoordVarying.st/fraction).r;
|
float thermo = texture2D(u_v4l2cam, texCoordVarying.st/fraction).r;
|
||||||
|
@ -152,8 +155,8 @@ void main()
|
||||||
|
|
||||||
if(vValid == 1 && target.w == 0) { // point valid && no target -> move to the point
|
if(vValid == 1 && target.w == 0) { // point valid && no target -> move to the point
|
||||||
pos = posWorld.xyz;
|
pos = posWorld.xyz;
|
||||||
|
// prevPos = posWorld.xyz;// + vec3(1,0,0);//random3(posWorld.xyz) * 0.5;
|
||||||
age = 0;
|
age = 0;
|
||||||
target.xyz = pos;
|
|
||||||
}
|
}
|
||||||
else if (target.w > 0) { // targeted
|
else if (target.w > 0) { // targeted
|
||||||
age += 0.002;
|
age += 0.002;
|
||||||
|
@ -165,7 +168,7 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vValid == 1 && target.w > 0 && length(target.xy - pos.xy) < 100) { // arrived
|
if(vValid == 1 && target.w > 0 && length(target.xy - pos.xy) < 100) { // arrived
|
||||||
age += 0.1;
|
age += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wandering
|
// wandering
|
||||||
|
@ -218,7 +221,6 @@ void main()
|
||||||
force.y = sin(th) * cos(phi);
|
force.y = sin(th) * cos(phi);
|
||||||
force.z = sin(phi);
|
force.z = sin(phi);
|
||||||
force *= 200 + 200 * simplex3d_fractal(vec3(texCoordVarying, 0.0));
|
force *= 200 + 200 * simplex3d_fractal(vec3(texCoordVarying, 0.0));
|
||||||
// force += (target.xyz - pos) * 0.3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// damping
|
// damping
|
||||||
|
@ -228,10 +230,12 @@ void main()
|
||||||
vel += elapsed * force;
|
vel += elapsed * force;
|
||||||
|
|
||||||
// move
|
// move
|
||||||
|
prevPos = pos;
|
||||||
pos += elapsed * vel;
|
pos += elapsed * vel;
|
||||||
|
|
||||||
posOut = vec4(pos, 1.0);
|
posOut = vec4(pos, 1.0);
|
||||||
velOut = vec4(vel, 0.0);
|
velOut = vec4(vel, 0.0);
|
||||||
misOut = vec4(thermo, age, 0, 0);
|
misOut = vec4(thermo, age, 0, 0);
|
||||||
tarOut = vec4(target);
|
tarOut = vec4(target);
|
||||||
|
prevPosOut = vec4(prevPos, 1.0);
|
||||||
}
|
}
|
|
@ -75,7 +75,7 @@ void ofApp::setupParticles()
|
||||||
unsigned w = 512 * 4 * 2;
|
unsigned w = 512 * 4 * 2;
|
||||||
unsigned h = 512 * 4 * 2;
|
unsigned h = 512 * 4 * 2;
|
||||||
|
|
||||||
particles.init(w, h, OF_PRIMITIVE_POINTS, false, 4);
|
particles.init(w, h, OF_PRIMITIVE_POINTS, false, 5);
|
||||||
|
|
||||||
particles.loadShaders("shaders/particles/update", "shaders/particles/draw");
|
particles.loadShaders("shaders/particles/update", "shaders/particles/draw");
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ void ofApp::setupParticles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
particles.loadDataTexture(ofxGpuParticles::POSITION, particlePosns);
|
particles.loadDataTexture(ofxGpuParticles::POSITION, particlePosns);
|
||||||
|
particles.loadDataTexture(4, particlePosns); // prev pos
|
||||||
|
|
||||||
// initial velocities
|
// initial velocities
|
||||||
particles.zeroDataTexture(ofxGpuParticles::VELOCITY);
|
particles.zeroDataTexture(ofxGpuParticles::VELOCITY);
|
||||||
|
|
Loading…
Reference in a new issue