handmade.network » Forums » Single Vertex Multiple Normals
Chen96
Chen
18 posts
#11496 Single Vertex Multiple Normals
1 month, 4 weeks ago

Hi Guys! I encountered some problem when trying to render a model in OpenGL. I know that in order to render a mesh, for each of its vertices, a vertex attribute is specified, containing information such as its position, color, etc. I store the indices to traverse vertices to avoid duplicate vertex problem. However, the same vertex can be traversed while rendering different faces, therefore needing a different normal. In hindsight, it doesn't look like I can store the normals in vertex attributes anymore, but I don't want to average the normals since I want it to have a sharp-edge effect. I searched on the web and the only answer I can find is "don't use indices". I was wondering if any of you handmade folks know the answer to this. Thanks a bunch!

Alex
mmozeiko
Mārtiņš Možeiko
1315 posts
1 project
#11497 Single Vertex Multiple Normals
1 month, 4 weeks ago Edited by Mārtiņš Možeiko on March 28, 2017, 12:17 a.m.

You need to understand that "vertex" is not just "position".
Vertex is position, plus texcoord, plus normal, plus whatever else attributes you need.
Some vertices will have same positions, that's ok. And some will have same texcoord, that's also OK. So just duplicate position attribute for vertices that differ in other attributes (normal/texcoord/etc).
Chen96
Chen
18 posts
#11498 Single Vertex Multiple Normals
1 month, 4 weeks ago Edited by Chen on March 28, 2017, 12:31 a.m.

Oh you are right! Thanks a bunch! Now I think the question I asked is pretty dumb :(

Alex