Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm having trouble finding conclusive information on this, but it seems like I can't pass integer attributes to GLSL for OpenGL ES or that if I do they'll be converted to float. I need a value between the range [0-65535] for each vertex. If I pass it as a float and then convert it back, I'm concerned that the value will have changed (if the precision is low enough and can't suitably represent values at the higher magnitudes).

Its also confusing trying to figure out what precision for floats the OpenGL ES 2 standard requires. It seems like the minimum requirement is 16-bit (ie some implementations will use 16-bit floats for highp variables). In this case, it would seem like the floating point number wouldn't be able to store enough information for 0-65535 since that's what a 16-bit unsigned int holds.

So, formally, how can I specify a vertex attribute that will let me precisely represent the values 0-65535 in OpenGL ES 2.

share|improve this question
What is the purpose of that integer? You could always send it as two 8-bit integers and combine them later if necessary. –  Sam Hocevar Jan 12 '13 at 18:09
I batch geometry and use the integer to identify geometry as belonging to separate entities. With regards to sending it as two 8-bit integers... I think you can only use float attributes in your shaders. I don't know how I'd combine two ints [represented as floats] into one int, or even if thats necessary. –  Pris Jan 12 '13 at 20:01
Yes, integers passed as attributes are converted to floats, but 0 - 255 can be exactly represented by a shader variable. –  Sam Hocevar Jan 13 '13 at 0:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.