In my program I am doing a single render of one model. I have a generated array of unsigned chars where all bits in each byte can be used. There is an element in the array for each triangle in the model. To get the color for the triangle I use gl_PrimitiveID which gives you the location of the triangle in the buffer being rendered.
My problem is that my GPU is 4.2 meaning I can only use UBOs and not SSBOs. The max array size (byte array) is a little over 16,000 and I need 100,000, The smallest required UBO size is 16KB. Using a standard uniform float[N] has the same limit as the UBO in my case.
I have been looking at this: https://www.opengl.org/registry/specs/NV/shader_buffer_load.txt
But I would like to know if there are other option before I use something so device specific.
My current Frag-Shader if you would like to see:
#version 420 core
out vec3 color;
layout (std140) uniform ColorBlock{
unsigned char colors[16000]; // this need to be 100,000
};
void main(){
float r, g, b;
r = colors[1.0f / gl_PrimitiveID];
g = colors[1.0f / gl_PrimitiveID];
b = colors[1.0f / gl_PrimitiveID];
color = vec3(r, g, b);
}
unsigned char? The smallest data type GLSL supports is 32-bit. If you have an array of bytes like that in C, you're going to have to unpack it in GLSL.