PDA

View Full Version : culling stage



IG
04-21-2006, 03:10 PM
At what stage of the rendering pipeline culling is done? (before/after matrix transformation?before/after clipping? ...)

songho
04-21-2006, 11:35 PM
IG,
I believe the culling is performed after matrix transform and after clipping.

Please look at OpenGL pipeline diagram in the redbook for more details.

Modelview transform > Projection transform > View Volume clipping > Division by w > Viewport transform > Polygon Culling > Raterization

IG
04-22-2006, 01:33 AM
I can not find the culling stage at this diagram. Can you please direct me to the specific location?
Does it mean that clipping is done for culled polygons??

memfr0b
04-22-2006, 02:16 AM
The OpenGL specification describes culling as the first part of rasterization (Section 3.5.1 "Basic Polygon Rasterization"). This would place culling after the clipping process.

jide
04-22-2006, 04:31 AM
It is done during the fragment operation:

Texturing -> Fog -> Scissor -> Alpha -> Stencil -> Depth -> Color -> Dithering -> Logic and Mask Op => Pixel Buffer

What you mean by culling is I guess the depth test, isn't it ?

ZbuffeR
04-22-2006, 08:02 AM
@jide: no, culling is discarding back-facing triangles, see the ref :
http://www.mevis.de/opengl/glCullFace.html

jide
04-22-2006, 08:46 AM
Oups... as much for me :)

So, this happens during the privitive assembly:

clipping -> perspective division -> viewport (?) -> depth-> culling (HERE !)

So this is the last step of the primitive assembly. Afterward, this is the mode point operation then the fragment operation.

memfr0b
04-22-2006, 08:59 AM
Culling certainly comes before the depth test, as it is a primitive operation, whereas depth test is a fragment operation. If a primitive is culled, no fragments are generated.

jide
04-22-2006, 09:07 AM
What I meant here by depth is the calculation of the z value (of the depth). Sorry for this misunderstanding.

Depth test happens during the fragment operations but for early depth test which happens before (don't really remember)

memfr0b
04-22-2006, 10:26 AM
There are only two "depth tests" that i know about.

The first is the vertex level clipping test against near and far plane. It can modify the primitive's vertices, or drop the entire primitive if all vertices lie outside the same clipping plane. It's not really a "depth test", as it works against all six frustum planes equally.

The second is the fragment level depth test. It tests fragment depth values against depth buffer content, and thus lies behind the rasterizer. It can, however, be applied in various stages of the fragment pipeline. In the FFP or with fragment shaders that do not modify fragment depth, for example, the depth test can be applied early, thus skipping texture lookups/shader runs for discarded fragments. I think this is what "early z-test" refers to.

Culling could theoretically come before or after the clipping test, however the missing perspective division would make the test unnecessarily expensive, i think.

songho
04-22-2006, 11:55 AM
IG,
The diagram which I was talking about is a large foled chart at the back of the red or bluebook.

I think the order of processing was well clarified by valuable members, memfr0b, jide, and ZbuffeR :)

jide
04-22-2006, 12:57 PM
memfrOb, depth is ranged between 0 and 1. This is what I meant. I guess this join your first paragraph (about the frustum planes).