GLSL Shaders | Slices of circle

796 views Asked by At

I'm trying to make kind of polar clock in Quartz Composer with GLSL Shaders. The problem is i've no idea of this programming language. However i've been searching and found this code as good start:

Vertex Shader:

#version 120    
void main()
{
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;       
  gl_TexCoord[0] = gl_MultiTexCoord0;
}

Fragment Shader:

#version 120
uniform sampler2D tex0;
uniform float border; // 0.01
uniform float circle_radius; // 0.5
uniform vec4 circle_color; // vec4(1.0, 1.0, 1.0, 1.0)
uniform vec2 circle_center; // vec2(0.5, 0.5)
void main (void)
{
  vec2 uv = gl_TexCoord[0].xy;

  vec4 bkg_color = texture2D(tex0,uv * vec2(1.0, -1.0));

  // Offset uv with the center of the circle.
  uv -= circle_center;

  float dist =  sqrt(dot(uv, uv));
  if ( (dist > (circle_radius+border)) || (dist < (circle_radius-border)) )
    gl_FragColor = bkg_color;
  else 
    gl_FragColor = circle_color;    
}

Now i'd like to know where to say to this code that it will be drawn by degrees depending of the variable on the input.

Thank You in advance

0

There are 0 answers