11
\$\begingroup\$

glVertexAttribPointer(index, size, type, normalized, stride, pointer);

If I use type=GL_UNSIGNED_BYTE and normalized=GL_TRUE

how is it normalized? would the data be divided by 256 for normalization? or? This would mean there is no way to have a normalized value of '1.0f'..

\$\endgroup\$
14
\$\begingroup\$

From the manual,

If set to GL_TRUE, normalized indicates that values stored in an integer format are to be mapped to the range [-1,1] (for signed values) or [0,1] (for unsigned values) when they are accessed and converted to floating point.

I take that to mean that, with an unsigned 8 bit type, 0 would map to 0.0f and 255 would map to 1.0f.

\$\endgroup\$
5
  • \$\begingroup\$ So that means it is divided by 255? \$\endgroup\$
    – Jonathan
    Apr 8 '11 at 21:58
  • \$\begingroup\$ Right, unsigned byte has range of 0 - 255. So if you passed 0xFF (which is equal to 255), you'd get 1.0f. \$\endgroup\$
    – notlesh
    Apr 8 '11 at 22:09
  • 8
    \$\begingroup\$ ... Did you ever play the original Zelda? The maximum amount of rubies you could hold was 255, not 256 ;) \$\endgroup\$
    – notlesh
    Apr 8 '11 at 22:12
  • \$\begingroup\$ I know that unsigned bytes only go to 255.. I was just wondering because it seemed logic for the GPU to divide by a power-of-two \$\endgroup\$
    – Jonathan
    Apr 8 '11 at 23:23
  • \$\begingroup\$ I was wondering something similar. There may be an efficient conversion from uint_8 to float that doesn't do much more than shifting bits around, but I'm not the one to ask... Someone who knows more about FPU's might chime in? \$\endgroup\$
    – notlesh
    Apr 9 '11 at 0:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .