I am developing some GPU raycasting volume rendering and I encountered some precision problems.
To retrieve starting and ending points, I draw bounding box’s front faces and back faces on FBO and set them as input of my cg fragment shader.
The problem is that the direction computed is not accurate when I zoom on the volume (when the camera is far away it looks fine, but when I move on, big pixels effect appear)
The color textures are defined as:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F_ARB, mWindowWidth, mWindowHeight,0, GL_RGBA, GL_FLOAT, 0);
My graphic card is GeForce7600GT
Have you experience the same thing? How could I retrieve accurate 3D positions?
First, using RGBA16F will be enough and faster. I’m using this and clamp_to_edge for texparameters.
Without seeing a picture of your result it’s difficult to say, but I guess you should change the stepsize in your shader. How many iterations are you doing and what is your stepsize?
Thanks for your reply,
I changed with RGBA16F but it’s not better unfortunately.
I noticed something strange to me.
If I don’t use the FBO and compute the direction vector with the camera position and the first position encoded with texture coordinate everything is ok I get perfect rendering
But If I use the position encoded with color, I get the same effect as FBO sort of big aliasing…
It seems that I don’t get float precision encoding position with colors, maybe I only have 8bit precision per component…
But I need to store these intermediate results (sarting 3D position) in texture… Is there any R32G32B32 texture format??? How can I do that?
Thanks in advance
RGBA16F means 16bit float for each channel.
In your first post you are using three components for internal format, but four for format. Correct that and test with glGetError()!
You are using glColor3f for the coordinates,aren’t you?
First you could try to render the rays with and without using the FBO to test if this looks the same.
when passing color from vertex to pixel shader (I mean, vertex output and pixel input COLOR0 and COLOR1), theay are evaluated with limited precision on most hardware. If you need float precision - pass them via TEXCOORD.
Thanks for your answers,
Indeed this is something I have noticed, there is a loss of precision using color instead of texcoord; but is there the same loss if I use FBO with color textures attached on?
I tried to better explain my problem here : http://alfalf3.neuf.fr/
I am wondering why I can’t get the same precision rendering front faces on FBO and use them in my pixel shader?
You solved my problem.
I didn’t realize that I had also to use other shaders to build my FBO from texcoord.
Thanks for your help