Triangle fans and normals
I''ve been using triangle fans to draw a 3d box on the screen using OpenGL. The box is comprised of the triangle fans with each 6 triangles.
However when I add lighting to the application I get strange results with the triangle fans. If I use triangles to draw the box, lighting works correctly, so my normals are correctly calculated.
When I use triangle fans I supply the normal for every vertex. I believe my problem is that the triangles share points, but not normals for these points, eg. a corner vertex of my box is used to generate four side faces and two top (or bottom) faces, obviously that single vertex will not have the same normal for every face generated. Can anyone confirm this problem? It effectively renders triangle fans useless for objects that aren''t "flat"...
yep, that''s the problem. If you really want to use tri fans you could make the "tip" of the fan the center of each side. For the cube you need to have 3 normals per corner vertex, so it doesn''t really make sense to reuse the points.
lonesock
Piranha are people too.
lonesock
Piranha are people too.
lonesockPiranha are people too.www.lonesock.netSOIL: Simple OpenGL Image LibraryMovies I've mocked: "The Core", "The Mummy", "Tale of Despereaux"
Thanks for your reply, it''s nice to have it confirmed.
This literaly means that complex objects will have to be drawn using GL_TRIANGLES... Do you know anything about the slowdown of using that, instead of TRIANGLE_FAN?
This literaly means that complex objects will have to be drawn using GL_TRIANGLES... Do you know anything about the slowdown of using that, instead of TRIANGLE_FAN?
in my experience, slowest to fastest was actually:
tri-fans, tris, tri-strips
but that was a long time ago, and it probably just meant that the driver was not optimized at all for fans (this was back in the TNT2 days).
Tri strips are pretty cool, and there are utilities that will stripify a model for you (I think there is one from nVidia, and another called stripe?) Maybe look into those.
lonesock
Piranha are people too.
tri-fans, tris, tri-strips
but that was a long time ago, and it probably just meant that the driver was not optimized at all for fans (this was back in the TNT2 days).
Tri strips are pretty cool, and there are utilities that will stripify a model for you (I think there is one from nVidia, and another called stripe?) Maybe look into those.
lonesock
Piranha are people too.
lonesockPiranha are people too.www.lonesock.netSOIL: Simple OpenGL Image LibraryMovies I've mocked: "The Core", "The Mummy", "Tale of Despereaux"
Actually triangle strips are as fast as traisngle fans. They both benefit the vertex caching capabilities of todays'' graphics cards.
As for vertex sharing, well, it just depends on what your model is meant to represent.
You can share your vertices for your cube if you want to make a roundish look. And you can dissociate vertices over a sphere if you want to make a metalish look.
As for vertex sharing, well, it just depends on what your model is meant to represent.
You can share your vertices for your cube if you want to make a roundish look. And you can dissociate vertices over a sphere if you want to make a metalish look.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement