diff --git a/zoneb/bin/data/settings.xml b/zoneb/bin/data/settings.xml index 358aaf2..0f0ee4b 100644 --- a/zoneb/bin/data/settings.xml +++ b/zoneb/bin/data/settings.xml @@ -1,8 +1,9 @@ - 61.2245, 0 + 61.2245, -28.5714 1.7965 video3 - 7 + 4 1 + 3 diff --git a/zoneb/bin/data/shaders/bound.frag b/zoneb/bin/data/shaders/bound.frag index 49132a2..c1d5cfe 100644 --- a/zoneb/bin/data/shaders/bound.frag +++ b/zoneb/bin/data/shaders/bound.frag @@ -128,42 +128,46 @@ void main() { // Note: Here is where most of the action happens. But need's to read // te content of the previous pass, for that we are making another buffer // BUFFER_1 (u_buffer1) - vec4 color = vec4(0,0,0,1); + vec4 color = vec4(0,0,0,0); if(u_init) { - int brightCount = 0; - // for (int i=0; i < 9; i++){ - // float tmp = texture(u_buffer1, st + offset[i]/40).r; - // if(depthToSilhouette(tmp) > 0) { - // brightCount++; - // } - // } - brightCount = 10; - if(brightCount > 4) { - vec3 tmpc = texture(u_ofcam, st).rgb; - float tmp = tmpc.r;// + tmpc.g + tmpc.b; - color.rgb = vec3(depthToSilhouette(tmp)); - } + color = vec4(texture(u_energy, st).rgba); + color = vec4(mix(texture(u_buffer1, st).rgb * 0.95, color.rgb, color.a), 1); } else { float kernel[9]; - kernel[0] = 0.125; - kernel[1] = 0.25; - kernel[2] = 0.125; - kernel[3] = 0.25; + kernel[0] = 0.125*2; + kernel[1] = 0.25*2; + kernel[2] = 0.125*2; + kernel[3] = 0.25*2; kernel[4] = 1.0; - kernel[5] = 0.25; - kernel[6] = 0.125; - kernel[7] = 0.25; - kernel[8] = 0.125; + kernel[5] = 0.25*2; + kernel[6] = 0.125*2; + kernel[7] = 0.25*2; + kernel[8] = 0.125*2; float lap = 0; + vec4 cc = vec4(0); for (int i=0; i < 9; i++){ - float tmp = texture(u_buffer1, st + offset[i]).r; - lap += tmp * kernel[i] / 2.5; + // float tmp = texture(u_buffer1, st + offset[i]).r; + // lap += tmp * kernel[i] / 2.5; + // vec4 ccc = texture(u_buffer1, st + offset[i]); + // if(length(ccc.rgb) > length(cc.rgb)) cc = ccc; + // if(ccc.r < 1 && ccc.g < 1 && ccc.b < 1) { + // cc += ccc * kernel[i] / 4; + // } } - color = vec4(vec3(lap * 2.0), 1.0); + // color = vec4(vec3(lap * 2.0), 1.0); + // color = vec4(cc.rgba); + // // color = vec4(cc.rgba/4); + // color.r = min(1, color.r); + // color.g = min(1, color.g); + // color.b = min(1, color.b); + // color.a = min(1, color.a); + + color = texture(u_buffer1, st); + } gl_FragColor = color; @@ -174,7 +178,9 @@ void main() { // Note: Just copy the content of the BUFFER0 so it can be // read by it in the next frame // - gl_FragColor = texture(u_buffer0, st); + vec4 color = vec4(0,0,0,1); + color = texture(u_buffer0, st); + gl_FragColor = color; #else // Main Buffer if (u_calib) { @@ -187,9 +193,13 @@ void main() { else { vec4 pointCloudColor = texture(u_ofcam, st); vec4 energyColor = texture(u_energy, st); - vec4 color = vec4(mix(vec3(0), pointCloudColor.rgb, pointCloudColor.a), 1.0); + vec4 bufColor = texture(u_buffer1, st); + float newA = length(bufColor.rgb) / 2; + newA = min(1, newA); + gl_FragColor = vec4(mix(pointCloudColor.rgb,bufColor.rgb, newA), 1); + // gl_FragColor = vec4(mix(pointCloudColor.rgb, bufColor.rgb, min(1, length(bufColor.rgb))), 1.0); gl_FragColor = vec4(mix(pointCloudColor.rgb, energyColor.rgb, energyColor.a), 1.0); - // gl_FragColor = vec4(mix(vec3(0), energyColor.rgb, energyColor.a), 1.0); + // gl_FragColor = vec4(mix(vec3(0), pointCloudColor.rgb, pointCloudColor.a), 1.0); } #endif diff --git a/zoneb/bin/data/shaders/particles/draw.frag b/zoneb/bin/data/shaders/particles/draw.frag index 2b8ece1..648cc3e 100755 --- a/zoneb/bin/data/shaders/particles/draw.frag +++ b/zoneb/bin/data/shaders/particles/draw.frag @@ -115,10 +115,10 @@ void main() float rate = 1-smoothstep(D - d, D + d, length(gPos.x + uBetween.x) + n); rate *= uAreThereTwoPeopleTween; vec3 remapedColor = mix(remapedColorC, remapedColorW, rate); - float alpha = max(0, 1 - pow(gAge,4)); + float alpha = min(1, max(0, 1 - pow(gAge,4))); if(uEnergy > 0) { // alpha = 1; - alpha *= 0.3; + alpha *= 0.15; } else { alpha *= 0.1; diff --git a/zoneb/bin/data/shaders/particles/draw.geom b/zoneb/bin/data/shaders/particles/draw.geom index 608136d..a8259d3 100644 --- a/zoneb/bin/data/shaders/particles/draw.geom +++ b/zoneb/bin/data/shaders/particles/draw.geom @@ -47,6 +47,7 @@ void main() vec3 vOffset; if(uEnergy > 0) { if(gAge < 0.01) return; + if(length(gTarget.xyz) > 1000) return; vOffset = (vPrevPosition[i].xyz - vPosition[i].xyz); vOffset += normalize(vOffset) * 10; } diff --git a/zoneb/bin/data/shaders/particles/update.frag b/zoneb/bin/data/shaders/particles/update.frag index af88111..9874256 100755 --- a/zoneb/bin/data/shaders/particles/update.frag +++ b/zoneb/bin/data/shaders/particles/update.frag @@ -150,8 +150,8 @@ void main() float age = misc.y; if(age > 1) { // reached target - target.w = 0; if(vValid == 1) { // rebirth if point is valid + target.w = 0; age = 0; } } @@ -162,7 +162,7 @@ void main() age = 0; } else if (target.w > 0) { // targeted - age += 0.002; + age += 0.005; thermo = misc.x; } else { // wandering @@ -185,17 +185,17 @@ void main() force *= 100; } else { - 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); - force *= 100; + // 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); + // force *= 100; } if(age < 0.001) { // targetting target.w = 0; - if(random3(pos + vec3(u_time, 0, 0)).x > 2*pow(length(texCoordVarying.st/fraction - uHottest0.st)/25,0.5)) { + if(random3(pos + vec3(u_time, 0, 0)).x > 8*pow(length(texCoordVarying.st/fraction - uHottest0.st)/50,1)) { vec2 h = uHottest1.st; vec4 hray = texture(u_world, h); float hdepth = -depth * 65535.0; @@ -203,8 +203,9 @@ void main() vec3 H = vec3(hray.xy * hdepth, hdepth); target.xyz = H + random3(pos) * 3; target.w = 1; + thermo += random3(pos).y * 0.2 - 0.1; } - else if(random3(pos + vec3(u_time, 0, 0)).x > 2*pow(length(texCoordVarying.st/fraction - uHottest1.st)/25,0.5)) { + else if(random3(pos + vec3(u_time, 0, 0)).x > 8*pow(length(texCoordVarying.st/fraction - uHottest1.st)/50,1)) { vec2 h = uHottest0.st; vec4 hray = texture(u_world, h); float hdepth = -depth * 65535.0; @@ -212,6 +213,7 @@ void main() vec3 H = vec3(hray.xy * hdepth, hdepth); target.xyz = H + random3(pos) * 3; target.w = 1; + thermo += random3(pos).y * 0.2 - 0.1; } } diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index 3482f67..f2007cc 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -135,6 +135,8 @@ void ofApp::setupGui() gui.add(v4l2Delay.setup("thermo delay", 0, 0, 59)); gui.add(captureDeviceName.setup("device", "video3")); gui.add(blendAdd.setup("blend add", false)); + gui.add(renderTimes.setup("render times", 1, 1, 30)); + gui.add(traceTimes.setup("trace times", 3, 1, 30)); gui.loadFromFile("settings.xml"); gui.setPosition(10, 10); @@ -164,6 +166,13 @@ void ofApp::setup() fbos.insert({"energy", ofFbo()}); fbos.at("energy").allocate(ofGetWidth(), ofGetHeight(), GL_RGBA32F_ARB); + for (int i = 0; i < 30; i++) + { + traces.push_back(ofFbo()); + traces.back().allocate(ofGetWidth(), ofGetHeight(), GL_RGBA32F_ARB); + } + curTrace = 0; + for (auto s : gradientNames) { gradients.insert({s, ofFloatImage()}); @@ -347,7 +356,10 @@ void ofApp::drawMain() boundShader.setUniform1i("u_init", 1); boundShader.render(); boundShader.setUniform1i("u_init", 0); - boundShader.render(); + for (int i = 0; i < renderTimes; i++) + { + boundShader.render(); + } } void ofApp::drawDebug() @@ -365,7 +377,7 @@ void ofApp::draw() particles.whateverImages.at("u_world") = kinectDevice.getDepthToWorldTex(); particles.whateverImages.at("u_v4l2cam") = v4l2Buffer.at(v4l2BufferCount); - fbos.at("energy").begin(); + traces.at(curTrace).begin(); ofClear(0); cam.begin(); if (blendAdd) @@ -384,7 +396,19 @@ void ofApp::draw() ofDisableBlendMode(); } cam.end(); + traces.at(curTrace).end(); + + fbos.at("energy").begin(); + ofClear(0); + ofEnableBlendMode(OF_BLENDMODE_ADD); + for (int i = 0; i < traceTimes; i++) + { + int index = (curTrace - i + traces.size()) % traces.size(); + traces.at(index).draw(0, 0); + } + ofDisableBlendMode(); fbos.at("energy").end(); + curTrace = (curTrace + 1) % traces.size(); fbos.at("ofcam").begin(); ofClear(0); diff --git a/zoneb/src/ofApp.h b/zoneb/src/ofApp.h index eb58b0e..39de5a3 100644 --- a/zoneb/src/ofApp.h +++ b/zoneb/src/ofApp.h @@ -50,6 +50,8 @@ private: ofxShaderFilter boundShader; std::map fbos; + std::vector traces; + int curTrace; std::map gradients; std::vector gradientNames {"warm1", "warm2", "cold1", "cold2"}; @@ -74,6 +76,8 @@ private: ofxIntSlider v4l2Delay; ofxInputField captureDeviceName; ofxToggle blendAdd; + ofxIntSlider renderTimes; + ofxIntSlider traceTimes; ofxPanel gui; ofxToggle calibMode;