Commits

Cliff Biffle  committed 0bddf46

Surface readings are now drawn as point sprites, scaled with both distance from the Kinect and distance from the eyepoint. (Scaling is slightly wrong, in that it doesn't consider true viewport size.)

  • Participants
  • Parent commits d0f32bb
  • Branches shaders

Comments (0)

Files changed (2)

File KVRenderer.m

   glLinkProgram(program);
   glUseProgram(program);
   
+  glEnable(GL_POINT_SPRITE);
+  glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
+
   GLint depthUniform = glGetUniformLocation(program, "depthTex");
   glUniform1i(depthUniform, 0);
   
  */
 void main() {
   vec4 vertex = kinect_unproject(depthTex, gl_Vertex);
-  
+  vec4 eyeVertex = gl_ModelViewMatrix * vertex;
   // Project the point using GL's perspective settings.
-  gl_Position = gl_ModelViewProjectionMatrix * vertex;
+  gl_Position = gl_ProjectionMatrix * eyeVertex;
   
   // Calculate the vertex normal in Kinect-camera space.
   vec4 rightVertex = kinect_unproject(depthTex, gl_Vertex + vec4(pixelDistanceX, 0, 0, 0));
   } else {
     gl_FrontColor = gl_Color;
   }
+  
+  vec3 eyeVertex3 = eyeVertex.xyz / eyeVertex.w;
+  float distance = -eyeVertex3.z;
+  float baseSize = vertex3.z * 1.9;
+  gl_PointSize = baseSize / (distance);
 }