PDA

View Full Version : Clipping before Culling



IG
05-04-2006, 03:16 AM
Hi,
I've posted this on the beginers forum but not sure i've got a clear answer:
Why according to th GL spec and RedBook clipping is done before culling in the graphics pipeline? Can they be overturned? Clipping is expensive and shuold not be done for culled polygons...

Relic
05-04-2006, 05:55 AM
Unless you're intending to develop both yourself, the answer will not change how it's done. ;)
Clipping informations (search for "Cohen-Sutherland") can be gathered per vertex before it's known which primitives are generated.
That happens higher up in the vertex pipeline.
At the time the primitive is assembled from the resulting vertices, the per vertex clip information is used to quickly decide if it's trivially out, in or needs to be clipped. It's just an AND operation.
Since culling in OpenGL is done with the winding informations in screen space primitives need to be clipped (and split into triangles) first and then transformed from clip space to screen space before the culling can actually be applied.

Overmind
05-04-2006, 04:24 PM
Who says clipping is expensive?

Deciding if a polygon is outside of the frustum in clip space is just a few floating point compares, while culling involves at least two multiplications.

Implemented in hardware, you can't generally tell what's faster...

And as I already said on the other forum, the implementations are free to reorder the operations anyway, at least as long as the result stays the same.