rulfen
05-02-2011, 06:56 AM
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)
vec2 p = gl_FragCoord.xy / screenDim_.xy;
vec2 circleCenter = vec2(0.5,0.5);
float dist = length(p - circleCenter _);
float circle = smoothstep(circleRadius_,circleRadius_ - 0.05,dist);
I have tried setting
vec2 p = gl_FragCoord.xy / screenDim_.x;
but then the circle is not positioned correctly
Thanks!
vec2 p = gl_FragCoord.xy / screenDim_.xy;
vec2 circleCenter = vec2(0.5,0.5);
float dist = length(p - circleCenter _);
float circle = smoothstep(circleRadius_,circleRadius_ - 0.05,dist);
I have tried setting
vec2 p = gl_FragCoord.xy / screenDim_.x;
but then the circle is not positioned correctly
Thanks!