fix depth cropped issue (properly)

This commit is contained in:
micuat 2020-10-19 11:02:40 +02:00
parent 2c8d9789de
commit ed61bd152f
2 changed files with 4 additions and 1 deletions

View file

@ -12,6 +12,7 @@ uniform sampler2D uDepthTex; // Sampler for the depth space data
uniform sampler2D uWorldTex; // Transformation from kinect depth/color space to kinect world space uniform sampler2D uWorldTex; // Transformation from kinect depth/color space to kinect world space
uniform ivec2 uFrameSize; uniform ivec2 uFrameSize;
uniform ivec2 uDepthFrameSize;
uniform vec2 u_resolution; uniform vec2 u_resolution;
@ -21,7 +22,7 @@ flat out int vValid;
void main() void main()
{ {
vTexCoord = vec2(gl_InstanceID % uFrameSize.x, gl_InstanceID / uFrameSize.x)/vec2(512,424); vTexCoord = vec2(gl_InstanceID % uFrameSize.x, gl_InstanceID / uFrameSize.x) / uDepthFrameSize;
float depth = texture2D(uDepthTex, vTexCoord).x; float depth = texture2D(uDepthTex, vTexCoord).x;
vec4 ray = texture2D(uWorldTex, vTexCoord); vec4 ray = texture2D(uWorldTex, vTexCoord);

View file

@ -84,6 +84,7 @@ void ofApp::draw()
shader.setUniformTexture("uWorldTex", kinectDevice.getColorToWorldTex(), 2); shader.setUniformTexture("uWorldTex", kinectDevice.getColorToWorldTex(), 2);
shader.setUniformTexture("uColorTex", kinectDevice.getColorTex(), 3); shader.setUniformTexture("uColorTex", kinectDevice.getColorTex(), 3);
shader.setUniform2i("uFrameSize", kinectDevice.getColorTex().getWidth(), kinectDevice.getColorTex().getHeight()); shader.setUniform2i("uFrameSize", kinectDevice.getColorTex().getWidth(), kinectDevice.getColorTex().getHeight());
shader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthInColorTex().getWidth(), kinectDevice.getDepthInColorTex().getHeight());
numPoints = kinectDevice.getColorTex().getWidth() * kinectDevice.getColorTex().getHeight(); numPoints = kinectDevice.getColorTex().getWidth() * kinectDevice.getColorTex().getHeight();
} }
@ -93,6 +94,7 @@ void ofApp::draw()
shader.setUniformTexture("uWorldTex", kinectDevice.getDepthToWorldTex(), 2); shader.setUniformTexture("uWorldTex", kinectDevice.getDepthToWorldTex(), 2);
shader.setUniformTexture("uColorTex", kinectDevice.getColorInDepthTex(), 3); shader.setUniformTexture("uColorTex", kinectDevice.getColorInDepthTex(), 3);
shader.setUniform2i("uFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight()); shader.setUniform2i("uFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight());
shader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight());
numPoints = kinectDevice.getDepthTex().getWidth() * kinectDevice.getDepthTex().getHeight(); numPoints = kinectDevice.getDepthTex().getWidth() * kinectDevice.getDepthTex().getHeight();
} }