Handmade Network»Forums
Chen
102 posts / 2 projects
Some guy trying to make some video game.
Single Vertex Multiple Normals
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!
Mārtiņš Možeiko
2562 posts / 2 projects
Single Vertex Multiple Normals
Edited by Mārtiņš Možeiko on
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).
Chen
102 posts / 2 projects
Some guy trying to make some video game.
Single Vertex Multiple Normals
Edited by Chen on
Oh you are right! Thanks a bunch! Now I think the question I asked is pretty dumb :(