VBOs and material properties

Hi

Can material properties [ambient properties, etc] be used in conjunction with VBOs? And if so, what is the best approach and does anyone know of some good tutorials?

I’ve checked the red-book but couldn’t find anything about mixing VBOs and material properties.

Thanks.

Graham

I’ve checked the red-book but couldn’t find anything about mixing VBOs and material properties.

And why would you? What do buffer objects have to do with fixed-function material properties? The two concepts have nothing to do with one another.

It’s like asking if you can use textures with buffer objects. Only it makes less sense, because at least there, fixed-function texturing usually relies on texture coordinates taken from vertex attributes.

In short, there is no interaction between fixed-function lighting and using buffer objects.

gmseed, the equivalent of material properties in a modern opengl approach (i.e. one where you do everything via VBOs), is to write your own vertex and fragment shaders.

VBOs can contain any kind of data, so you can put “material properties” in them, but since you are using your own lighting algorithm, they are not the material properties defined by opengl. From the API point of view, they are just data, it’s your code that will decide that such VBO (or part of it) represent ambient/diffuse/specular/… components. Depending on the lighting algorithm used, you will need different data.

Unfortunately, last time I checked there was very few tutorials for non-fixed function OpenGL coding. One that seems very good is here:

http://www.arcsynthesis.org/gltut/index.html

There’s a part on lighting.

This thread may be relevant: http://www.opengl.org/discussion_boards/…6059#Post306059

I guess you are asking if you can use glMaterial. Yes you can. BTW, there are many ways to send vertices to the graphics cards and non of them state that you can’t use some particular function.

The best approach? I guess the best approach is to call glMaterial before rendering your geometry.

For VBO specific info,
http://www.opengl.org/wiki/Vertex_Buffer_Object
http://www.opengl.org/wiki/VBO_-_more
http://www.opengl.org/wiki/VBO_-_just_examples

no, you will not find any calls for glMaterial.

With the legacy fixed function pipeline it is possible to control some material properties per vertex from the VBO. Enable GL_COLOR_MATERIAL and use glColorMaterial() to choose which material property to control.

All of that is deprecated of course.

You can also have a per vertex material ambient, emission, diffuse, specular and shininess with shaders, which means you have more control with shaders. With fixed function, you can only control one of the properties per vertex.

@Alfonso states: “there is no interaction between fixed-function lighting and using buffer objects”.

As indicated with other posts, the following works:


            glv.glColorMaterial( GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE ); // call glColorMaterial before enabling GL_COLOR_MATERIAL
            glv.glEnable( GL2.GL_COLOR_MATERIAL );

This allows VBOs [without shaders] to be used and existing material properties used.

This allows VBOs [without shaders] to be used and existing material properties used.

And it would work just as well if you were using client-side vertex arrays instead of buffer objects. My point is that the use of buffer objects to supply vertex arrays (aka: VBO) has nothing to do with how lighting works.