2
uniform mat4 kinect_to_world_matrix;
3
uniform mat4 view_matrix;
4
uniform mat4 projection_matrix;
5
uniform sampler2D camTexture;
6
uniform float camXReso;
7
uniform float camYReso;
8
uniform float camXZFactor;
9
uniform float camYZFactor;
10
uniform float mirrored;
15
varying float fragTest;
19
gl_FrontColor = gl_FrontMaterial.diffuse;
21
gl_TexCoord[0] = gl_MultiTexCoord0;
23
//get depth pixel in camera texture
24
float depth = float(texture2D(camTexture, vec2(vertex.x/camXReso,
25
vertex.y/camYReso)).r)
29
//keep only if non zero and if distance to neighbours is small enough
30
if(depth<=500.0 || depth>5000.0) {
35
float depth2 = float(texture2D(camTexture,
36
vec2((vertex.x+1.0)/camXReso,
37
vertex.y/camYReso)).r)
39
float depth3 = float(texture2D(camTexture,
40
vec2((vertex.x+1.0)/camXReso,
41
(vertex.y+1.0)/camYReso)).r)
44
if(abs(depth-depth2)>max || abs(depth-depth3)>max) {
49
//compute position in world coords
50
vec4 depthPos = vec4((vertex.x/camXReso-0.5)
51
*depth*camXZFactor/1000.0,
52
(0.5-(vertex.y/camYReso))
53
*depth*camYZFactor/1000.0,
56
//multiply by kinect to projector matrix and projection matrix
57
vec4 posWS = kinect_to_world_matrix * depthPos;
61
gl_Position = projection_matrix * view_matrix * posWS;
62
//gl_Position = vec4(vertex.x/camXReso, vertex.y/camYReso, 0.0, 1.0);
63
viewRay = posWS.xyz - vec3(-view_matrix[3][0],