Remember that there is a lot going on in the fixed pipeline between the vertex shader and the fragment shader.
The vertex shader sends the position down the pipeline, and then primitive assembly sorts the vertices into triangles, then these triangles are scanned and any fragments inside these triangles are sent to the the fragment shader. If any of that is unfamiliar to you, I suggest that you study Chapter 3 The Rendering Pipeline. That one is an important chapter to understand, and probably needs a number of readings and going back to it later on for further understanding.
So [[position]]
coming out of the vertex shader contains the float4
position of the vertex, but going into the fragment shader, the xy
of the [[position]]
contains the screen coordinates of the current fragment.
Btw, if you’re using a struct with [[stage_in]]
, the [[position]]
attribute is inside that struct, as in this debug screenshot
Hopefully you can see the coordinates (311.5, 199.5) of the fragment being debugged.