Opengl/GLSL Using SSBO in an array -
i got errro when using ssbo in array.
this source code in vertex shader:
#version 430 compatibility in int aid; in int bid; out vec4 vcolor; struct vertex{ vec4 position; vec4 color; }; layout(std430) buffer shader_data{ vertex vertex[]; }mybuffers[4]; // using fixed size void main() { vcolor = mybuffers[bid].vertex[aid].color; // using bid locate ssbo. error here vec4 worldpos = mybuffers[0].vertex[aid].position; gl_position = gl_modelviewprojectionmatrix * worldpos; } and got error when link glsl program object.
the error is:
link error
0(17) : error c1306: cannot determine type of interface variable. need inline function
i don't understand meaning, need inline function
glsl saying must resolve @ link time buffer you're using. if substitute mybuffers[bid] mybuffers[0] (for example) link cleanly.
a solution problem using explicit if (since universe of buffers small - 4 only):
void main() { // explicitly index buffer glsl can see @ link time: if(bid == 0) vcolor = mybuffers[0].vertex[aid].color; else if(bid == 1) vcolor = mybuffers[1].vertex[aid].color; else if(bid == 2) vcolor = mybuffers[2].vertex[aid].color; else if(bid == 3) vcolor = mybuffers[3].vertex[aid].color; vec4 worldpos = mybuffers[0].vertex[aid].position; gl_position = gl_modelviewprojectionmatrix * worldpos; }
Comments
Post a Comment