I have written a fragment shader, on a shape which is a square made with
gl.TRIANGLE_STRIP, and which displays a radar:
To build the radar, I'm using distance from the center of the shape.
Currently, I'm using
gl_FragCoord and have to pass the shader the size of the window, the position of the center of the radar, in order to determine where I am in the shape. I'm not really OK with that..
I would like to know if there is a better way to make the shader, to make it independent from display variables.
For example I thought I could use
gl_PointCoord whose x and y coordinates goes from 0. to 1., but it requires to use
GL_POINTS... I could give it a try by using
GL_POINTS, but I'm not sure it's THE best solution.
For example, I could make a 3d scene, with lot of cubes, and display this radar on the faces of that cube. If the shader isn't independent from
gl_FragCoord, it feels like it will be a nightmare to make it work.
Is there a way to get the relative position of the pixel we are giving the color, in the shape (triangle) we are rendering? Do you have suggestions / tips?