2

I'm very confused when it is necessary for a homogeneous coordinate (x, y, z, w) get divided by w (ie. converting to (x/w, y/w, z/w, 1)).

According to this page, when a homogeneous vertex coordinate is passed through a orthographical or projective matrix, the coordinate will be in clip coordinates. Perspective division is necessary for clip coordinates to get NDC. It will produce x, y, and z values in range (-1, 1).

I was following WebGL tutorial pages on orthographical and perspective projection. These tutorials didn't mention a single word about perspective division. I'm not sure if the division is still necessary after multiplying with projective matrix. Perhaps, the division is performed automatically during matrix multiplication?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Real Donald Trump
  • 412
  • 1
  • 5
  • 15
  • 2
    "*These tutorials didn't mention a single word about perspective division.*" You mean, besides all the words [in this section](http://learnwebgl.brown37.net/08_projections/projections_perspective.html#the-perspective-calculation) where it specifically talks about the perspective divide? It literally says, "*The graphics pipeline is designed to expect the perspective divisor in the w component. The pipeline always calculates (x/w, y/w, z/w) before passing a vertex’s values onto the remaining stages.*" – Nicol Bolas May 29 '22 at 01:57
  • Now, I personally don't like some of the language used there, but it does talk about it. – Nicol Bolas May 29 '22 at 01:57
  • Oh, thanks for pointing out. For some reason, I missed this section. I see, I finally got answer to my question: perspective division is necessary after using perspective projection matrix but not necessary for orthographic projection matrix. – Real Donald Trump May 29 '22 at 02:06

1 Answers1

3

The perspective divide (the conversion from clip space to NDC space) is neither necessary nor unnecessary; it is a part of the graphics pipeline. It happens automatically to every vertex that passes through the system.

You can make it into a no-op by setting a vertex's W component to 1.0 (which is what the orthographic projection matrix does, assuming the input position had a W of 1.0). But the division always happens.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982