Author: Not specified Language: glsl
Description: Not specified Timestamp: 2017-08-29 06:59:33 +0000
View raw paste Reply
  1. precision highp float;
  2. varying vec4 vertexPosition;
  3. void main(void) {
  4.   float polarTheta = atan(vertexPosition.y, vertexPosition.x);
  5.   float radius = pow(pow(vertexPosition.x, 2.0) + pow(vertexPosition.y, 2.0), 1.0 / 2.0) * 4.0;
  6.   float lotus1 = 1.0 + (((abs(cos(polarTheta*3.0))) + (0.25-(abs(cos(polarTheta*3.0+3.14/2.0))))*2.0) / (2.0+abs(cos(polarTheta*6.0 + 3.14/2.0))*8.0));
  7.   float lotus2 = 2.0 + (((abs(cos(polarTheta*3.0))) + (0.25-(abs(cos(polarTheta*3.0+3.14/2.0))))*2.0) / (2.0+abs(cos(polarTheta*6.0 + 3.14/2.0))*8.0));
  8.   float lotus3 = 3.0 + (((abs(cos(polarTheta*6.0))) + (0.25-(abs(cos(polarTheta*6.0+3.14/2.0))))*2.0) / (2.0+abs(cos(polarTheta*12.0 + 3.14/2.0))*8.0));
  9.   vec4 circleColor;
  10.   if (radius < lotus1) {
  11.     circleColor = vec4(1.0, 1.0, 1.0, 1.0);
  12.   } else if (radius < lotus2) {
  13.     circleColor = vec4(1.0, 0.0, 0.0, 1.0);
  14.   } else if (radius < lotus3) {
  15.     circleColor = vec4(0.0, 0.0, 1.0, 1.0);
  16.   } else {
  17.     circleColor = vec4(0.0, 1.0, 1.0, 1.0);
  18.   }
  19.   gl_FragColor = circleColor;
  20. }
View raw paste Reply