-
Notifications
You must be signed in to change notification settings - Fork 7
/
26_SoftPatterns.fs
executable file
·103 lines (86 loc) · 1.63 KB
/
26_SoftPatterns.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
// SaturdayShader Week 26 : Soft Patterns
// by Joseph Fiola (http://www.joefiola.com)
// 2016-02-13
// Based on Interferance, Color Waves by @gabrieldunne
// https://twitter.com/gabrieldunne/status/671398225593561090
// http://glslsandbox.com/e#29006.1
/*{
"CREDIT": "Joseph Fiola",
"DESCRIPTION": "",
"CATEGORIES": [
"Generator"
],
"INPUTS": [
{
"NAME": "zoom",
"TYPE": "float",
"DEFAULT": 20.0,
"MIN": 0.0,
"MAX": 50.0
},
{
"NAME": "iterations",
"TYPE": "float",
"DEFAULT": 20.0,
"MIN": 0.0,
"MAX": 50.0
},
{
"NAME": "contrast",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": -20.0,
"MAX": 20.0
},
{
"NAME": "offset",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": 0.0,
"MAX": 1.0
},
{
"NAME": "pattern",
"TYPE": "float",
"DEFAULT": 1.1,
"MIN": 1e-4,
"MAX": 10.0
},
{
"NAME": "rotate",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": -1.0,
"MAX": 1.0
},
{
"NAME": "pos",
"TYPE": "point2D",
"DEFAULT": [0.5,0.5],
"MIN":[0.0,0.0],
"MAX":[1.0,1.0]
}
]
}*/
#define PI 3.14159
#define TWO_PI (PI*2.0)
vec2 rot(vec2 uv,float a){
return vec2(uv.x*cos(a) -uv.y*sin(a),uv.y*cos(a)+uv.x*sin(a));
}
void main()
{
vec2 center = (gl_FragCoord.xy);
vec2 uv = gl_FragCoord.xy / RENDERSIZE.xy;
uv -= vec2(pos);
uv.x *= RENDERSIZE.x/RENDERSIZE.y;
uv *= zoom;
uv=rot(uv,rotate * PI);
float col = contrast;
for(float i = 0.0; i < 50.0; i++)
{
float a = i * (TWO_PI / pattern);
col += cos(TWO_PI*(uv.y * cos(a) + uv.x * sin(a) + offset));
if (i >= iterations) break;
}
gl_FragColor = vec4(col*1.0, col*1.0,col*1.0, 1.0);
}