Portal:OpenGL Shading Language/Fragment Shader

From OpenGL Wiki
Jump to navigation Jump to search

When a Primitive is rasterized, it is converted into blocks of data based on sample-sized areas of the primitive being rasterized. This data is called a Fragment. The Fragment Shader is the shader stage responsible for processing fragments. For each input fragment, it produces an output fragment consisting of a number of colors, a depth, and a stencil value that will be output to the Framebuffer (after some post-fragment shader operations).

Fragment shader input values are interpolated across the surface of the primitive, based on the interpolation qualifiers present on the input variable declaration (and on the corresponding output declaration in the previous shader stage).

Fragment shaders can use most of the texture accessing functions with full mipmapping support. They also can effectively abort processing, which not only ignores the output of the fragment shader, but culls the fragment entirely, as if the fragment had never been rasterized.