no holes!

This commit is contained in:
micuat 2020-10-31 20:59:19 +01:00
parent a9b65025d3
commit 23e77308e7
4 changed files with 27 additions and 14 deletions

View file

@ -46,8 +46,9 @@ void main()
{ {
vec3 vOffset; vec3 vOffset;
if(uEnergy > 0) { if(uEnergy > 0) {
vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz) * (gAge * 15); if(gAge < 0.01) return;
// vOffset += normalize(vOffset) * 5; vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz);
vOffset += normalize(vOffset) * 10;
} }
else { else {
vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz); vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz);

View file

@ -4,7 +4,10 @@ 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 particles4; // prev
uniform sampler2DRect particles5; // org
uniform int uEnergy;
in vec4 position; in vec4 position;
in vec2 texcoord; in vec2 texcoord;
@ -19,13 +22,18 @@ out vec4 vPrevPosition;
void main() void main()
{ {
// vTexCoord = vec2(gl_InstanceID % 512, gl_InstanceID / 512); // vTexCoord = vec2(gl_InstanceID % 512, gl_InstanceID / 512);
vTexCoord = texcoord; vTexCoord = texcoord;
vec4 misc = texture(particles2, vTexCoord); vec4 misc = texture(particles2, vTexCoord);
vec4 vTarget = texture(particles3, vTexCoord); vec4 vTarget = texture(particles3, vTexCoord);
vTemperature = misc.x; vTemperature = misc.x;
vAge = misc.y; vAge = misc.y;
if(uEnergy > 0) {
vPos = texture(particles0, vTexCoord).xyz; vPos = texture(particles0, vTexCoord).xyz;
vPosition = modelViewMatrix * vec4(vPos, 1.0); }
vPrevPosition = modelViewMatrix * vec4(texture(particles4, vTexCoord).xyz, 1.0); else {
vPos = texture(particles5, vTexCoord).xyz;
}
vPosition = modelViewMatrix * vec4(vPos, 1.0);
vPrevPosition = modelViewMatrix * vec4(texture(particles4, vTexCoord).xyz, 1.0);
} }

View file

@ -6,6 +6,7 @@ uniform sampler2DRect particles1;
uniform sampler2DRect particles2; uniform sampler2DRect particles2;
uniform sampler2DRect particles3; uniform sampler2DRect particles3;
uniform sampler2DRect particles4; uniform sampler2DRect particles4;
uniform sampler2DRect particles5;
uniform sampler2DRect u_depth; uniform sampler2DRect u_depth;
uniform sampler2DRect u_world; uniform sampler2DRect u_world;
@ -31,6 +32,7 @@ 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; layout(location = 4) out vec4 prevPosOut;
layout(location = 5) out vec4 orgPosOut;
vec3 random3(vec3 c) { vec3 random3(vec3 c) {
@ -144,7 +146,7 @@ void main()
posWorld.z = -depth * 65535.0; // Remap to float range. posWorld.z = -depth * 65535.0; // Remap to float range.
posWorld.x = ray.x * posWorld.z; posWorld.x = ray.x * posWorld.z;
posWorld.y = ray.y * posWorld.z; posWorld.y = ray.y * posWorld.z;
posWorld.xyz += random3(posWorld.xyz) * 0.5; posWorld.xyz += random3(posWorld.xyz) * 0.3;
float age = misc.y; float age = misc.y;
if(age > 1) { // reached target if(age > 1) { // reached target
@ -239,4 +241,5 @@ void main()
misOut = vec4(thermo, age, 0, 0); misOut = vec4(thermo, age, 0, 0);
tarOut = vec4(target); tarOut = vec4(target);
prevPosOut = vec4(prevPos, 1.0); prevPosOut = vec4(prevPos, 1.0);
orgPosOut = posWorld;
} }

View file

@ -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, 5); particles.init(w, h, OF_PRIMITIVE_POINTS, false, 6);
particles.loadShaders("shaders/particles/update", "shaders/particles/draw"); particles.loadShaders("shaders/particles/update", "shaders/particles/draw");
@ -92,7 +92,6 @@ 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);
@ -109,6 +108,8 @@ void ofApp::setupParticles()
} }
particles.loadDataTexture(ofxGpuParticles::MISC, particlePosns); particles.loadDataTexture(ofxGpuParticles::MISC, particlePosns);
particles.zeroDataTexture(3); particles.zeroDataTexture(3);
particles.zeroDataTexture(4); // prev pos
particles.zeroDataTexture(5); // org pos
delete[] particlePosns; delete[] particlePosns;