# In the rendering pipeline, in what coordinate space are vertices when they arrive at the primitive assembly stage?

Full disclaimer, this was a test question, but I couldn't find any information online.

In my opinion, this depends on if the primitive assembly stage happens before or after perspective division. If before, then it must be in homogeneous clip space. If after, NDC space.

Which of the two is it? Or am I completely wrong and its neither?

• You have to perform clipping on triangles (i.e. assembled primitives) which therefore has to be done before the perspective divide. Oct 4, 2019 at 10:09
• Why can’t perspective divide happen before clipping? Isn’t clipping much easier in NDC space? Oct 4, 2019 at 10:18
• Because once you divide through by Z, data can be destroyed. EG if Z = 0, the resulting X'=X/Z and Y'=Y/Z are undefined. Similarly Z<0 will produce incorrect X' & Y' Vals (in the sense that you can't just interpolate from one vertex to another). You must clip in, say, homogeneous space, i.e JUST prior to the division. Oct 4, 2019 at 14:02

As pointed out by Simon F, the clipping stage needs to clip against edges (and thus triangles/primitives). Thus the primitive assembly stage cannot happen after clipping, even though the Pipeline is described such that primitive assembly happens after clipping.

Slide 16 of Ohio university's Han-Wei Shen's 2010 course The OpenGL Rendering Pipeline suggests that vertices are transformed to Clip Space, then the primitive assembly happens and only afterwards is clipping actually done.

According to Khronos' wiki the primitive assembly happens after clipping, which includes the following:

The vertex positions are transformed from clip-space to window space via the Perspective Divide and the Viewport Transform.

Window Space is described as the space after the viewport transform and that means after NDC space:

The viewport transform defines the transformation of vertex positions from NDC space to window space. These are the coordinates that are rasterized to the output image.

Since the viewport transform includes a scaling for the width and height of the viewport, as well as a translation with the viewports position on screen, you should end up with pixel coordiantes of your screen.

• " primitive assembly happens after clipping,.....The vertex positions are transformed from clip-space to window space via the Perspective Divide and the Viewport Transform." Surely that can only work IF the triangle did not need to be clipped. The dot products VS clip plane calculations (needed as a prerequisite to actual clipping) can be done on individual vertices, but you need actual edges (i.e. pairs of vertices and hence the triangle) to do clipping. Oct 4, 2019 at 10:15
• How could it be that primitive assembly happens after clipping? Surely clipping cannot be performed on vertices without first knowing their primitives? Oct 4, 2019 at 10:17
• I see your (or rather my) problem. This is how the pipeline is ordered, which is why I first assumed as suggested in my answer. Right now I cannot find one instance where it says the primitive assembly happens before clipping (even if the pipeline lists primitive assembly after clipping), but as you are correct with your comment, I will adjust my answer accordingly.
– Tare
Oct 4, 2019 at 10:48