silly question - 0.5 as a byte? 127 or 128?

Started by
3 comments, last by Dave Hunt 17 years, 1 month ago
Sorry for this dumb question but... I want to load a (floating point) texture with 0.5 quickly so I load it using bytes to cut down on my memory bandwidth usage. As far as OpenGl and GLSL are concerned what is 0.5 as a byte? 127 or 128?
Advertisement
0.5 is 127 in case you count byte as 0-255, and 128 in case byte is 1-256. Gl uses first scheme, but you need to take into account buffer depth, in 16 bit mode you get only 5 bits per pixel, so both values will be rounded roughly to 0.5, and why don't use floating color values instead of bytes ? As far as i know they faster, and easier to understand
Asuming you load a single channel texture which represents each pixel with one byte, it shouldn't matter whether you use 127 or 128 since: 0(byte) = 0.0f(float), 255(byte) = 1.0f (float) -> 127 = 0.498, 128 = 0.501.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
Further thinking about this has made me realize it was a really stupid question..... 0.5 lies exactly at 127.5 so either 127 or 128 are equally good.

Thanks for humouring me :-D
Quote:Original post by coordz
Further thinking about this has made me realize it was a really stupid question..... 0.5 lies exactly at 127.5 so either 127 or 128 are equally good.

Thanks for humouring me :-D


It depends on whether you follow the Path of Light, or the Path of Darkness. ;)

This topic is closed to new replies.

Advertisement