PDA

View Full Version : about normals of vertex



zydgyy
11-22-2011, 03:51 AM
Hi,guys!
If i got a mesh consits of multiple poloygons,some vertices are shared by some poloygons,can i assign the different normals to the same vertex???

tksuoran
11-22-2011, 03:58 AM
Yes, in that case you duplicate the vertex and set desired normal to each copy.

See recent thread http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=306317#Post3063 17 and don't miss the link from remdul pointing to http://www.bytehazard.com/code/vertnorm.html

zydgyy
11-22-2011, 04:39 AM
Can i submit the vertex and normal data array to OPENGL,use fewer data represents vertex,and more data represents normals since a vertex correspond to multiple normals

Lefteris
11-22-2011, 08:40 AM
it all depends on how you would interleave your data in your VBOs and your IBOs I guess.

_arts_
11-22-2011, 09:14 AM
No you can't. You must have for each vertex its normal. This will be the same for texture coordinates, colors and other vertex attributes. And this whether you use indicies or not.

tksuoran
11-24-2011, 03:28 AM
Theoretically, you could achieve a fixed normal:vertex ratio with glVertexAttribDivisor(). You could share each normal to exactly 3 vertices for example. However this fixed ratio is in use for a whole draw call, which makes it difficult to be useful for normal sharing. Also you need to use glVertexAttribPointer() etc., and needs at least OpenGL version 3.3.

Vertex duplication is general and effective solution, just go for it.

If you want, you can add an abstraction layer above OpenGL buffers, where you can set attributes per "point" (same vertex location) and per "corner" (corner of specific polygon). When baking these to OpenGL buffers you can merge corners which are equal (or close enough) to a single vertex. Corners with differing attribute values must have the whole vertex duplicated.

V-man
11-24-2011, 05:30 AM
It is covered in the Wiki
http://www.opengl.org/wiki/FAQ#Multi_indexed_rendering