diff --git a/zoneb/bin/data/shaders/particles/draw.frag b/zoneb/bin/data/shaders/particles/draw.frag index feb88a5..20bbb34 100755 --- a/zoneb/bin/data/shaders/particles/draw.frag +++ b/zoneb/bin/data/shaders/particles/draw.frag @@ -12,6 +12,8 @@ uniform sampler2DRect cold2; uniform float uAreThereTwoPeopleTween; +uniform float u_time; + uniform vec3 uHottest0; uniform vec3 uHottest1; uniform vec3 uHottest3d0; @@ -20,6 +22,7 @@ uniform vec3 uBetween; in vec2 texCoordVarying; in vec3 vPos; +in vec4 vTarget; in float vTemperature; in float vAge; @@ -104,13 +107,24 @@ void main() vec2 palette = vec2(vTemperature*3425, 0.5); vec3 remapedColorW = texture(warm1, palette).xyz; vec3 remapedColorC = texture(cold2, palette).xyz; - float d = 50; + float d = 80; float D = 600; - float rate = 1-smoothstep(D - d, D + d, length(vPos.x + uBetween.x) + simplex3d(vPos * vec3(0.001, 0.001, 0.1)) * 100); + float n = (simplex3d(vPos * vec3(0.01, 0.01, 0.1 * sin(u_time * 0.01)))) * 100; + float rate = 1-smoothstep(D - d, D + d, length(vPos.x + uBetween.x) + n); rate *= uAreThereTwoPeopleTween; vec3 remapedColor = mix(remapedColorC, remapedColorW, rate); - float alpha = max(0, 1 - pow(vAge,4)); - + float alpha = max(0, 1 - pow(vAge,4)) * 1; + +// if(vTemperature < 0.5) { +// alpha *= vTemperature * 2; +// } +// if(vTarget.w >1) { +// alpha = 0.1; +// } + + if(vPos.z > -200) { + alpha = 0; + } vec4 color = vec4(remapedColor, alpha); fragColor = color; diff --git a/zoneb/bin/data/shaders/particles/draw.vert b/zoneb/bin/data/shaders/particles/draw.vert index 96a7ebf..5ff186f 100755 --- a/zoneb/bin/data/shaders/particles/draw.vert +++ b/zoneb/bin/data/shaders/particles/draw.vert @@ -2,12 +2,14 @@ uniform mat4 modelViewProjectionMatrix; uniform sampler2DRect particles0; uniform sampler2DRect particles1; uniform sampler2DRect particles2; +uniform sampler2DRect particles3; in vec4 position; in vec2 texcoord; out vec2 texCoordVarying; out vec3 vPos; +out vec4 vTarget; out float vTemperature; out float vAge; @@ -15,6 +17,7 @@ void main() { texCoordVarying = texcoord; vec4 misc = texture(particles2, texCoordVarying); + vec4 vTarget = texture(particles3, texCoordVarying); vTemperature = misc.x; vAge = misc.y; vPos = texture(particles0, texCoordVarying).xyz; diff --git a/zoneb/bin/data/shaders/particles/update.frag b/zoneb/bin/data/shaders/particles/update.frag index 484194a..a5999d6 100755 --- a/zoneb/bin/data/shaders/particles/update.frag +++ b/zoneb/bin/data/shaders/particles/update.frag @@ -112,13 +112,14 @@ void main() vec3 misc = texture(particles2, texCoordVarying.st).xyz; vec4 target = texture(particles3, texCoordVarying.st).xyzw; - float thermo = texture2D(u_v4l2cam, texCoordVarying.st/4).r; + float fraction = 8; + float thermo = texture2D(u_v4l2cam, texCoordVarying.st/fraction).r; - vec2 subPix = mod(texCoordVarying.st / 4, 1.0); - float depth0 = texture(u_depth, texCoordVarying.st/4 - subPix).x; - float depth1 = texture(u_depth, texCoordVarying.st/4 - subPix + vec2(1, 1)).x; - vec4 ray0 = texture(u_world, texCoordVarying.st/4 - subPix); - vec4 ray1 = texture(u_world, texCoordVarying.st/4 - subPix + vec2(1, 1)); + vec2 subPix = mod(texCoordVarying.st / fraction, 1.0); + float depth0 = texture(u_depth, texCoordVarying.st/fraction - subPix).x; + float depth1 = texture(u_depth, texCoordVarying.st/fraction - subPix + vec2(1, 1)).x; + vec4 ray0 = texture(u_world, texCoordVarying.st/fraction - subPix); + vec4 ray1 = texture(u_world, texCoordVarying.st/fraction - subPix + vec2(1, 1)); float depth = mix(depth0, depth1, length(subPix)); vec4 ray = mix(ray0, ray1, length(subPix)); @@ -129,6 +130,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) * 2; float age = misc.y; if(age > 1) { // reached target @@ -144,7 +146,7 @@ void main() target.xyz = pos; } else if (target.w > 0) { // targeted - age += 0.01; + age += 10.01; thermo = misc.x; } else { // wandering @@ -159,8 +161,8 @@ void main() // wandering vec3 force = vec3(0,0,0); - float th = 3.1415 * 4 * simplex3d_fractal(vec3(pos.xyz * 0.001)); - float phi = 3.1415 * simplex3d_fractal(pos.xyz * 0.002); + float th = 3.1415 * 4 * simplex3d_fractal(vec3(pos.xyz * 0.01)); + float phi = 3.1415 * simplex3d_fractal(pos.xyz * 0.02); force.x += cos(th) * cos(phi); force.y += sin(th) * cos(phi); force.z += sin(phi); @@ -168,7 +170,7 @@ void main() if(age < 0.001) { // targetting target.w = 0; - if(random3(pos).x > pow(length(texCoordVarying.st/4 - uHottest0.st)/5,16*16)+0) { + if(random3(pos).x > pow(length(texCoordVarying.st/fraction - uHottest0.st)/5,16*16)+0) { vec2 h = uHottest1.st; vec4 hray = texture(u_world, h); float hdepth = -depth * 65535.0; @@ -182,7 +184,7 @@ void main() // target.xyz = H + random3(pos); // target.w = 1; } - else if(random3(pos).x > pow(length(texCoordVarying.st/4 - uHottest1.st)/5,16*16)+0) { + else if(random3(pos).x > pow(length(texCoordVarying.st/fraction - uHottest1.st)/5,16*16)+0) { vec2 h = uHottest0.st; vec4 hray = texture(u_world, h); float hdepth = -depth * 65535.0; diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index c86a64f..851e45a 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -72,8 +72,8 @@ void ofApp::setupThermal() void ofApp::setupParticles() { // 1,000,000 particles - unsigned w = 512*4; - unsigned h = 512*4; + unsigned w = 512 * 4 * 2; + unsigned h = 512 * 4 * 2; particles.init(w, h, OF_PRIMITIVE_POINTS, false, 4); @@ -132,6 +132,7 @@ void ofApp::setupGui() gui.add(registrationScale.setup("scale", 2.0, 0.1, 3)); gui.add(v4l2Delay.setup("thermo delay", 0, 0, 59)); gui.add(captureDeviceName.setup("device", "video3")); + gui.add(blendAdd.setup("blend add", false)); gui.loadFromFile("settings.xml"); gui.setPosition(10, 10); @@ -248,7 +249,8 @@ void ofApp::updateThermal() areThereTwoPeople = true; areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween + 0.02, 0, 1); } - else { + else + { areThereTwoPeople = false; areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween - 0.02, 0, 1); } @@ -351,7 +353,15 @@ void ofApp::draw() fbos.at("ofcam").begin(); ofClear(0); cam.begin(); + if (blendAdd) + { + ofEnableBlendMode(OF_BLENDMODE_ADD); + } particles.draw(); + if (blendAdd) + { + ofDisableBlendMode(); + } cam.end(); fbos.at("ofcam").end(); diff --git a/zoneb/src/ofApp.h b/zoneb/src/ofApp.h index 366e541..58c16c6 100644 --- a/zoneb/src/ofApp.h +++ b/zoneb/src/ofApp.h @@ -72,6 +72,7 @@ private: ofxFloatSlider registrationScale; ofxIntSlider v4l2Delay; ofxInputField captureDeviceName; + ofxToggle blendAdd; ofxPanel gui; ofxToggle calibMode;