Fragment: Difference between revisions
→Fragment shader inputs: Fixed link. |
Added a few more inputs. Also, linking to the right places. |
||
Line 1: | Line 1: | ||
A '''Fragment''' is a collection of values produced by the [[Rasterizer]]. Each fragment represents a sample-sized segment of a rasterized [[Primitive]]. The size covered by a fragment is related to the pixel area, but rasterization can produce multiple fragments from the same triangle per-pixel, depending on various multisampling parameters and OpenGL state. There will be at least one fragment produced for every pixel area covered by the primitive being rasterized. | A '''Fragment''' is a collection of values produced by the [[Rasterizer]]. Each fragment represents a sample-sized segment of a rasterized [[Primitive]]. The size covered by a fragment is related to the pixel area, but rasterization can produce multiple fragments from the same triangle per-pixel, depending on various multisampling parameters and OpenGL state. There will be at least one fragment produced for every pixel area covered by the primitive being rasterized. | ||
Fragments are processed in a manor similar to vertices in a [[Vertex Shader]]. | Fragments are processed in a manor similar to vertices in a [[Vertex Shader]]. For them, an input vertex, build from [[Vertex Attribute]]s defined during [[Vertex Specification]], enters the [[Vertex Shader]]. After arbitrary processing, the vertex shader writes a number of values. These values represent the output vertex, and this output vertex is passed along to the next stages of the pipeline. | ||
Fragments work the same way. An input fragment, built by the rasterizer, enters the [[Fragment Shader]]. After arbitrary processing, the fragment shader writes a number of values. These values represent the output fragment, and this output fragment is passed along to the next stage of the pipeline. | Fragments work the same way. An input fragment, built by the rasterizer, enters the [[Fragment Shader]]. After arbitrary processing, the fragment shader writes a number of values. These values represent the output fragment, and this output fragment is passed along to the next stage of the pipeline. | ||
Line 9: | Line 9: | ||
Initially, the data for a fragment consists of the following: | Initially, the data for a fragment consists of the following: | ||
* The screen-space position of the fragment, in | * The screen-space position of the fragment, in X, Y and Z. | ||
* A stencil value. | * A stencil value. | ||
* If point rasterization is being used, then there will be a location within the point for this fragment. | * If point rasterization is being used, then there will be a [[Primitive#Point Fragment Inputs|location within the point for this fragment]]. | ||
* Arbitrary values written by the last vertex processing stage, which have been interpolated across the primitive's surface according to each variable's [[Type Qualifier (GLSL)#Interpolation qualifiers|interpolation qualifiers]]. | * Arbitrary values written by the last vertex processing stage, which have been interpolated across the primitive's surface according to each variable's [[Type Qualifier (GLSL)#Interpolation qualifiers|interpolation qualifiers]]. | ||
* If a [[Geometry Shader]] is active, and it uses [[Geometry Shader#Layered rendering|layered rendering]], the primitive's layer and viewport indices are also part of the fragment. | |||
== Fragment shader outputs == | == Fragment shader outputs == | ||
Line 23: | Line 24: | ||
The color value array elements are routed to different buffers based on the [[Framebuffer#Draw_color_buffers|framebuffer's draw buffer state]]. | The color value array elements are routed to different buffers based on the [[Framebuffer#Draw_color_buffers|framebuffer's draw buffer state]]. | ||
== See also == | |||
* [[Rasterizer]] | |||
* [[Fragment Shader]] | |||
[[Category:General OpenGL]] | [[Category:General OpenGL]] |
Revision as of 03:22, 19 December 2014
A Fragment is a collection of values produced by the Rasterizer. Each fragment represents a sample-sized segment of a rasterized Primitive. The size covered by a fragment is related to the pixel area, but rasterization can produce multiple fragments from the same triangle per-pixel, depending on various multisampling parameters and OpenGL state. There will be at least one fragment produced for every pixel area covered by the primitive being rasterized.
Fragments are processed in a manor similar to vertices in a Vertex Shader. For them, an input vertex, build from Vertex Attributes defined during Vertex Specification, enters the Vertex Shader. After arbitrary processing, the vertex shader writes a number of values. These values represent the output vertex, and this output vertex is passed along to the next stages of the pipeline.
Fragments work the same way. An input fragment, built by the rasterizer, enters the Fragment Shader. After arbitrary processing, the fragment shader writes a number of values. These values represent the output fragment, and this output fragment is passed along to the next stage of the pipeline.
Fragment shader inputs
Initially, the data for a fragment consists of the following:
- The screen-space position of the fragment, in X, Y and Z.
- A stencil value.
- If point rasterization is being used, then there will be a location within the point for this fragment.
- Arbitrary values written by the last vertex processing stage, which have been interpolated across the primitive's surface according to each variable's interpolation qualifiers.
- If a Geometry Shader is active, and it uses layered rendering, the primitive's layer and viewport indices are also part of the fragment.
Fragment shader outputs
After processing, the output fragment from a fragment shader consists of the following:
- a depth value, either written by the fragment shader or passed through from the screen-space fragment's Z value.
- a stencil value.
- An array of zero or more color values, as written by the fragment shader.
The color value array elements are routed to different buffers based on the framebuffer's draw buffer state.