Portal:OpenGL Shading Language/Fragment Shader: Difference between revisions

From OpenGL Wiki
Jump to navigation Jump to search
m Added clarification.
Smaller.
Line 3: Line 3:
Fragment shader input values are interpolated across the surface of the primitive, based on the [[Type_Qualifier_(GLSL)#Interpolation_qualifiers|interpolation qualifiers]] present on the input variable declaration (and on the corresponding output declaration in the previous shader stage).
Fragment shader input values are interpolated across the surface of the primitive, based on the [[Type_Qualifier_(GLSL)#Interpolation_qualifiers|interpolation qualifiers]] present on the input variable declaration (and on the corresponding output declaration in the previous shader stage).


Fragment shaders are afforded a number of capabilities not given to other shader stages. Fragment shaders have the ability to use most of the [[Sampler (GLSL)|texture accessing functions]] with full mipmapping support. This is because fragment shaders have access to "implicit derivatives" of their values, which are needed to automatically compute the proper mipmap level. Fragment shaders also have the ability to 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.
Fragment shaders can use most of the [[Sampler (GLSL)|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.

Revision as of 08:37, 25 July 2013

When a Primitive is rasterized, it is converted 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.