-
Notifications
You must be signed in to change notification settings - Fork 6
/
39_MoreMoire.fs
executable file
·128 lines (115 loc) · 2.04 KB
/
39_MoreMoire.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
// SaturdayShader Week 39 : More Moiré
// by Joseph Fiola (http://www.joefiola.com)
// 2016-05-14
// Based on "Moiré Bounce" Shadertoy by echophon
// https://www.shadertoy.com/view/XlfGDB
/*{
"CREDIT": "Joseph Fiola",
"DESCRIPTION": "",
"CATEGORIES": [
"Generator"
],
"INPUTS": [
{
"NAME": "invert",
"TYPE": "bool"
},
{
"NAME" : "zoom",
"TYPE" : "float",
"DEFAULT": 10.0,
"MIN": 1e-4,
"MAX": 20.0
},
{
"NAME" : "moire_x",
"TYPE" : "float",
"DEFAULT": 10.0,
"MIN": 1e-4,
"MAX": 10.0
},
{
"NAME" : "moire_y",
"TYPE" : "float",
"DEFAULT": 4.0,
"MIN": 1e-4,
"MAX": 10.0
},
{
"NAME" : "shape_x",
"TYPE" : "float",
"DEFAULT": 1.005,
"MIN": 0.0,
"MAX": 1.0
},
{
"NAME" : "shape_y",
"TYPE" : "float",
"DEFAULT": 0.5,
"MIN": 0.0,
"MAX": 1.0
},
{
"NAME" : "mult_x",
"TYPE" : "float",
"DEFAULT": 1.0,
"MIN": 0.0,
"MAX": 10.0
},
{
"NAME" : "mult_y",
"TYPE" : "float",
"DEFAULT": 2.0,
"MIN": 0.0,
"MAX": 10.0
},
{
"NAME": "speed",
"TYPE": "float",
"DEFAULT": 0.0,
"MIN": 0.0,
"MAX": 1000.0
},
{
"NAME": "timeOffset",
"TYPE": "float",
"DEFAULT": 80.0,
"MIN": 0.0,
"MAX": 1000.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]
}
]
}*/
#ifdef GL_ES
precision mediump float;
#endif
#define TWO_PI 6.28318530718
// Rotate
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 *= zoom;
uv = rotate2d(rotate*-TWO_PI) * uv;
float _time = TIME + timeOffset;
float distance = sqrt( pow(abs(uv[0]), shape_x * mult_x) + pow(abs(uv[1]), shape_y * mult_y) + speed);
float color = sin(distance * _time * moire_x) * cos(distance * _time * moire_y);
if (invert) color = color *-1.0 + 1.0;
gl_FragColor = vec4(color, color, color,1.0);}