What is the difference between sample, pixel and fragment?

I still can not plunge into the head about the differences between the pattern / pixel / fragment.

Since the fragment shader is executed per pixel, I think the fragment just refers to the pixel, is that correct? Can someone give me an example and definition of each of them?

+8
shader opengl
source share
2 answers

A pixel is an element of the screen. A fragment is an appropriate part for a given geometric primitive + - for covering a pixel. For smoothing (and more), several samples can be selected in a pixel.

Pixel values ​​are the average of the values ​​of the samples, and fragments of several triangles can contribute to a given pixel.

+2
source share

A fragment shader is executed for each fragment and emits pixels. They are very similar, but not the same.

A fragment is a set of values ​​created by a Rasterizer. Each fragment represents a segment of a sample with a rasterized primitive. The size covered by the fragment is related to the pixel area, but rasterization can create several fragments from the same triangle per pixel, depending on various multisampling parameters and OpenGL state. At least one fragment will be created for each region of pixels covered by the priming rasterization. A source

So, if you completely disable multisampling / antialiasing, each fragment should be displayed on one pixel. But if you turn it on, several fragments will be interpolated to form one pixel.

Differentiation can also be seen in Rendering Pipelines OpenGL here: https://openglinsights.com/pipeline.html

+2
source share

All Articles