Hi,
Jean-Sébastien Guay wrote:
Hi Christian,
my geometry has 9 vertices - i thought if i use a drawElement index
with index swaps to revist a vertex, this would give me the
opportunity to use more than one normal per vertex (there are reasons
why i need this ;-). i now think the truth is, only real vertices in
the vertexlist let me allow to do this.
Yes, if you need hard edges, then you need different normals for the
same vertex when it's part of a different face. But the way to express
that with vertex arrays is to duplicate the vertex in the array and use
a different normal.
Your analysis seems correct. From what you say above, what you actually
did was have a larger number of normals than vertices, thinking that
then the extra normals would be used when the same vertex was used in a
different primitive set. That doesn't work. When normals are used in
BIND_PER_VERTEX mode, it's assumed that you have the same number of
vertices as normals, and so the result was just that the extra normals
were never used. (same with colors in the color array BTW)
So to recap, if normals are used in BIND_PER_VERTEX mode, then vertex i
is used with normal i. But vertex i and vertex j can be equal, with a
different normal j. And then vertex i and vertex j can be part of
different triangles (well, should, otherwise you have a degenerate
triangle).
At first this seems like a waste of memory, but the hardware is really
optimized to work this way.
Hope this helps,
J-S
What J-S says is right and would work fine if you want a single
primitive. You can however avoid duplicating vertices if you are willing
to make more primitives.
Simple contrived example: say you want to draw a triangle and specify
normals for both sides manually. (GL_TRIANGLES)
Now you can make a single vertex array, normal array and drawelements
va = [v1, v2, v3, v3, v2, v1]
na = [n1, n1, n1, n2, n2, n2]
de = [0, 1, 2, 3, 4, 5]
and make a primitive out of this.
Or, you can make a single vertex array, 2 normal arrays and 2 drawelements
va = [v1, v2, v3]
na1 = [n1, n1, n1]
na2 = [n2, n2, n2]
de1 = [0, 1, 2]
de2 = [2, 1, 0]
and make two primitives.
In this way you can sometimes save some memory by having less vertices
loaded up.
jp
--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean. MailScanner thanks Transtec Computers for their support.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org