Hello All,
i tried obtaining the window coordinates in my fragment shader. So, this is my approach:
In the vertex shader:
Code :varying vec2 my_fragCoord; my_fragCoord = (gl_ModelViewProjectionMatrix * gl_Vertex).xy; // getting clip coordinates. my_fragCoord /= w; // Do perspective divide
1) And, now in the fragment shader, i scale appropriately by the window size. Is this the right way to do it? Or is there a better way
to achieve the same?
Thanks!