Hi all,
Here’s the problem. I’m rendering a scene (512x512) on my nVidia GF3 at about 750 FPS.
What I want is the range from the eye position to every pixel in the scene and would like to store that in a 512x512 array. So I used the following code (mostly from previous posts in this forum):
…
…
glReadPixels(0, 0, WindowX, WindowY, GL_DEPTH_COMPONENT, GL_FLOAT, winz);
glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
int count = 0;
for (int i = 0; i < WindowX; i++) {
for (int j = 0; j < WindowY; j++) {
gluUnProject((GLdouble)i, (GLdouble)j, (GLdouble)winz[count], modelMatrix,
projMatrix, viewport, &objx, &objy, &objz);
distance2eyepoint = (GLfloat)(sqrt((objx-eyex)(objx-eyex) +
(objy-eyey)(objy-eyey) +
(objz-eyez)*(objz-eyez)));
count++;
}
}
…
…
I must admit that I was shocked at the drop in FPS. I didn’t expect it to be this bad:
Just rendering: 750 FPS
Rendering with glReadPixels only: 115 FPS
all the above + the for loops: 4.4 FPS
There must be a way to extract true range information without killing performance, isn’t there? Can someone please point it out for me. How about extensions, would they help? It’s driving me nuts…
TIA,
GGL