Chaining vertex programs

I am chaining vertex programs together using a VBO/PBO combination. I want the output of the first vertex program to be pumped into the second vertex program. I then read the data back using ReadPixel (everything is done in a FBO). For debugging purposes and simplicity, I am outputting the vertex position as the color such that the first glVertex3f I do will end up being the first 3 floats of the buffer returned by ReadPixel (and so on).

I am going glVertex3f (0.2,0.3,0.4)
The result when I do not do any chaining (ie. I do not pipe the results using the PBO to a second vertex shader) is as it should: 0.2, 0.3, 0.4.

But, when I pipe the result to another VBO with my PBO and redraw using the same vertex program I get 0.19995117, 0.29809570, 0.39990234!

If I hardcode values in the vertex program, everything’s fine, the precision loss must when I bind the pbo to the array buffer… but why! :confused:

any ideas?

Floating point math is not exact…

It’s not a problem of floating point math.

Try this:

  • Make a 64x64 viewport
  • Make a vertex shader that outputs the TEXCOORD0 into the position and a fragment shader that outputs these into the framebuffer. (in absbolute value)
  • To make sure the point gets rasterized, output -1, -1 as a texture coordinate (this will end end as the first pixel in the frame buffer).
  • glBegin ( GL_POINTS );
  • glVertex3f (0,0,0);
  • glTexCoord2f ( -1,-1);
  • Now if you readpixel, you get 1,1,0 as the first RGB pixel.

Now try the same steps, but output in an FBO. You get an error on the Y coordinate. It seems the framebuffer is shifted up one pixel.

I think it’s a driver bug.

nVidia Quadro FX 4000, latest driver.

Quick comment: If you’re using 16bit floatingpoint, you might want to try out 32bit instead.