Hi, I would like to draw a circle in a GLSL shader when the render window is not square. In my solution the circle turns into an ellipse when the window size is not square (ex. 640x480 instead of 512x512)
You could scale your vector from the midpoint to the fragment differently in x and y to adjust for the aspect ratio, but a cleaner way would be to do the computations in unscaled fragment coordinates, without doing any scaling:
Several advantages here. The max() function handles a tall and narrow window as well as a low and wide one. The smoothstep gets a step width in fragment coordinates, which creates an anti-aliasing that is independent on the viewport resolution.