Losing precision

Started by
3 comments, last by zedzeek 19 years, 6 months ago
So here's the deal: I have an opengl app, on linux, with an nvidia geforce fx 5700 ultra, latest nvidia drivers. I'm using Cg, and I render something in two passes; first pass, I draw a quad, using one fragment program, then use glcopysubtex2d to copy the result to a texture, then use that texture later as input to another fragment program. Problem is, I lose precision in the process. the red component output of the first fragment program needs more than 256 distinct values (at least 16 bits I think), otherwise the 2nd fragment program doesn't get enough detail as input and I end up with sharply defined spots on my final output. I found the GL_NV_float_buffer extension, changed my program to use GL_TEXTURE_RECTANGLE_NV instead of GL_TEXTURE_2D, and tried it. No difference, then I realized the output goes to the framebuffer first before it goes to the texture. So I looked up the GLX_SGIX_pbuffer extension, implemented it, and now it doesn't work at all if I give it more than 8 bits for any color value. Apparently it only works on the NV40 (Geforce 6200, 6600, 6800) series. So anything I can do? Besides shelling out a lot of money to replace a card I bought a month ago. (Hope I was clear enough :) )
Advertisement
Have you tried another fragmenter?
-"What would you say to the kids of Columbine?"-"I wouldn't say a single word to them. I'd listen to what they had to say. That's what no one did."-Marilyn Manson
Do you need more than 8 bits of precision on all color chanels or just on some? If you only need it on some then you could pack it in 2 chanels (red & alpha) and unpack it in second FP.
You should never let your fears become the boundaries of your dreams.
Quote:Original post by _DarkWIng_
Do you need more than 8 bits of precision on all color chanels or just on some? If you only need it on some then you could pack it in 2 chanels (red & alpha) and unpack it in second FP.


Any good sites/tutorials/code/anything that shows how to do this? I've googled a little bit but I haven't found anything yet.

But yeah, if I could figure out how to do that it would probably solve my problem.
its very easy to do if youre using glsl
eg
vec4 sample = texture2D( tex0, gl_TexCoord[0].xy ).rgb;
float answer = sample.x * 256.0 + sample.y;
or whatever

This topic is closed to new replies.

Advertisement