Ok, in my GLSL fragment shader I want to be able to calculate the distance of the fragment from a particular line in space.
The result of this is that I am first trying to use a varying vec2 set in my vertex shader to mirror what ends up in gl_FragCoord
:
varying vec2 fake_frag_coord;
//in vertex shader:
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
fake_frag_coord=(gl_ModelViewProjectionMatrix * gl_Vertex).xy;
Now in the fragment shader I expect:
gl_FragCoord.xy==fake_frag_coord
But it does not. What operation does the pipeline do on gl_Position
to turn it into gl_FragCoord
that I am neglecting to do on fake_frag_coord
?