Jump to content
  • Advertisement
Sign in to follow this  
Guy Meh

OpenGL Flat shading and vertex arrays

This topic is 3533 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want a flat shading effect in my game, where colours are assigned to each polygon instead of each vertex (I don't want any vertex colour blending). I know that flat shading is available, but the polygon colours can only be controlled by setting the colour for the right vertex in a polygon (either the first or last one; I don't remember). Since I'm loading/converting my models from files like OBJ, I'm not sure how much control over the final ordering of the vertices in each polygon I have. Also, I intend to use vertex arrays (probably switch to vertex buffer objects later) and as far as I can tell the colour arrays specify the colours for each vertex only. I'm also planning on using some basic shaders instead of OpenGL's built-in lighting and colouring model. Would this effect anything?

Share this post


Link to post
Share on other sites
Advertisement
unless u use immediate mode
u will need to duplicate the vertices, ie have multiple vertex positions in the same place but each having a different normal

Share this post


Link to post
Share on other sites
Well, in that case I guess I'll have duplicate vertices; each triangle has their own vertices, and each vertex of a triangle has the same normal.

The thing is that I'm going for a retro look, sort of like Darwinia, which is why I'm trying so hard to get the flat shading "right."

Though I guess I'll ask: say my models have 50 to 200 triangles. With the vertex duplication thing, I'll have to store 150 to 600 vertices. Would vertex arrays/VBOs still be faster than immediate mode (which wouldn't have duplicate vertices, and would let me keep a normal for each triangle instead of each vertex)?

Share this post


Link to post
Share on other sites
yes most likely faster.

dont be afraid of duplicating vertices, most games even back in the quake2 days do it.
eg a quake2 model might have actual 300vertices but have 800 unique ones in the file,
its not just cause of normals but any data eg texture coordinates

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!