-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRainbow_circle.c
More file actions
47 lines (40 loc) · 1.12 KB
/
Rainbow_circle.c
File metadata and controls
47 lines (40 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// https://www.shadertoy.com/view/XdlSDs
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// make origin (0,0) in center of the screen
vec2 p = (2.0*fragCoord.xy-iResolution.xy)/iResolution.y;
float tau = 3.1415926535*2.0;
float a = atan(p.x,p.y);
float r = length(p)*0.55; // 1/radius of circle default = 0.75
vec2 uv = vec2(a/tau,r);
const float numberOfLoops = 1.0; // 1.0
const float coef = 3.0; // 3.0
//get the color
float xCol = (uv.x - (iTime / coef)) * coef * numberOfLoops;
xCol = mod(xCol, 3.0);
vec3 horColour = vec3(0.25); // 0.25
if (xCol < 1.0)
{
horColour.r += 1.0 - xCol;
horColour.g += xCol;
}
else if (xCol < 2.0)
{
xCol -= 1.0;
horColour.g += 1.0 - xCol;
horColour.b += xCol;
}
else
{
xCol -= 2.0;
horColour.b += 1.0 - xCol;
horColour.r += xCol;
}
// draw color beam
uv = (2.0 * uv) - 1.0;
float beamWidth =
(0.7+0.5*cos(uv.x*10.0*tau*0.15*clamp(floor(5.0 + 10.0*cos(iTime)), 0.0, 10.0)))
* abs(1.0 / (30.0 * uv.y));
vec3 horBeam = vec3(beamWidth);
fragColor = vec4((( horBeam) * horColour), 1.0);
}