View Full Version : VBOs and Materials
04-10-2008, 10:41 AM
Is is possible to specify several materials for a single VBO? If so, how?
04-10-2008, 10:47 AM
A VBO is simply a storage for vertex data (position, normals etc). You can use one VBO for several different draw calls, in various ways.
I guess what you mean is if you can specify several materials for a single draw call. Afaik that is not possible.
You could however use a common shader which would mix or switch between textures and/or lighting models based on a vertex attribute. If it pays off is another question though :)
04-10-2008, 11:06 AM
It's like this: I'm loading a mesh specified by an OBJ and MTL file and I want the vertex data to be stored as a VBO. The problem is that thosse vertices represent several faces which, in turn, can have different materials.
It seems it can't be done, so I'll have to use display lists, right? Or even vertex arrays?
I don't know anything about shaders, but I'll be learning soon, though.
04-10-2008, 12:13 PM
Vertex arrays are is the same as using VBOs just that VBOs are supposed to be more efficient since you don't always have to retransmit the vertex data to the card. To render to your model you do not need display lists at all. You can do everything without them.
You simply store all the vertex data in a VBO and then you need to set the appropriate material parameters and make the draw call for rendering all the faces with this material. Then you move an to the next material and do the same.
[ www.trenki.net (http://www.trenki.net) | vector_math (3d math library) (http://www.trenki.net/content/view/16/36/) | software renderer (http://www.trenki.net/content/view/18/38/) ]
04-11-2008, 09:54 PM
.. So you could make & use several index arrays (with GL_ELEMENT_ARRAY_BUFFER) for the vbo of your object, one array for each material.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.