what i expected: a red circle with 100xp radius on the center of the object
what i got: a quarter of a circle on the lower left edge of the screen (0,0 coordinates)
so what am i misunderstanding or is the desired effect even possible to achieve?
gl_FragCoord is in window coordinates, e.g. [0, width], [0, height]. You gotta convert to normalized device coordinates [-1,1] which is what the projection matrix uses, here’s how to do it: http://www.txutxi.com/?p=182
I’m trying to write a fragment shader that is influenced by line going through my object. Since it didn’t work and I need two points to construct a line, I made this example to verify if I could at least get the center coordinate of my mesh. As it turns out - I can’t.
UPDATE:
I managed to find the reason why it didn’t work. Apparently after normalized device transformation, normalized perspective division was needed ( * point.w):