From 2b6f7059a67d4bc82522ccf0ef0b2adf7b479bc8 Mon Sep 17 00:00:00 2001 From: micuat Date: Mon, 26 Oct 2020 12:22:40 +0100 Subject: [PATCH] fixing thermo mapped pos?? --- zoneb/bin/data/shaders/particles/draw.frag | 15 ++++++++++++--- zoneb/bin/data/shaders/particles/draw.vert | 4 +++- zoneb/src/ofApp.cpp | 7 ++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/zoneb/bin/data/shaders/particles/draw.frag b/zoneb/bin/data/shaders/particles/draw.frag index 628ed5d..4961d68 100755 --- a/zoneb/bin/data/shaders/particles/draw.frag +++ b/zoneb/bin/data/shaders/particles/draw.frag @@ -9,14 +9,23 @@ uniform sampler2DRect imageTexture; uniform vec3 uHottest0; uniform vec3 uHottest1; +uniform vec3 uHottest3d0; +uniform vec3 uHottest3d1; in vec2 texCoordVarying; +in vec3 vPos; in float vTemperature; in float vAge; void main() { - vec3 remapedColor = texture(imageTexture, vec2(vTemperature*1600, 0.5)).xyz; - float alpha = max(0, 1 - pow(vAge,4)); - fragColor = vec4(remapedColor, alpha); + vec3 remapedColor = texture(imageTexture, vec2(vTemperature*1600, 0.5)).xyz; + float alpha = max(0, 1 - pow(vAge,4)); + + vec4 color = vec4(remapedColor, alpha); + + if(length(vPos.x - uHottest3d1.x) < 500) { + color = vec4(0,1,0,1); + } + fragColor = color; } diff --git a/zoneb/bin/data/shaders/particles/draw.vert b/zoneb/bin/data/shaders/particles/draw.vert index 449e9da..96a7ebf 100755 --- a/zoneb/bin/data/shaders/particles/draw.vert +++ b/zoneb/bin/data/shaders/particles/draw.vert @@ -7,6 +7,7 @@ in vec4 position; in vec2 texcoord; out vec2 texCoordVarying; +out vec3 vPos; out float vTemperature; out float vAge; @@ -16,5 +17,6 @@ void main() vec4 misc = texture(particles2, texCoordVarying); vTemperature = misc.x; vAge = misc.y; - gl_Position = modelViewProjectionMatrix * vec4(texture(particles0, texCoordVarying).xyz, 1.0); + vPos = texture(particles0, texCoordVarying).xyz; + gl_Position = modelViewProjectionMatrix * vec4(vPos, 1.0); } diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index ce19711..2251dd6 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -161,9 +161,10 @@ void ofApp::exit() ofVec3f ofApp::getDepthAt(int x, int y) { auto ray = kinectDevice.getDepthToWorldPix().getColor(x, y); - float depth = kinectDevice.getDepthPix().getColor(x, y).r; - if (depth == 0) - depth = 2000; + auto depthShort = kinectDevice.getDepthPix().getColor(x, y).r; + float depth = -depthShort; + if (depthShort == 0) + depth = -2000; ofVec3f pos(ray.r * depth, ray.g * depth, depth); return pos; }