Per face colouring

Started by Graeme, November 08, 2007, 05:12:06

Previous topic - Next topic

Graeme

Hi everyone, I have been searching and searching but I can't seem to find out whether this is possible.  I want my vertex buffer object to have a flat colour for each triangular face.  I know I can just turn on flat shading, but that gives a flat colour for each vertex rather than each face.

The obvious way to do this is to not share vertices between adjacent triangles, but that would make my frame rate take a hit.

I'm sure I could figure out a way to do it with a glsl shader, but wouldn't that require a pixel shader since two faces that share a vertex can have a completely different colour?  That solution seems like overkill for something as simple as this.

Any ideas?  I'm hoping it's something extremely simple (but not obvious, that would make me look dumb)  ;D

elias4444

Let me start out by saying, I don't know for sure. BUT, I was looking into this not too long ago myself. VBOs really just are what they are, a buffered array of vertices with corresponding colors, tex coords, etc.. If you want a per-face color, I'm pretty sure you can't share vertices and will need to duplicate them (someone please contradict me if I'm wrong... I'd love to be wrong). If it's any consolation though, I didn't notice much of a hit when I duplicated all of the vertices.

Another option would be to use display lists, so long as all the information is static.

=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Graeme

Dang, I knew that was going to be the answer.  :(

Oh well, I'm using it for a very low detail terrain, and since I don't have many vertices, I don't lose much fps by repeating vertices.

If anyone else has a suggestion though, I'd be glad to hear it.

Thanks elias