2

So if I'm to draw three-sided pyramid with GL_TRIANGLE_FAN I provide one vertice for center and three for bottom (actually four but you know what I mean, right?!).

I can calculate face normals for all three faces (sides) of pyramid.

Question is how can I assign different normal to the first (center) vertice for every face (side) if I have only one call to draw that vertice ?

Basically I need to assign same face normal to all three vertices that compose triangle and than same thing for next two triangles.

But don't know how to assigne normal for the first (center) vertice three times when I call that vertice draw function only once (is that even possible with GL_TRIANGLE_FAN ?!).

Setting that vertice normal to glNormal3f(0.0f, 0.0f, 1.0f) is no good (though it seems correct) because that way color interpolation between vertices is not correct.

bmargulies
  • 91,317
  • 38
  • 166
  • 290
  • 3
    You can't, you need to use a different vertex. It will have the same position but a different normal. (and probably be a triangle list rather than a fan) – jcoder Oct 26 '12 at 12:03
  • 1
    See [here](http://stackoverflow.com/q/11148567/743214) for the general problem and its solution. – Christian Rau Oct 26 '12 at 14:21

1 Answers1

4

It's a common misconception that a vertex is just the position. A vertex is the whole set of position, normal, texture coordinates, and so on. If you change only one attribute of the vertex vector, you get a very different vertex.

Hence it is not possible to have only one vertex, but several normals. This contradicts the very way a vertex is defined as.

datenwolf
  • 149,702
  • 12
  • 167
  • 273