PDA

View Full Version : Creating a sphere by hand



Exoide
03-03-2010, 11:01 AM
Hi there,

I wanna create a sphere by hand in an optimal way so I decided to use VBO and IBO.

I've created the VBO for the vertices of the sphere and I rendered as GL_POINTS and they're in their right positions.

The question is about the IBO. I was trying to create it in such a way to get advantage of the GL_TRIANGLE_STRIP, but now I'm reading an old post http://www.opengl.org/discussion_boards/...true#Post272666 (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=272666&Searchpa ge=1&Main=52645&Words=sphere+algorithm&Search=true #Post272666)

where Dark Photon said this


Second, using carefully ordered triangles is much more important than using the TRIANGLE_STRIP primitive. Strips are old school and basically dead except for trivial things such regular grids. You'll get the same performance from indexed TRIANGLEs where the triangle order is the same.

What he means with "You'll get the same performance from indexed TRIANGLEs where the triangle order is the same."?

I was trying to create the index to render only triangles using GL_TRIANGLE_STRIP but it seems to be complex to order the vertices. If drawing separated triangles has no penalty in performance I think it's the easiest way. But I repeat I'm looking for high performance.

Can someone help me with this?

Thank you.

PD: I'm looking for the fastest possible way to render the sphere.

Ido_Ilan
03-03-2010, 12:51 PM
Hi,

Today GPUs are complex machine with both large and efficient pre and post transformation caches, using index arrays with optimized array indexing and positioning could lead to very high vertex throughput.
Look at both NVidia and ATI(AMD) site for cache optimizing libraries. I've used tootle form ATI that gave very favorable performance compared to many others I've tested.


Ido

pjcozzi
03-03-2010, 06:10 PM
Create triangles for the sphere in the most convenient order for you, then in a separate step, optimize them for the pre and post vertex caches on the GPU, as Ido said. This is separate from the sphere triangulation, so it can be used for any triangle mesh. Take a look at these two algorithms:

Linear-Speed Vertex Cache Optimisation (http://home.comcast.net/~tom_forsyth/papers/fast_vert_cache_opt.html)
Fast Triangle Reordering for Vertex Locality and Reduced Overdraw (http://www.cs.princeton.edu/gfx/pubs/Sander_2007_%3ETR/)

We have implemented the later with much success. If you are concerned about performance, consider level of detail in addition to raw triangle throughput. Also, if the sphere is opaque, make sure to enable back face culling (unless the viewer is inside of it).

Regards,
Patrick