<p>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.</p>

<p>Slide 16 of Ohio university's Han-Wei Shen's 2010 course <a href="http://web.cse.ohio-state.edu/~shen.94/781/Site/Slides_files/pipeline.pdf" rel="nofollow noreferrer">The OpenGL Rendering Pipeline</a> suggests that vertices are transformed to Clip Space, then the primitive assembly happens and only afterwards is clipping actually done.</p>

<hr>

<p><s>According to <a href="https://www.khronos.org/opengl/wiki/Rendering_Pipeline_Overview" rel="nofollow noreferrer">Khronos' wiki</a> the primitive assembly happens after clipping, which includes the following:</s></p>

<blockquote>
  <p>The vertex positions are transformed from clip-space to window space via the Perspective Divide and the Viewport Transform.</p>
</blockquote>

<p><a href="https://www.khronos.org/opengl/wiki/Vertex_Post-Processing#Viewport_transform" rel="nofollow noreferrer">Window Space</a> is described as the space after the viewport transform and that means after NDC space:</p>

<blockquote>
  <p>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.</p>
</blockquote>

<p>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.</p>

CC BY-SA 4.0
2019-10-04T10:15:56.923Z
*" 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.
Simon F
CC BY-SA 4.0
2019-10-04T10:17:18.823Z
How could it be that primitive assembly happens after clipping? Surely clipping cannot be performed on vertices without first knowing their primitives?
eclmist
CC BY-SA 4.0
2019-10-04T10:48:03.533Z
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
CC BY-SA 4.0
2019-10-04T10:11:15.477Z
2019-10-04T11:05:27.920Z
2019-10-04T11:05:27.920Z
Tare
<p>Full disclaimer, this was a test question, but I couldn't find any information online.</p>

<p>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.</p>

<p>Which of the two is it? Or am I completely wrong and its neither?</p>

CC BY-SA 4.0
2019-10-04T10:09:49.220Z
You have to perform clipping on triangles (i.e.  assembled primitives) which therefore has to be done *before* the perspective divide.
Simon F
CC BY-SA 4.0
2019-10-04T10:18:54.077Z
Why can’t perspective divide happen before clipping? Isn’t clipping much easier in NDC space?
eclmist
CC BY-SA 4.0
2019-10-04T14:02:48.243Z
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.
Simon F
<opengl>
In the rendering pipeline, in what coordinate space are vertices when they arrive at the primitive assembly stage?
eclmist
# In the rendering pipeline, in what coordinate space are vertices when they arrive at the primitive assembly stage?

(Asked by: username_0 on 2019-10-04)

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?

**Tags:** opengl

> **Comments:**
> **username_1**: You have to perform clipping on triangles (i.e.  assembled primitives) which therefore has to be done *before* the perspective divide.  
> **username_0**: Why can’t perspective divide happen before clipping? Isn’t clipping much easier in NDC space?  
> **username_1**: 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.  

---

## 1 answers

### Answer by username_2 on 2019-10-04. Score: 1

As pointed out by username_1 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](http://web.cse.ohio-state.edu/~shen.94/781/Site/Slides_files/pipeline.pdf) suggests that vertices are transformed to Clip Space, then the primitive assembly happens and only afterwards is clipping actually done.

---

~~According to [Khronos' wiki](https://www.khronos.org/opengl/wiki/Rendering_Pipeline_Overview) 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](https://www.khronos.org/opengl/wiki/Vertex_Post-Processing#Viewport_transform) 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.

> **Comments:**
> **username_1**: *" 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.  
> **username_0**: How could it be that primitive assembly happens after clipping? Surely clipping cannot be performed on vertices without first knowing their primitives?  
> **username_2**: 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.  

---

