PDA

View Full Version : culling



grimoire
06-26-2004, 03:53 PM
If I cull a polygon say
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);Will it speed antying up?

brucemangy
06-26-2004, 04:15 PM
I believe that your vertex will be transformed anyway and will be treated until it is rejected by the frontface culling.
you can avoid this by pre-calculating the normal of the face (cross product) and do a simple dot product.
(3 multiplications n2 additions + determination of the normalized vector going from the triangle to the eye are simpler than multiplication of matrices).
You can do that if your draw simple primitive like gl_triangles. But it is not interesting for strips or fan cause you will have to break them.

If you are not, consider using Vertex Array, compiled Vertex Array or Vertex Buffer Object.
(I didn't try VBO before understanding Vertex array and i suggest you to do the same).
Culling is still interesting to avoid Overdraw if you don't render your primitives from Front to Back. (fragments are rejected by Depth Test if they are occluded)

I may be wrong but it make sense to me ^^.

Do not hesitate if you have any other question.

--
brucemangy

grimoire
06-26-2004, 05:30 PM
how do you do a compiled vertex array? a regular one is like this right??
static GLint verticies[]={1.0,1.0,1.0};
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GLint,0,verticies);
glBegin(GL_POINTS);
glArrayElement(0);
glEnd();I have never heard of a precompiled one. Also I know this is off subject, but which function is faster glFrustum or gluPerspective??

plasmonster
06-27-2004, 02:51 AM
Will it speed antying up?Yes, you could see huge gains. I just wanted to drive this point home. As Bruce pointed out, the vertex will be transformed before culling takes place, and that's where some clever culling can help. GL's culling, on the other hand, helps to avoid unecessary fragment processing, which could be considerable, especially if you have complex combiners and fragment programs. And the GL can cull polygons very quickly, so I wouldn't hesitate to use it everywhere it makes sense :-).