PDA

View Full Version : Normals



Lindley
06-10-2010, 11:01 AM
Let's say I've got a retangular prism and I'd like to generate uniform normals for each face, straight outward.

If I didn't care about normals, then I could use glDrawElements() to render it, using a vertex array of length 8 and an index array of length 24----it's easy to re-use vertices here.

The question is, can I still re-use vertices if I want to define face normals? Since I only know how to define vertex normals, I'd think I would need to specify 3 different copies of the vertex, each with a different normal. But this seems silly; there has to be a better way to handle this (fairly common) situation. It would make no sense to totally negate the benefits of indexed vertices as soon as normals come into play.

Any ideas?

Alfonse Reinheart
06-10-2010, 11:26 AM
But this seems silly; there has to be a better way to handle this (fairly common) situation.

It's not a "fairly common" situation at all. Think of most games you've played. What takes up most of the polygon count?

Things that have smooth normals, not faceted objects. In short, objects that, more often than not, have a single normal for each position.

Faceted objects are rare, usually simple, and don't make up the lion's share of the vertex data. So optimizing for them doesn't make sense.

overlay
06-10-2010, 03:17 PM
It is fairly common in a modelling tool, to be able to give different color for each polygon when editing. It is also fairly common for scientific visualization software to map data attached to a face into a visual cue.