View Full Version : Shader Calculation

04-04-2017, 11:57 AM
I'd like the vertex shader to calculate something for me. The number of output vertices is the same as the number of input vertices, but the number of input vertices can vary, is not constant. I'd need a variable array in the shader, but there is none. Nevertheless, maybe there is some tweak?

04-04-2017, 01:16 PM
The vertex shader runs once and once only per vertex, and does not have access to any vertex other than the one it is currently running on.

Can you clarify that the latter is your requirement before I comment further, please?

04-04-2017, 04:12 PM
take a look at shader storage buffer (https://www.khronos.org/opengl/wiki/Shader_Storage_Buffer_Object)
generate a buffer object, allocate some space for it, fill it with some data, bind it to a "shader storage block", then you can access an "unsized array", the size depends on the buffer objects size. read also about the memory layout "std430" (https://www.khronos.org/opengl/wiki/Interface_Block_(GLSL)#Memory_layout)