Why does GL divide `gl_Position` by W for you rather than letting you do it yourself?

后端 未结 3 1724
一整个雨季
一整个雨季 2020-12-01 04:52

Note: I understand the basic math. I understand that the typical perspective function in various math libraries produces a matrix that converts z values from -z

3条回答
  •  一生所求
    2020-12-01 04:58

    The reason is, that not only gl_Position gets divided by the homogeneous coordinate, but also all other interpolated varyings. This is called perspective correct interpolation which requires the division to be after the interpolation (and thus after the rasterization). So doing the division in the vertex shader would simply not work. See also this post.

提交回复
热议问题