Packing Values
Ok, each of the four values that I have are actually color values. The colors have been split (8 bits per color, RGBA). So my precision is x/255. My dilema lies in keeping precision, or at the least, creating a unique representation in the range of [0..1).
Quote:Original post by Daishi
Ok, each of the four values that I have are actually color values. The colors have been split (8 bits per color, RGBA). So my precision is x/255. My dilema lies in keeping precision, or at the least, creating a unique representation in the range of [0..1).
1) Your range is [0,1], not [0,1) - or don't you have pure red, blue, green or white [smile]
2) You will loose precision, no matter what since IEEE floats are not evenly distributed and therefore not all numbers can be represented.
Why do you want to map the four values into a single float? Anyway, if you don't plan on remapping the float back to RGBA, you can use a simple conversion to a gray value. Otherwise r/255^1 + g/255^2 + b/255^3 + a/255^4 would be the most simple soution even though you would lose much precision on the way...
Good luck,
Pat
Quote:Original post by darookieQuote:Original post by Daishi
Ok, each of the four values that I have are actually color values. The colors have been split (8 bits per color, RGBA). So my precision is x/255. My dilema lies in keeping precision, or at the least, creating a unique representation in the range of [0..1).
1) Your range is [0,1], not [0,1) - or don't you have pure red, blue, green or white [smile]
2) You will loose precision, no matter what since IEEE floats are not evenly distributed and therefore not all numbers can be represented.
Why do you want to map the four values into a single float? Anyway, if you don't plan on remapping the float back to RGBA, you can use a simple conversion to a gray value. Otherwise r/255^1 + g/255^2 + b/255^3 + a/255^4 would be the most simple soution even though you would lose much precision on the way...
Good luck,
Pat
You're right, my range of my four values is actually [0..1], I wasn't paying close enough attention.
I don't need to convert back at all. It's a one way process. I am storing values into a texture and then trying to store the pixel data as a depth value, and then rendering a quad into the depth buffer with GL_EQUAL to detect collisions/matches. Not exactly the intention of a graphics processor. So as long as I can get a unique value, precision won't really matter anymore.
[Edited by - Daishi on December 1, 2005 11:10:21 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement