View Full Version : While the value in float pixel buffer is not accurate?

11-16-2004, 04:20 AM
I set the color (0.5,0,0,0.5) to an vertex, but the value in p-buffer is (0.50195313,0,0,0.50195313). What is wrong with my p-buffer?

Thanks very much!

11-16-2004, 04:41 AM
maybe the problem is in the way the float value is internally converted. instead of

glColor3f(0.5, 0.5, 0.5);

you should better use

glColor3ub(128, 128, 128);

when your display is set to 24 bit depth, the three unsigned bytes are used without being converted.

11-17-2004, 09:45 PM
Thank you for your reply.

But I can't set ubyte color in my program, because I need to set the output of vertex processor to colors, which is float.

Will other float buffer, such as PBO, avoid this problem?

11-18-2004, 01:25 AM

Quick rehash:
128/255 is approximately 0.50196. This is the closest you get to 0.5 with 8 integer bits per channel. So it appears like somewhere during processing, the value is converted to 8 bit (per channel) integer.
PBuffer vs PBO won't make a difference, but you must make sure that your buffer is in a floating point format. if you use vertex colors as a source, try using a texture coordinate set instead. Texcoord interpolators are generally high precision. The color interpolators OTOH may operate at reduced precision. Fragment programs can MOV a texcoord directly to result.color.

11-19-2004, 09:32 PM
I have not tried your method, but I believe your method will success. You have easily solve my supicious on the strange number of 0.5019.

Thank you very much!