I'm not sure how to present this in a shader.
This is because this information does not live in the shader.
All values ββprovided by glVertexAttribPointer
will be converted to floating-point GLSL values ββ(if they are no longer a float). This conversion is essentially free. Therefore, you can use any of these glVertexAttribPointer
definitions with the vec4
attribute vec4
:
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, ...); glVertexAttribPointer(0, 4, GL_UNSIGNED_SHORT, GL_TRUE, ...); glVertexAttribPointer(0, 4, GL_SHORT, GL_TRUE, ...); glVertexAttribPointer(0, 4, GL_SHORT, GL_FALSE, ...);
All of them will be automatically converted to vec4
. Your shader should not know or care about being fed shorts, bytes, integers, floats, etc.
The first will be used as is. The second converts the unsigned short range [0, 65535] to the range [0.0, 1.0] with a floating point. The third converts the signed short range [-32768, 32767] to the range [-1.0, 1.0] ( although the conversion is a bit odd and differs for some versions of OpenGL to allow integer 0 to match floating point 0.0 ). The fourth converts [-32768, 32767] to [-32768.0, 32767.0] as a floating point range.
The GLSL type you use for attributes only changes if you use glVertexAttribIPointer
or glVertexAttribLPointer
, none of which are available in OpenGL ES 2.0.
In short: you should always use GLSL floating point types for attributes. OpenGL will do the conversion for you.