Vertex Shader with arrays

Hello,
I’m trying to implement a similar usage of vertex shaders as in this Touch Designer tutorial link but with openframeworks.

Essentially I’d like to generate an array of OBJs of the same file, say a sphere, but have a single vertex shader effect each instance slightly differently.

Is this possible? Or should I just creat a new class of objects containing a load OBJ and load vertex shader with assignable uniforms? Trying to keep performance in mind and best practices.

Thanks in advance.

Hi Michael,

Sure, you can just use the gl_InstanceID builtin variable in your vertex shader (that can be used to indexed a buffer storage if needed be).

1 Like

To add a bit to DarkSalmon’s post, maybe look at the vboMeshDrawInstancedExample. It uses a shader with ofVbo::drawInstanced() and the gl_InstanceID in the vertex shader. I’ve used this approach before and its fantastic!

2 Likes