1

I'm curious about how does OpenGL transform vertices output to fragments input by fragment interpolation. Could anyone post the formula or algorithm of how does OpenGL do fragment interpolation?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
suyen729
  • 93
  • 4
  • That depends on the [Interpolation qualifier](https://www.khronos.org/opengl/wiki/Type_Qualifier_(GLSL)#Interpolation_qualifiers) – Rabbid76 Sep 16 '20 at 12:12
  • 1
    Does this answer your question? [How exactly does OpenGL do perspectively correct linear interpolation?](https://stackoverflow.com/questions/24441631/how-exactly-does-opengl-do-perspectively-correct-linear-interpolation) – Rabbid76 Sep 16 '20 at 12:22

1 Answers1

1

This depends on the Interpolation qualifier. For a detailed explanation see OpenGL Shading Language 4.60 Specification (HTML) - 4.5. Interpolation Qualifiers.

By default (smooth) the interpolation is done in a perspective correct manner.
See How exactly does OpenGL do perspectively correct linear interpolation?.

But the interpolation can be changed. If the qualifier flat is explicitly specified, no interpolation takes place at all. The value given to the fragment shader is the value from the Provoking Vertex of the corresponding primitive.
noperspective causes a linear interpolation.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • Could you give some simple example formula for vec and integer of interpolation between out from vertex shader and in at fragment shader? – suyen729 Sep 16 '20 at 12:29
  • See [How exactly does OpenGL do perspectively correct linear interpolation?](https://stackoverflow.com/questions/24441631/how-exactly-does-opengl-do-perspectively-correct-linear-interpolation) – Rabbid76 Sep 16 '20 at 12:30