-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path36_Hypnocone.fs
executable file
·149 lines (132 loc) · 2.43 KB
/
36_Hypnocone.fs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// SaturdayShader Week 36 : SpiralCone
// by Joseph Fiola (http://www.joefiola.com)
// 2016-04-23
// Based on "Flailing" Shadertoy by okro
//https://www.shadertoy.com/view/MsjSWw
/*{
"CREDIT": "",
"DESCRIPTION": "",
"CATEGORIES": [
"Generator"
],
"INPUTS": [
{
"NAME": "invert",
"TYPE": "bool"
},
{
"NAME": "zoom",
"TYPE": "float",
"DEFAULT": 2.0,
"MIN": 0.25,
"MAX": 10.0
},
{
"NAME": "rings",
"TYPE": "float",
"DEFAULT": 0.01,
"MIN": 0.01,
"MAX": 1.0
},
{
"NAME": "radius",
"TYPE": "float",
"DEFAULT": 1.0,
"MIN": 0.001,
"MAX": 2.0
},
{
"NAME": "xAmp",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": -0.1,
"MAX": 0.1
},
{
"NAME": "xOffset",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": -1.0,
"MAX": 1.0
},
{
"NAME": "xOffsetSpeed",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": 0.0,
"MAX": 0.1
},
{
"NAME": "yAmp",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": -0.1,
"MAX": 0.1
},
{
"NAME": "yOffset",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": -1.0,
"MAX": 1.0
},
{
"NAME": "yOffsetSpeed",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": 0.0,
"MAX": 0.1
},
{
"NAME": "startPoint",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": 0.0,
"MAX": 300.0
},
{
"NAME": "rotate",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": 0.0,
"MAX": 1.0
},
{
"NAME": "pos",
"TYPE": "point2D",
"DEFAULT": [0.5,0.5],
"MIN":[0.0,0.0],
"MAX":[1.0,1.0]
}
]
}*/
#define TWO_PI 6.28318530718
mat2 rotate2d(float _angle){
return mat2(cos(_angle),-sin(_angle),
sin(_angle),cos(_angle));
}
void main()
{
vec2 uv = gl_FragCoord.xy / RENDERSIZE.xy;
uv -= vec2(pos);
uv.x *= RENDERSIZE.x/RENDERSIZE.y;
uv = rotate2d(rotate*-TWO_PI) * uv;
uv *= zoom;
vec3 col = vec3(0.);
vec2 loc = uv * 0.0;
float radius = radius+rings;
for (int i = 0; i < 100; ++i) {
float r = smoothstep(radius, radius+.004, distance(uv,loc));
col = 1.0 - col * r;
//move circles
float dx = xAmp;
dx += cos((startPoint + TIME) * xOffsetSpeed * float(i)) * xOffset;
float dy = yAmp;
dy += sin((startPoint + TIME) * yOffsetSpeed * float(i)) * yOffset;
loc += vec2(dx, dy);
//make smaller
radius -= rings;
}
if (invert) col = col *-1.0 + 1.0;
gl_FragColor = vec4(col, 1.0);
}