This procedural texture recipe will make use of fragment coordinates to demonstrate a circular pattern using gl_FragCoord
. The gl_FragCoord
is a keyword available in the fragment shader that is responsible to store the window position of the current fragment in x and y coordinates; the z coordinate stores the depth of the fragment in the range [0, 1]
.
These coordinates are always relative to the OpenGL ES surface window; the gl_FragCoords
is a result of a fixed functionality in which primitive are interpolated after the vertex processing stage to generate fragments. By default, the gl_FragCoord
assumes the lower-left corner of the OpenGL ES rendering surface window as the origin. The following image shows the origin in the OpenGL ES surface window with different dimensions: