Hi! I think I have a misunderstanding, when passinng the vertex poses to the fragment shader. So, when I’m using the out keyword with the vertex poses, and pass them to the fragment shader with the in keyword, what will be the value of the variable in the fragment shader? I understand that it is interpolated, but what does it mean? Does it mean, that the vertex pos become the position of each pixel(fragment)? If yes, how is it working?
It is interpolated across the primitive being rasterized.
Take a triangle for example. The vertex shader runs for each vertex in the triangle (3X) and outputs a value for each vertex for that specific output. The fragment shader runs for each fragment (pixel, or sample) interior to that triangle. How does it even make sense to pass values from the vertex shader to the fragment shader when they represent different points in space?
Well, thanks to the vertex shader, we know the values at the vertices. So these values are interpolated (blended) across the triangle between the vertices to get their values at points 'between" those vertices.
You have some control over how (or whether) this interpolation is performed, but in general it behaves the way you’d expect it to behave when rasterizing planar 3D geometry. (it’s smooth, perspective-correct interpolation. See this section in the wiki for more details: Type_Qualifier_(GLSL) # Interpolation_qualifiers.