GLSL着色器|切片的圆圈

时间:2014-11-21 13:28:58

标签: glsl geometry clock degrees

我正在尝试使用GLSL着色器在Quartz Composer中制作一种极性时钟。问题是我不知道这种编程语言。但是我一直在搜索并发现这段代码是一个好的开始:

顶点着色器:

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

片段着色器:

#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;    
}

现在我想知道在这个代码的哪个位置说它将根据输入的变量以度数绘制。

提前谢谢

0 个答案:

没有答案
相关问题