From fe9c40f859a0e2e4b890ab0f6410ad9e5d742a0a Mon Sep 17 00:00:00 2001 From: micuat Date: Sat, 31 Oct 2020 17:42:54 +0100 Subject: [PATCH] reso --- zoneb/bin/data/settings.xml | 7 ++- zoneb/bin/data/shaders/particles/draw.frag | 2 +- zoneb/bin/data/shaders/particles/update.frag | 63 +++++++++++++------- zoneb/src/main.cpp | 1 + zoneb/src/ofApp.cpp | 53 ++++++++++------ 5 files changed, 82 insertions(+), 44 deletions(-) diff --git a/zoneb/bin/data/settings.xml b/zoneb/bin/data/settings.xml index 7d181ef..358aaf2 100644 --- a/zoneb/bin/data/settings.xml +++ b/zoneb/bin/data/settings.xml @@ -1,7 +1,8 @@ - 61.2245, -12.2449 - 1.869 - video1 + 61.2245, 0 + 1.7965 + video3 7 + 1 diff --git a/zoneb/bin/data/shaders/particles/draw.frag b/zoneb/bin/data/shaders/particles/draw.frag index 20bbb34..d158c66 100755 --- a/zoneb/bin/data/shaders/particles/draw.frag +++ b/zoneb/bin/data/shaders/particles/draw.frag @@ -113,7 +113,7 @@ void main() 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)) * 1; + float alpha = max(0, 1 - pow(vAge,4)) * .3; // if(vTemperature < 0.5) { // alpha *= vTemperature * 2; diff --git a/zoneb/bin/data/shaders/particles/update.frag b/zoneb/bin/data/shaders/particles/update.frag index a5999d6..2c650de 100755 --- a/zoneb/bin/data/shaders/particles/update.frag +++ b/zoneb/bin/data/shaders/particles/update.frag @@ -116,21 +116,31 @@ void main() float thermo = texture2D(u_v4l2cam, texCoordVarying.st/fraction).r; 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)); + vec2 basePix = texCoordVarying.st/fraction - subPix; + float depth00 = texture(u_depth, basePix + vec2(0, 0)).x; + float depth01 = texture(u_depth, basePix + vec2(0, 1)).x; + float depth10 = texture(u_depth, basePix + vec2(1, 0)).x; + float depth11 = texture(u_depth, basePix + vec2(1, 1)).x; + vec4 ray00 = texture(u_world, basePix + vec2(0, 0)); + vec4 ray01 = texture(u_world, basePix + vec2(0, 1)); + vec4 ray10 = texture(u_world, basePix + vec2(1, 0)); + vec4 ray11 = texture(u_world, basePix + vec2(1, 1)); - float depth = mix(depth0, depth1, length(subPix)); - vec4 ray = mix(ray0, ray1, length(subPix)); + float depth0 = mix(depth00, depth10, subPix.x); + float depth1 = mix(depth01, depth11, subPix.x); + vec4 ray0 = mix(ray00, ray10, subPix.x); + vec4 ray1 = mix(ray01, ray11, subPix.x); - float vValid = (depth0 != 0 && depth1 != 0 && ray.x != 0 && ray.y != 0) ? 1 : 0; + float depth = mix(depth0, depth1, subPix.y); + vec4 ray = mix(ray0, ray1, subPix.y); + + float vValid = (depth00 != 0 && depth01 != 0 && depth10 != 0 && depth11 != 0 && ray.x != 0 && ray.y != 0) ? 1 : 0; vec4 posWorld = vec4(1); 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; + // posWorld.xyz += random3(posWorld.xyz) * 2; float age = misc.y; if(age > 1) { // reached target @@ -146,31 +156,40 @@ void main() target.xyz = pos; } else if (target.w > 0) { // targeted - age += 10.01; + age += 0.002; thermo = misc.x; } else { // wandering - age += 10.02; - // age += 0.01; + age += 0.02; thermo = misc.x; } - // if(vValid == 1 && target.w > 0 && length(target.xy - pos.xy) < 100) { // arrived - // age += 0.03; - // } + if(vValid == 1 && target.w > 0 && length(target.xy - pos.xy) < 100) { // arrived + age += 0.03; + } // wandering vec3 force = vec3(0,0,0); - 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(vValid == 1 && target.w == 0) { + float th = 3.1415 * 4 * simplex3d_fractal(vec3(pos.xyz * 0.001)); + float phi = 3.1415 * simplex3d_fractal(pos.xyz * 0.002); + force.x += cos(th) * cos(phi); + force.y += sin(th) * cos(phi); + force.z += sin(phi); + 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; + } if(age < 0.001) { // targetting target.w = 0; - if(random3(pos).x > pow(length(texCoordVarying.st/fraction - uHottest0.st)/5,16*16)+0) { + if(random3(pos).x > 0.5*pow(length(texCoordVarying.st/fraction - uHottest0.st)/5,1)) { vec2 h = uHottest1.st; vec4 hray = texture(u_world, h); float hdepth = -depth * 65535.0; @@ -184,7 +203,7 @@ void main() // target.xyz = H + random3(pos); // target.w = 1; } - else if(random3(pos).x > pow(length(texCoordVarying.st/fraction - uHottest1.st)/5,16*16)+0) { + else if(random3(pos).x > 0.5*pow(length(texCoordVarying.st/fraction - uHottest1.st)/5,1)) { vec2 h = uHottest0.st; vec4 hray = texture(u_world, h); float hdepth = -depth * 65535.0; diff --git a/zoneb/src/main.cpp b/zoneb/src/main.cpp index 6c48ca5..c94f387 100644 --- a/zoneb/src/main.cpp +++ b/zoneb/src/main.cpp @@ -15,6 +15,7 @@ int main( ){ #else ofGLWindowSettings settings; settings.setGLVersion(3, 2); // Programmable pipeline + settings.setSize(1920, 1200); #endif ofCreateWindow(settings); ofRunApp(new ofApp()); diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index 851e45a..11c1929 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -138,8 +138,8 @@ void ofApp::setupGui() debugGui.setup("DEBUG"); debugGui.add(calibMode.setup("calib", false)); - debugGui.add(dummyMode.setup("dummy", true)); // should be false - debugGui.add(dummyXY.setup("XY", {0, 0}, {-500, -1000}, {500, 500})); // should be false + debugGui.add(dummyMode.setup("dummy", true)); // should be false + debugGui.add(dummyXY.setup("XY", {0, 0}, {-500, -500}, {500, 500})); // should be false debugGui.add(debugFps.setup("FPS", "0")); debugGui.setPosition(230, 10); } @@ -233,26 +233,35 @@ void ofApp::updateThermal() std::sort(hotspots.at(i).begin(), hotspots.at(i).end(), compareZThermal); } - if (hotspots.size() > 0 && hotspots.at(0).size() > 0) + if (dummyMode == false) { - hotspot0 = hotspots.at(0).at(0); - } - if (hotspots.size() > 1 && hotspots.at(1).size() > 0) - { - hotspot1 = hotspots.at(1).at(0); - areThereTwoPeople = true; - areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween + 0.02, 0, 1); - } - else if (dummyMode == true && (hotspots.size() > 0 && hotspots.at(0).size() > 1)) - { - hotspot1 = hotspots.at(0).at(1); - areThereTwoPeople = true; - areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween + 0.02, 0, 1); + if (hotspots.size() > 0 && hotspots.at(0).size() > 0) + { + hotspot0 = hotspots.at(0).at(0); + } + if (hotspots.size() > 1 && hotspots.at(1).size() > 0) + { + hotspot1 = hotspots.at(1).at(0); + areThereTwoPeople = true; + areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween + 0.02, 0, 1); + } + else + { + areThereTwoPeople = false; + areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween - 0.02, 0, 1); + } } else { - areThereTwoPeople = false; - areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween - 0.02, 0, 1); + if (hotspots.size() > 0 && hotspots.at(0).size() > 0) + { + hotspot0 = hotspots.at(0).at(0); + } + { + hotspot1 = ofVec3f(dummyXY->x + 500, dummyXY->y + 500, 0); + areThereTwoPeople = true; + areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween + 0.02, 0, 1); + } } hotspot3d0 = getDepthAt(hotspot0.x, hotspot0.y); @@ -373,6 +382,14 @@ void ofApp::draw() void ofApp::keyPressed(int key) { + if (key == 'f') + { + ofSetFullscreen(true); + } + if (key == 'g') + { + ofSetFullscreen(false); + } } void ofApp::keyReleased(int key)