[Interpolation in OpenGL]

Hello,

I wanted to know how the interpolation works in OpenGL.
Does interpolation result in generating fragments inside the shape (example: a triangle) I want to draw after executing vertex and geometry shaders?
Because, mathematically, an interpolation is the generation of new values based on existing values. So in this case, the existing values are the triangle’s vertices and the new values are the fragments.
Does it make sense ? I’m afraid I got it all wrong.

Thank you.

Rasterisation (generation of fragments) occurs after the vertex, tessellation, and geometry shaders, and before the fragment shader.

For any given fragment, the value of each fragment shader input is determined by interpolating the values of the corresponding output for the last shader stage before the fragment shader (the geometry shader if it exists, otherwise the tessellation evaluation shader if that exists, otherwise the vertex shader).

The exact calculation depends upon whether the variable was declared with smooth, noperspective or flat interpolation qualifiers (the default is smooth, i.e. perspective-correct interpolation).

1 Like

Thank you.
But according to my research, rasterisation is the generation of pixels and pixels aren’t fragments right ?

A fragment is one invocation of the fragment shader. For single-sample rasterisation, each pixel which is modified by rasterisation of the primitive results in one invocation of the fragment shader. For multi-sample rasterisation, there can be one invocation per pixel or several.

1 Like

Not within the context of GPU rendering.

Rasterization generates fragments, which after processing can yield per-fragment values which after further processing may be written to pixels in the framebuffer. Images store pixels. Fragments are generated relative to pixels (or more accurately, the pixel grid defined by the framebuffer), but they aren’t pixels yet (and may never become pixels, since they can be discarded).

A pixel can be composed of multiple samples, and fragments can write their values to one or more of the samples within a pixel. This is what multisample rendering is.

1 Like