I have a working code where I am reading vec4 values in the shader from a texture buffer.
On the client side, I create a buffer of displacement vectors:
vec4 vector1 : vec4(x1, y1, z1, w1);
vec4 vector2 : vec4(x2, y2, z2, w2);
vec4 vector3 : vec4(x3, y3, z3, w3);
..
then I create a vertex buffer that contains vector1, vector2, vector3....
next, I create a texture and bind the above buffer to it using:
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, bufferID);
I chose GL_RGBA32F because each of x1, y1, z1, w1, etc are float.
in the shader I can fetch the individual vectors using:
vec4 vector1 = texelFetch(samplerObj, 0);
vec4 vector2 = texelFetch(samplerObj, 1);
.
.
But, now suppose my displacement vector is not a vec4, but a single integer. i.e
int vector1 = x1; //(int is 32 bit unsigned)
int vector2 = x2; //(int is 32 bit unsigned)
can somebody please tell what will be the corresponding internalFormat be? is it
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32UI, bufferID);
also how will I fetch the value using texelFetch in shader? is it
int vector1 = texelFetch(samplerObj, 0);
or
int vector1 = texelFetch(samplerObj, 0).r ?
I am confused because texelFetch should return a texel that has 4 components, so must I use the red component of the result?