What does the 1 / w coordinate mean in gl_FragCoord?

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

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

+5
source share
2 answers

The GLSL and OpenGL specifications are useless in this regard. The specifics of OpenGL are easier to understand: it gl_FragCoordstores the components X, Y and Z at the position of the vertices of the window. The values ​​of X, Y and Z are calculated as described to calculate the position of the window (although the pixel center and the top left start can change the values ​​of X and Y). This is described in the Coordinate Transformsspecification section .

The W component gl_FragCoordis (1 / W c), where W c - . gl_Position.w .

W c reverse-transform gl_FragCoord, . , , W c. gl_FragCoord , gl_FragCoord.w.

, , OpenGL , OpenGL ;) ., , OpenGL . XYZ , , , .

, , 3D Labs GLSL. , , .

+12

: (x, y, z, w), : (x/w, y/w, z/w). gl_FragCoord , () (w/w) = (1) (1/w), .

+2

All Articles