I am doing some work with shaders where I use an array of ints as a lookup index. At present, I do this using:
buffer_SegWeb.allocate(); buffer_SegWeb.bind(GL_TEXTURE_BUFFER); buffer_SegWeb.setData(data_SegWeb,GL_DYNAMIC_DRAW); tex_SegWeb.allocateAsBufferTexture(buffer_SegWeb,GL_R32F);
Where data_SegWeb is just a vector of ints, assigned at the start…
Then sending to the shader, once at the start:
shaderMeasures.updateShader.begin(); shaderMeasures.updateShader.setUniformTexture("tex_SegWeb",tex_SegWeb,i); shaderMeasures.updateShader.end();
And then in the shader, to read an item from the vector:
int segX = int(texelFetch(tex_SegWeb, i).x);
Is there any way to optimise or improve on this? i.e. I am only sending ints, whereas this reads floats, which then need to be turned back into ints - can I just send ints? And, are there any other improvements I could do, that would help with speed?