Hello.
At the moment, when I need to process colour attributes, I pass them to the shader as vec4, and for glVertexAttribPointer() I use the GL_FLOAT type. Eg.
C code:
glVertexAttribPointer(index, 4, GL_FLOAT, GL_FALSE, stride, colour_data);
GLSL:
attribute vec4 colour;
…
I’ve read that glVertexAttribPointer() can also accept GL_UNSIGNED_BYTE as attribute type. However, for the life of me, I cannot figure out how to let the GLSL shader know about these attributes, since the language only specifies float, int and bool as supported vector/scalar types. There is no support for GLubyte variables. So how do I specify that the attributes are GLubyte if I wanted to save bandwidth and use 4 bytes for colour instead of 4 floats.
PS. I do know that internally everything gets converted to floats in the shader, I just want to learn how I’m supposed to access non float/int/bool variables (eg. how to access short or bytes, since it is a supported argument for glVertexAttribPointer)
Edit OK, I’ve figured it out. The normalized flag in glVertexAttribPointer() indicates whether to convert bytes/shorts/etc to floats. So the GLSL would access the attribute as a vec4. I’m leaving this post here so that others can also read about the problem/solution. The only question I have is performance - is it really worth while? Only benchmarking can answer that question …