boundary is back
This commit is contained in:
parent
d07ef8f779
commit
3390203fd7
2 changed files with 26 additions and 22 deletions
|
@ -2,11 +2,11 @@
|
|||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform sampler2D u_depth;
|
||||
uniform sampler2D u_ofcam;
|
||||
uniform sampler2D u_v4l2cam;
|
||||
uniform sampler2D u_buffer0;
|
||||
uniform sampler2D u_buffer1;
|
||||
uniform sampler2DRect u_depth;
|
||||
uniform sampler2DRect u_ofcam;
|
||||
uniform sampler2DRect u_v4l2cam;
|
||||
uniform sampler2DRect u_buffer0;
|
||||
uniform sampler2DRect u_buffer1;
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
uniform vec2 u_mouse;
|
||||
|
@ -17,13 +17,13 @@ uniform bool u_init;
|
|||
varying vec2 v_texcoord;
|
||||
|
||||
float depthToSilhouette(float depth) {
|
||||
if(depth <= 0.0) return 0;
|
||||
if(depth <= 0.4) return 0;
|
||||
// if(depth > 0.1) return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 pixel = 1./u_resolution;
|
||||
vec2 pixel = vec2(1.0);//./u_resolution;
|
||||
vec2 offset[9];
|
||||
offset[0] = pixel * vec2(-1.0,-1.0);
|
||||
offset[1] = pixel * vec2( 0.0,-1.0);
|
||||
|
@ -49,8 +49,8 @@ void main() {
|
|||
// BUFFER_1 (u_buffer1)
|
||||
vec4 color = vec4(0,0,0,1);
|
||||
if(u_init) {
|
||||
vec3 tmpc = texture2D(u_ofcam, st).rgb;
|
||||
float tmp = tmpc.r + tmpc.g + tmpc.b;
|
||||
vec3 tmpc = texture(u_ofcam, st).rgb;
|
||||
float tmp = tmpc.r;// + tmpc.g + tmpc.b;
|
||||
color.rgb = vec3(depthToSilhouette(tmp));
|
||||
}
|
||||
else {
|
||||
|
@ -69,7 +69,7 @@ void main() {
|
|||
float lap = 0;
|
||||
|
||||
for (int i=0; i < 9; i++){
|
||||
float tmp = texture2D(u_buffer1, st + offset[i]).r;
|
||||
float tmp = texture(u_buffer1, st + offset[i]).r;
|
||||
lap += tmp * kernel[i] / 2.5;
|
||||
}
|
||||
color = vec4(vec3(lap * 2.0), 1.0);
|
||||
|
@ -83,31 +83,29 @@ void main() {
|
|||
// Note: Just copy the content of the BUFFER0 so it can be
|
||||
// read by it in the next frame
|
||||
//
|
||||
gl_FragColor = texture2D(u_buffer0, st);
|
||||
gl_FragColor = texture(u_buffer0, st);
|
||||
#else
|
||||
// Main Buffer
|
||||
float buf1 = texture2D(u_buffer1, st).r;
|
||||
float buf1 = texture(u_buffer1, st).r;
|
||||
vec3 dispColor = vec3(0, 0, 0);
|
||||
vec4 pointCloudColor = texture2D(u_ofcam, st);
|
||||
vec4 pointCloudColor = texture(u_ofcam, st);
|
||||
|
||||
float maxVal = buf1;
|
||||
float minVal = buf1;
|
||||
float maxVal = 0;
|
||||
float minVal = 1;
|
||||
for (int i=0; i < 9; i++){
|
||||
float tmp = texture2D(u_buffer1, st + offset[i]).r;
|
||||
float tmp = texture(u_buffer1, st + offset[i]/4).r > 0.5 ? 1 : 0;
|
||||
maxVal = max(maxVal, tmp);
|
||||
minVal = min(minVal, tmp);
|
||||
}
|
||||
|
||||
if(maxVal - minVal > 0.8) {
|
||||
if(maxVal - minVal >= 0.5) {
|
||||
dispColor.rgb = vec3(1);
|
||||
}
|
||||
|
||||
// dispColor.rgb = vec3(depthToSilhouette(texture2D(u_depth, st/u_resolution).r));
|
||||
// dispColor.rgb = vec3(depthToSilhouette(texture(u_depth, st/u_resolution).r));
|
||||
gl_FragColor = vec4(dispColor, 1.0);
|
||||
gl_FragColor += pointCloudColor; // not good
|
||||
gl_FragColor = vec4(pointCloudColor.rgb, 1.0); // not good
|
||||
|
||||
// gl_FragColor = texture2D(u_v4l2cam, st/3);
|
||||
gl_FragColor.rgb += pointCloudColor.rgb; // not good
|
||||
// gl_FragColor = texture(u_buffer1, st); // not good
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -263,9 +263,15 @@ void ofApp::draw()
|
|||
particles.whateverImages.at("u_world") = kinectDevice.getDepthToWorldTex();
|
||||
particles.whateverImages.at("u_v4l2cam") = v4l2Tex;
|
||||
|
||||
fbos.at("ofcam").begin();
|
||||
ofClear(0);
|
||||
cam.begin();
|
||||
particles.draw();
|
||||
cam.end();
|
||||
fbos.at("ofcam").end();
|
||||
|
||||
drawMain();
|
||||
boundShader.draw(0, 0);
|
||||
}
|
||||
drawDebug();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue