diff --git a/zoneb/bin/data/shaders/particles/update.frag b/zoneb/bin/data/shaders/particles/update.frag index 5ecc5c3..11a9b95 100755 --- a/zoneb/bin/data/shaders/particles/update.frag +++ b/zoneb/bin/data/shaders/particles/update.frag @@ -103,20 +103,6 @@ float simplex3d_fractal(vec3 m) { +0.0666667*simplex3d(8.0*m); } -vec2 stToV4l2(vec2 v) { - v *= 1.65; - v.s -= 115; - v.t -= 170; - return v; -} - -vec2 v4l2ToSt(vec2 v) { - v.s += 115; - v.t += 170; - v /= 1.65; - return v; -} - void main() { vec3 pos = texture(particles0, texCoordVarying.st).xyz; @@ -124,8 +110,7 @@ void main() vec3 misc = texture(particles2, texCoordVarying.st).xyz; vec4 target = texture(particles3, texCoordVarying.st).xyzw; - vec2 v4l2st = stToV4l2(texCoordVarying.st); - float thermo = texture2D(u_v4l2cam, v4l2st).r; + float thermo = texture2D(u_v4l2cam, texCoordVarying.st).r; float depth = texture(u_depth, texCoordVarying.st).x; vec4 ray = texture(u_world, texCoordVarying.st); @@ -169,15 +154,15 @@ void main() 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); - // force.x += cos(th) * cos(phi); - // force.y += sin(th) * cos(phi); - // force.z += sin(phi); - // force *= 100; + force.x += cos(th) * cos(phi); + force.y += sin(th) * cos(phi); + force.z += sin(phi); + force *= 100; if(age < 0.001) { target.w = 0; - if(random3(pos).x > pow(length(v4l2st - uHottest0.st)/20,16)+0) { - vec2 h = v4l2ToSt(uHottest1.st); + if(random3(pos).x > pow(length(texCoordVarying.st - uHottest0.st)/20,16)+0) { + vec2 h = uHottest1.st; vec4 hray = texture(u_world, h); float hdepth = -depth * 65535.0; if(hdepth == 0) hdepth = -0.01 * 65535.0; @@ -185,8 +170,8 @@ void main() target.xyz = H + random3(pos); target.w = 1; } - else if(random3(pos).x > pow(length(v4l2st - uHottest1.st)/50,16)+0) { - vec2 h = v4l2ToSt(uHottest0.st); + else if(random3(pos).x > pow(length(texCoordVarying.st - uHottest1.st)/20,16)+0) { + vec2 h = uHottest0.st; vec4 hray = texture(u_world, h); float hdepth = -depth * 65535.0; if(hdepth == 0) hdepth = -0.01 * 65535.0; @@ -199,8 +184,8 @@ void main() if(target.w > 0) { float th = atan(-pos.y + target.y, -pos.x + target.x); float phi = atan(-pos.z + target.z, length(target.xy-pos.xy)); - th += 3.1415 / 2 * simplex3d_fractal(vec3(pos.xyz * 0.001)); - phi += 3.1415 / 2 * simplex3d_fractal(pos.xyz * 0.001); + th += 3.1415 / 4 * simplex3d_fractal(vec3(pos.xyz * 0.001)); + phi += 3.1415 / 4 * simplex3d_fractal(pos.xyz * 0.001); force.x = cos(th) * cos(phi); force.y = sin(th) * cos(phi); force.z = sin(phi); diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index ad5dcfd..8f9a64c 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -51,9 +51,16 @@ void ofApp::setupThermal() // we use a texture because the ofxV4L2 class has no draw method (yet) // we use GL_LUMINANCE because the ofxV4L2 class supports only grayscale (for now) - v4l2Tex.allocate(camWidth, camHeight, GL_RGB); + v4l2Tex.allocate(512, 512, GL_RGB); - v4l2Pixels.allocate(camWidth, camHeight, OF_PIXELS_RGB); + v4l2Pixels.allocate(512, 512, OF_PIXELS_RGB); + for (int i = 0; i < 512; i++) + { + for (int j = 0; j < 512; j++) + { + v4l2Pixels.setColor(j, i, 0); + } + } } void ofApp::setup() @@ -139,16 +146,20 @@ void ofApp::updateThermal() { hotspots.push_back(std::vector()); } - int count = 0; - for (int i = 0; i < camHeight; i++) + for (int i = 0; i < 512; i++) { - for (int j = 0; j < camWidth; j++) + for (int j = 0; j < 512; j++) { - int a = v4l2Cam.getPixels()[count / 3]; - v4l2Pixels.setColor(count++, a); - v4l2Pixels.setColor(count++, a); - v4l2Pixels.setColor(count++, a); - if (i % 4 == 0 && j % 4 == 0 && i > 80) + int x = j * 1.65 - 115; + int y = i * 1.65 - 170; + if (ofInRange(x, 0, camWidth - 1) == false || ofInRange(y, 0, camHeight - 1) == false) + { + continue; + } + int count = x + y * camWidth; + int a = v4l2Cam.getPixels()[count]; + v4l2Pixels.setColor(j, i, a); + if (i % 4 == 0 && j % 4 == 0) { auto c = body.getColor(j, i); if (c.r < hotspots.size()) @@ -198,9 +209,9 @@ void ofApp::onParticlesUpdate(ofxShader &shader) { shader.setUniform3f("uHottest1", hotspots.at(1).at(0)); } - else if (hotspots.size() > 0 && hotspots.at(0).size() > 0) { + else if (hotspots.size() > 0 && hotspots.at(0).size() > 0) + { shader.setUniform3f("uHottest1", hotspots.at(0).at(1)); - } } @@ -244,7 +255,6 @@ void ofApp::draw() cam.end(); } drawDebug(); - kinectDevice.getBodyIndexTex().draw(0, 0, 360, 360); } void ofApp::keyPressed(int key)