What does the 1/w coordinate stand for in gl_FragCoord?

前端 未结 2 1855
孤街浪徒
孤街浪徒 2021-02-10 05:36

The gl_FragCoord variable stores four components: (x, y, z, 1/w)

What is the w coordinate and why is it stored as 1/w?

2条回答
  •  难免孤独
    2021-02-10 06:24

    A homogeneous coordinate is given by: (x, y, z, w), which projects to: (x/w, y/w, z/w). gl_FragCoord stores this projection, but rather than storing the (useless) (w/w) = (1) for the last component, it stores (1/w), to preserve useful information.

提交回复
热议问题