Passing custom vertex attributes to vertex shader?

I want to use a set of related but different shaders for a project. I realise one way is to just do multiple passes, and that would be fine but probably inefficient.

So I would prefer to render in one pass, with the shader treating each category of vertex differently based on a categorisation variable passed to it. E.g. an int indicating “render as dotted line” How can I pass custom attributes on a per-vertex basis, to allow this?

Or is there a better way of handling the same problem?

One quick and dirty way to solve this, would be to hijack some other value like the UV coordinate or the color, if you are not already using all of them.

Otherwise it is possible to send additional data per vertex to your shaders. This is not as straight forward a process as one would hope for. The search terms there are Vertex Buffer Objects ( http://openframeworks.cc/documentation/gl/ofVbo/ ) and Vertex Buffers (ofBufferObjects) The basic idea is that you can upload your own data more or less the same way as you set vertex, color, etc data. I think this requires you to use the programmable renderer though.

Thanks very much - I’d literally just found the VBO stuff and was wondering if that was the right path.
I’m tempted to try your first suggestion though. This is a fairly simple set of 2d lines and moving to VBOs is going to complicate the code massively.

Then go for the first one. You can always add the more complicated stuff later on if it isn’t flexible enough…

that’s what I’m thinking - cheers for your help here. Much appreciated.