Jump to content
  • Advertisement
Sign in to follow this  
etothex

OpenGL Losing precision

This topic is 5019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :) )

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!