From 23e77308e7ec40938c1f38c8d18592ee641179dc Mon Sep 17 00:00:00 2001 From: micuat Date: Sat, 31 Oct 2020 20:59:19 +0100 Subject: [PATCH] no holes! --- zoneb/bin/data/shaders/particles/draw.geom | 5 ++-- zoneb/bin/data/shaders/particles/draw.vert | 26 +++++++++++++------- zoneb/bin/data/shaders/particles/update.frag | 5 +++- zoneb/src/ofApp.cpp | 5 ++-- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/zoneb/bin/data/shaders/particles/draw.geom b/zoneb/bin/data/shaders/particles/draw.geom index 4ab4898..608136d 100644 --- a/zoneb/bin/data/shaders/particles/draw.geom +++ b/zoneb/bin/data/shaders/particles/draw.geom @@ -46,8 +46,9 @@ void main() { vec3 vOffset; if(uEnergy > 0) { - vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz) * (gAge * 15); - // vOffset += normalize(vOffset) * 5; + if(gAge < 0.01) return; + vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz); + vOffset += normalize(vOffset) * 10; } else { vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz); diff --git a/zoneb/bin/data/shaders/particles/draw.vert b/zoneb/bin/data/shaders/particles/draw.vert index 30ff53d..6c19439 100755 --- a/zoneb/bin/data/shaders/particles/draw.vert +++ b/zoneb/bin/data/shaders/particles/draw.vert @@ -4,7 +4,10 @@ uniform sampler2DRect particles0; uniform sampler2DRect particles1; uniform sampler2DRect particles2; uniform sampler2DRect particles3; -uniform sampler2DRect particles4; +uniform sampler2DRect particles4; // prev +uniform sampler2DRect particles5; // org + +uniform int uEnergy; in vec4 position; in vec2 texcoord; @@ -19,13 +22,18 @@ out vec4 vPrevPosition; void main() { - // vTexCoord = vec2(gl_InstanceID % 512, gl_InstanceID / 512); - vTexCoord = texcoord; - vec4 misc = texture(particles2, vTexCoord); - vec4 vTarget = texture(particles3, vTexCoord); - vTemperature = misc.x; - vAge = misc.y; + // vTexCoord = vec2(gl_InstanceID % 512, gl_InstanceID / 512); + vTexCoord = texcoord; + vec4 misc = texture(particles2, vTexCoord); + vec4 vTarget = texture(particles3, vTexCoord); + vTemperature = misc.x; + vAge = misc.y; + if(uEnergy > 0) { 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); } diff --git a/zoneb/bin/data/shaders/particles/update.frag b/zoneb/bin/data/shaders/particles/update.frag index e8e68ae..af88111 100755 --- a/zoneb/bin/data/shaders/particles/update.frag +++ b/zoneb/bin/data/shaders/particles/update.frag @@ -6,6 +6,7 @@ uniform sampler2DRect particles1; uniform sampler2DRect particles2; uniform sampler2DRect particles3; uniform sampler2DRect particles4; +uniform sampler2DRect particles5; uniform sampler2DRect u_depth; uniform sampler2DRect u_world; @@ -31,6 +32,7 @@ layout(location = 1) out vec4 velOut; layout(location = 2) out vec4 misOut; layout(location = 3) out vec4 tarOut; layout(location = 4) out vec4 prevPosOut; +layout(location = 5) out vec4 orgPosOut; vec3 random3(vec3 c) { @@ -144,7 +146,7 @@ void main() posWorld.z = -depth * 65535.0; // Remap to float range. posWorld.x = ray.x * 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; if(age > 1) { // reached target @@ -239,4 +241,5 @@ void main() misOut = vec4(thermo, age, 0, 0); tarOut = vec4(target); prevPosOut = vec4(prevPos, 1.0); + orgPosOut = posWorld; } \ No newline at end of file diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index ecfb825..3482f67 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -75,7 +75,7 @@ void ofApp::setupParticles() unsigned w = 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"); @@ -92,7 +92,6 @@ void ofApp::setupParticles() } } particles.loadDataTexture(ofxGpuParticles::POSITION, particlePosns); - particles.loadDataTexture(4, particlePosns); // prev pos // initial velocities particles.zeroDataTexture(ofxGpuParticles::VELOCITY); @@ -109,6 +108,8 @@ void ofApp::setupParticles() } particles.loadDataTexture(ofxGpuParticles::MISC, particlePosns); particles.zeroDataTexture(3); + particles.zeroDataTexture(4); // prev pos + particles.zeroDataTexture(5); // org pos delete[] particlePosns;