I have packed several values needed for shading a particular vertex into a single 32-bit uint. In the shader, it is unpacked like this:
vec3 color;
uint vertexData = data;
float sunlight, artificialLight;
bool occlusion;
artificialLight = float(vertexData & 31u);
vertexData = vertexData >> 5;
sunlight = float(vertexData & 31u);
vertexData = vertexData >> 5;
occlusion = bool(vertexData & 1u);
vertexData = vertexData >> 1;
color.b = float(vertexData & 127u);
vertexData = vertexData >> 7;
color.g = float(vertexData & 127u);
vertexData = vertexData >> 7;
color.r = float(vertexData & 127u);
The color produced by this extraction is much different from the originally intended color. For example:
130, 245, 90 --> 78, 125, 249 (These values are not exact)
I took the code and put it into my main c++ program and ran it with a debugger. It showed the right values.
130, 245, 90 --> 130, 245, 90
EDIT
I have taken a uint produced by my compressor and directly inputted it into my shader like this
vertexData = 2179293184;
Every vertex is shaded with the color of green this value corresponds to. So apparently, there is something going wrong with the transmission of the values. What might be causing this?
glVertexAttribIPointer
to when setting up this vertex attribute (notglVertexAttribPointer
)? \$\endgroup\$