/usr/share/psychtoolbox-3/PsychOpenGL/PsychGLSLShaders/KinectShaderCompressed.vert.txt is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | /*
* File: KinectShaderCompressed.vert.txt
* Shader for conversion of Microsoft Kinect raw sensor data to
* 3D vertex and texture coordinate stream for realtime rendering.
*
* This implements mapping of raw depths sensor values to (x,y,z)
* vertex positions, plus standard modelview+projection transforms
* of the reconstructed vertex.
*
* It also implements generation of proper 2D texture coordinates
* for mapping the image of the color camera onto the 3D point cloud/
* mesh, plus standard texture matrix transforms on the reconstructed
* texture coordinates.
*
* This vertex shader is setup and used by PsychKinect.m.
*
* (c) 2010 by Mario Kleiner, licensed under MIT license.
*
*/
uniform vec4 depth_intrinsic;
uniform vec4 rgb_intrinsic;
uniform vec3 T;
uniform mat3 R;
uniform vec2 depth_base_and_offset;
void main()
{
vec4 v, t;
vec3 tm, inpos;
/* Get (x,y) position in depth sensor matrix and z as pixels depth: */
inpos.x = (mod(gl_Vertex.x, 640.0));
inpos.y = (gl_Vertex.x / 640.0);
inpos.z = gl_Vertex.y;
/* Remap inpos.z via mapping formula kinect -> real world: */
if (inpos.z < 2047.0) {
if (depth_base_and_offset[0] != 0.0) {
inpos.z = 540.0 * 8.0 * depth_base_and_offset[0] / (depth_base_and_offset[1] - inpos.z);
} else {
inpos.z = 1.0 / (inpos.z * -0.0030711016 + 3.3309495161);
}
gl_FrontColor = gl_Color;
} else {
inpos.z = 100.0;
gl_FrontColor = vec4(1.0, 1.0, 1.0, 0.0);
}
/* This does not help a single bit, unfortunately: */
/*
if (depth_base_and_offset[0] != 0.0) {
tm.x = (inpos.x - depth_intrinsic.z) / depth_intrinsic.x;
tm.y = (inpos.y - depth_intrinsic.w) / depth_intrinsic.y;
tm.z = 1.0;
tm = normalize(tm) * inpos.z;
v.xyz = tm.xyz;
v.w = 1.0;
}
*/
/* Map back to 3D Vertex in depth cams reference frame: */
v.x = (inpos.x - depth_intrinsic.z) * inpos.z / depth_intrinsic.x;
v.y = (inpos.y - depth_intrinsic.w) * inpos.z / depth_intrinsic.y;
v.z = inpos.z;
v.w = 1.0;
/* Map to color cameras frame of reference: */
tm = (R * v.xyz) + T;
/* Map to (x,y) texture coordinates in color cameras sensor plane: */
t.x = ( tm.x * rgb_intrinsic.x / tm.z ) + rgb_intrinsic.z;
t.y = ( tm.y * rgb_intrinsic.y / tm.z ) + rgb_intrinsic.w;
t.z = 0.0;
t.w = 1.0;
/* Apply standard geometric transformations to 3D vertex: */
gl_Position = gl_ModelViewProjectionMatrix * v;
/* Apply standard texture matrix transformation to texcoords: */
gl_TexCoord[0] = gl_TextureMatrix[0] * t;
}
|