Hi all,
I’m wondering if one could include material properties in vertex arrays? I don’t want to preassign colors to vertices but rather have them computed from ligting, material properties, and normal vectors. Is this possible or must I choose textures to render the object?
TIA,
GG
knackered:
By using a “vertex program” you mean write my own “colour” program to extract information from my lighting model, material properties, normal vectors and assign colour to the vertices of my triangle, right? I believe that could easily be done, as described in the Red Book, page 211, 3rd edition. I guess I would compute the colour each time I pass my position in the scene changes.
Thanks,
GG
No, I mean using the NVidia GL_VERTEX_PROGRAM_NV extension.
It enables you to offload all this kind of stuff onto the graphics card.
You could calculate your stuff in software, which is what you seem to be suggesting (BTW, you wouldn’t have to recalculate the colours every time the viewpoint changes, unless you’ve got a significant specular contribution - only when the light or the mesh moves).
But what’s wrong with using GL_COLOR_MATERIAL? It’s a robust and totally generic OpenGL solution.
I’m not sure what’s wrong with GL_COLOR_MATERIAL. It looks like I need a colour array to begin with before I use this property and this is the array I’m trying to computer per vertex. I could be looking at this the wrong way or I don’t quite understand how GL_COLOR_MATRIAL works. In my model I’m given material ambient & diffuse, lighting ambient & diffuse, vertex indices and vertex coordinates.
I’ll think some more about it.
Thanks,
GG
If you’re not given ambient and diffuse properties per vertex, then just use glMaterial to specify materials before rendering your model.