Multiple shaders single VAO/VBO

What is the best practice when you have mutliple similar objects in a scene and each one requires a seperate shader?
For instance, I can create a seperate VBO for every polygon mesh and also a seperate ArrayObject and then bind that particular ArrayObject and shader for each single mesh to draw a certain object. However, I feel like this is not so optimal.
Or if I created one large vbo for all the polygon meshes is there anyway I could use a different shader for every mesh?
Any suggestions?

well if you sort your objects depending on the shader it uses then there shouldn’t be a problem putting it all in one big VBO/VAO.
Though you should try and create shaders that can be used for as many objects as possible

Please note that you don’t have to switch VAOs each time you switch shaders. If you store multiple meshes in a single VAO+VBO set then issue different Draw* commands to draw the different objects and switch the shader between the Draw* commands.

Though you should try and create shaders that can be used for as many objects as possible

Is it a bad idea (or even possible) to somehow have one more general purpose shader that you can pass a “flag” attribute and it decides which function to perform inside the shader?

Please note that you don’t have to switch VAOs each time you switch shaders. If you store multiple meshes in a single VAO+VBO set then issue different Draw* commands to draw the different objects and switch the shader between the Draw* commands.

Are you referring to issuing a draw command like DrawRange* and keeping track of the count as zeoverlord suggested the ordering of VBO contents?

Is it better to just change the default VAO attributes upon drawing each VBO? Or is there any other most used practices addressing this issue?

Well it depends on the shaders themselves, if they are really similar then yes its better to condense it into one, like if the only difference is that they have a different amount of specular power it is definitely better to make that modifiable trough a uniform variable or a texture map.
But just have a super shader that sort of switches between a bunch of shaders might not be that optimal.

yes

Thanks for your helps guys!