shaderflow 0.4.0.dev1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of shaderflow might be problematic. Click here for more details.
- ShaderFlow/Common/Imgui.py +0 -0
- ShaderFlow/Common/Notes.py +134 -0
- ShaderFlow/Common/__init__.py +0 -0
- ShaderFlow/Message.py +147 -0
- ShaderFlow/Module.py +162 -0
- ShaderFlow/Modules/Audio.py +431 -0
- ShaderFlow/Modules/Bouncing.py +94 -0
- ShaderFlow/Modules/Camera.py +451 -0
- ShaderFlow/Modules/Depth.py +0 -0
- ShaderFlow/Modules/Dynamics.py +288 -0
- ShaderFlow/Modules/Frametimer.py +79 -0
- ShaderFlow/Modules/Keyboard.py +43 -0
- ShaderFlow/Modules/Noise.py +80 -0
- ShaderFlow/Modules/OpticalFlow.py +1 -0
- ShaderFlow/Modules/Piano.py +362 -0
- ShaderFlow/Modules/Spectrogram.py +315 -0
- ShaderFlow/Modules/Video.py +234 -0
- ShaderFlow/Modules/Waveform.py +100 -0
- ShaderFlow/Modules/__init__.py +0 -0
- ShaderFlow/Resources/Images/ShaderFlow.png +0 -0
- ShaderFlow/Resources/Images/ShaderFlow.svg +1 -0
- ShaderFlow/Resources/Scenes/Examples/Demo.py +284 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/Bars.frag +20 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/Bouncing.frag +50 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/Life/Simulation.glsl +49 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/Life/Visuals.glsl +31 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/MotionBlur.frag +20 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/Multipass.frag +43 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/RayMarch.frag +59 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/ShaderToy.frag +65 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/Video.frag +5 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/Visualizer.frag +75 -0
- ShaderFlow/Resources/Scenes/Examples/GLSL/Waveform.frag +18 -0
- ShaderFlow/Resources/Shaders/Fragment/Default.glsl +65 -0
- ShaderFlow/Resources/Shaders/Fragment/Final.glsl +7 -0
- ShaderFlow/Resources/Shaders/Fragment/Loading.frag +40 -0
- ShaderFlow/Resources/Shaders/Fragment/Missing.glsl +23 -0
- ShaderFlow/Resources/Shaders/Include/Camera.glsl +166 -0
- ShaderFlow/Resources/Shaders/Include/Complex.glsl +0 -0
- ShaderFlow/Resources/Shaders/Include/ShaderFlow.glsl +444 -0
- ShaderFlow/Resources/Shaders/Vertex/Default.glsl +21 -0
- ShaderFlow/Scene.py +1124 -0
- ShaderFlow/Shader.py +391 -0
- ShaderFlow/Texture.py +528 -0
- ShaderFlow/Variable.py +128 -0
- ShaderFlow/__init__.py +11 -0
- ShaderFlow/__main__.py +22 -0
- shaderflow-0.4.0.dev1.dist-info/METADATA +79 -0
- shaderflow-0.4.0.dev1.dist-info/RECORD +51 -0
- shaderflow-0.4.0.dev1.dist-info/WHEEL +5 -0
- shaderflow-0.4.0.dev1.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// (c) MIT, Tremeschin
|
|
3
|
+
// Hours wasted: 6
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#define ADVANCED_CORRECTION true
|
|
7
|
+
|
|
8
|
+
void main() {
|
|
9
|
+
float angle;
|
|
10
|
+
float aspect;
|
|
11
|
+
|
|
12
|
+
// Take into account rotation and image contents
|
|
13
|
+
// Fixme: Vertical stretching is slightly wrong
|
|
14
|
+
if (ADVANCED_CORRECTION) {
|
|
15
|
+
aspect = texture(iBounceAspectRatio, vec2(angle/TAU, 0.5)).r;
|
|
16
|
+
angle = iTime/2;
|
|
17
|
+
} else {
|
|
18
|
+
aspect = logoAspectRatio;
|
|
19
|
+
angle = 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Calculate the coordinate, a lot going on I wished to explain
|
|
23
|
+
vec2 correction = (1 - iLogoSize*vec2(aspect/iAspectRatio, 1));
|
|
24
|
+
vec2 uv = (gluv - iBouncePosition*correction) / iLogoSize;
|
|
25
|
+
uv *= rotate2d(angle);
|
|
26
|
+
|
|
27
|
+
// // Grid - Not part of the tech demo
|
|
28
|
+
|
|
29
|
+
// Background
|
|
30
|
+
int grid_spacing = 100;
|
|
31
|
+
int grid_thick = 2;
|
|
32
|
+
float size1 = 180.0;
|
|
33
|
+
|
|
34
|
+
// Background color
|
|
35
|
+
fragColor = vec4(vec3(0.3), 1);
|
|
36
|
+
|
|
37
|
+
// Grid marks when spacing fract (mod) pixel distance is less than value
|
|
38
|
+
bool _x = mod(glxy.x, grid_spacing) > (grid_spacing - grid_thick);
|
|
39
|
+
bool _y = mod(glxy.y, grid_spacing) > (grid_spacing - grid_thick);
|
|
40
|
+
if (_x || _y) {
|
|
41
|
+
fragColor = vec4(vec3(0.2), 1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// // Draw the bouncing logo
|
|
45
|
+
|
|
46
|
+
if (!agluv_oob(uv)) {
|
|
47
|
+
fragColor = alpha_composite(fragColor, gtexture(logo, uv));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// (c) MIT, Tremeschin
|
|
3
|
+
Conway's Game of Life Simulation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Live cells with two or three neighbours survive
|
|
7
|
+
const int alive[9] = int[9](
|
|
8
|
+
0, 0, 1,
|
|
9
|
+
1, 0, 0,
|
|
10
|
+
0, 0, 0
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
// Dead cell swith three neighbours becomes alive
|
|
14
|
+
const int dead[9] = int[9](
|
|
15
|
+
0, 0, 0,
|
|
16
|
+
1, 0, 0,
|
|
17
|
+
0, 0, 0
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
void main() {
|
|
21
|
+
int near = 0;
|
|
22
|
+
int current;
|
|
23
|
+
|
|
24
|
+
// Make the animation slower
|
|
25
|
+
if ((iFrame % iLifePeriod) != 0) {
|
|
26
|
+
fragColor.r = texture(iLife1x0, astuv).r;
|
|
27
|
+
fragColor.a = 1;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
ivec2 pixel = ivec2(astuv*iLifeSize);
|
|
32
|
+
|
|
33
|
+
// Integrate the rules kernel
|
|
34
|
+
for (int x=-1; x<=1; x++) {
|
|
35
|
+
for (int y=-1; y<=1; y++) {
|
|
36
|
+
ivec2 point = pixel + ivec2(x, y);
|
|
37
|
+
int cell = texelFetch(iLife1x0, point, 0).r > 0.5 ? 1:0;
|
|
38
|
+
if (x==0 && y==0) {
|
|
39
|
+
current = cell;
|
|
40
|
+
} else {
|
|
41
|
+
near += cell;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Apply the rules
|
|
47
|
+
fragColor.r = (current==1)?alive[near]:dead[near];
|
|
48
|
+
fragColor.a = 1;
|
|
49
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// (c) MIT, Tremeschin
|
|
3
|
+
Conway's Game of Life Visuals
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#define COLOR1 vec3(0.01060815, 0.01808215, 0.10018654)
|
|
7
|
+
#define COLOR2 vec3(0.38092887, 0.12061482, 0.32506528)
|
|
8
|
+
#define COLOR3 vec3(0.79650140, 0.10506637, 0.31063031)
|
|
9
|
+
#define COLOR4 vec3(0.95922872, 0.53307513, 0.37488950)
|
|
10
|
+
|
|
11
|
+
void main() {
|
|
12
|
+
vec2 uv = iCamera.stuv;
|
|
13
|
+
|
|
14
|
+
// Rratio of the life temporal integration of f(t) = (1 - t)^k
|
|
15
|
+
// Higher values prefer latest states, lower values smooths all
|
|
16
|
+
float exponent = 1.3;
|
|
17
|
+
float area = 1/(exponent + 1);
|
|
18
|
+
|
|
19
|
+
// Integrate life
|
|
20
|
+
float life = 0;
|
|
21
|
+
life += stexture(iLife0x0, uv).r;
|
|
22
|
+
life += stexture(iLife1x0, uv).r * pow(0.8, exponent);
|
|
23
|
+
life += stexture(iLife2x0, uv).r * pow(0.6, exponent);
|
|
24
|
+
life += stexture(iLife3x0, uv).r * pow(0.4, exponent);
|
|
25
|
+
life += stexture(iLife4x0, uv).r * pow(0.2, exponent);
|
|
26
|
+
life /= (5*area);
|
|
27
|
+
|
|
28
|
+
// Colorize life
|
|
29
|
+
fragColor.rgb = palette(life, COLOR1, COLOR2, COLOR3, COLOR4);
|
|
30
|
+
fragColor.a = 1;
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// (c) MIT, Tremeschin
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
void main() {
|
|
6
|
+
vec2 uv = iCamera.stuv;
|
|
7
|
+
|
|
8
|
+
if (iLayer == 0) {
|
|
9
|
+
fragColor = stexture(background, uv);
|
|
10
|
+
} else if (iLayer == 1) {
|
|
11
|
+
// Average of the last iTemporal layers
|
|
12
|
+
vec4 color = vec4(0);
|
|
13
|
+
for (int i=0; i<iScreenTemporal; i++) {
|
|
14
|
+
float factor = smoothstep(1.0, 0.0, float(i)/iScreenTemporal);
|
|
15
|
+
color += iScreenTexture(i, 0, astuv) * factor;
|
|
16
|
+
}
|
|
17
|
+
fragColor = 2 * color/iScreenTemporal;
|
|
18
|
+
}
|
|
19
|
+
fragColor.a = 1;
|
|
20
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// (c) MIT, Tremeschin
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** Walk in circles around the pixel and integrate samples, divide by area
|
|
6
|
+
* • Radius: How far to walk to sample the blur
|
|
7
|
+
* • Directions: Number of "rays" to cast
|
|
8
|
+
* • Steps: Number of samples per ray until the radius is reached
|
|
9
|
+
*/
|
|
10
|
+
vec4 blur(sampler2D image, vec2 stuv, float radius, int directions, int steps) {
|
|
11
|
+
vec4 color = vec4(0);
|
|
12
|
+
float weights = 0.0;
|
|
13
|
+
|
|
14
|
+
for (float direction=0; direction<TAU; direction+=TAU/directions) {
|
|
15
|
+
for (float walk=1.0/steps; walk<1.0; walk+=1.0/steps) {
|
|
16
|
+
vec2 offset = vec2(cos(direction), sin(direction)) * radius * walk / 2000;
|
|
17
|
+
vec4 sample = texture(image, stuv + offset);
|
|
18
|
+
float weight = 1.0 - distance(offset, vec2(0)) / float(radius);
|
|
19
|
+
color += sample * weight;
|
|
20
|
+
weights += weight;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return color / weights;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void main() {
|
|
28
|
+
if (iLayer == 0) {
|
|
29
|
+
fragColor = stexture(background, stuv);
|
|
30
|
+
|
|
31
|
+
} else if (iLayer == 1) {
|
|
32
|
+
fragColor = texture(iScreen0x0, astuv);
|
|
33
|
+
|
|
34
|
+
// Invert red on the left, blur the right
|
|
35
|
+
if (gluv.x < 0) {
|
|
36
|
+
fragColor.r = 1 - fragColor.r;
|
|
37
|
+
} else {
|
|
38
|
+
fragColor = blur(iScreen0x0, astuv, 5, 8, 8);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fragColor.a = 1;
|
|
43
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// (c) MIT, Tremeschin
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#define MAX_STEPS 100
|
|
6
|
+
#define MAX_DIST 100.0
|
|
7
|
+
#define MIN_DIST 0.001
|
|
8
|
+
|
|
9
|
+
float sdScene(vec3 origin) {
|
|
10
|
+
// origin = fract(origin) - 0.5;
|
|
11
|
+
|
|
12
|
+
// float sphere = sdSphere(origin, vec3(sin(iTime)*3, 0, 3), 1);
|
|
13
|
+
// float box = sdBox(origin, vec3(0, 0, 10), vec3(8));
|
|
14
|
+
// float ground = sdPlane(origin, vec3(0, -1, 0), vec3(0, 1, 0));
|
|
15
|
+
|
|
16
|
+
// float sdf = 1e10;
|
|
17
|
+
// sdf = sdSmoothUnion(sdf, sphere, 1);
|
|
18
|
+
// sdf = sdSmoothUnion(sdf, box, 1);
|
|
19
|
+
// sdf = sdSmoothUnion(sdf, ground, 1);
|
|
20
|
+
// return box;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
float sdf = 2*MAX_DIST;
|
|
24
|
+
|
|
25
|
+
for (int i=2; i<8; i++) {
|
|
26
|
+
sdf = sdUnion(sdf, sdBox(origin, vec3(0, 0, i), vec3(i-1)));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return sdf;
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void main() {
|
|
34
|
+
vec3 col = vec3(0);
|
|
35
|
+
|
|
36
|
+
// Camera setup
|
|
37
|
+
vec3 origin = iCamera.origin;
|
|
38
|
+
vec3 target = iCamera.target;
|
|
39
|
+
vec3 forward = normalize(target - origin);
|
|
40
|
+
|
|
41
|
+
// Raymarching
|
|
42
|
+
float traveled = 0;
|
|
43
|
+
float walk = 0;
|
|
44
|
+
int steps;
|
|
45
|
+
|
|
46
|
+
for (steps=0; steps<MAX_STEPS; steps++) {
|
|
47
|
+
vec3 point = origin + (forward*traveled);
|
|
48
|
+
walk = sdScene(point);
|
|
49
|
+
traveled += walk;
|
|
50
|
+
if (walk<MIN_DIST || walk>MAX_DIST) break;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Color based on the distance
|
|
54
|
+
// col = palette_magma(1 - (sqrt(traveled)*0.1 + steps*0.01));
|
|
55
|
+
// col = vec3(sqrt(traveled)*0.1);
|
|
56
|
+
col = vec3(1 - sqrt(steps)*0.1);
|
|
57
|
+
|
|
58
|
+
fragColor = vec4(col, 1);
|
|
59
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
In ShaderFlow, the main function is as simple as it can get!
|
|
3
|
+
|
|
4
|
+
void main() {
|
|
5
|
+
fragColor = vec4(0.2);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Coordinates
|
|
9
|
+
|
|
10
|
+
All the coordinates are already converted for you:
|
|
11
|
+
|
|
12
|
+
- astuv: Absolute 'ShaderToy' uv, from (0, 0) to (1, 1)
|
|
13
|
+
- agluv: Absolute 'OpenGL' uv, from (-1, -1) to (1, 1)
|
|
14
|
+
|
|
15
|
+
- stuv: Aspect-ratio corrected astuv
|
|
16
|
+
- sgluv: Aspect-ratio corrected agluv
|
|
17
|
+
|
|
18
|
+
The Top of the screen is always 1, the bottom is 0 or 1 (stuv/gluv)
|
|
19
|
+
|
|
20
|
+
Or use the iCamera.gluv, iCamera.stuv for a Z=1 plane-projected 2D uv :)
|
|
21
|
+
|
|
22
|
+
The basis are (Y up), (Z forward), (X right), so (Left-Handed Y up)
|
|
23
|
+
|
|
24
|
+
- All the Camera Math is already done for 2D, 3D, VR and 360°
|
|
25
|
+
- Just use iCamera.origin and iCamera.target for Ray Marching
|
|
26
|
+
- It works on any "UP" vector in Spherical mode. Quaternion math for the win!
|
|
27
|
+
- Native field of view, dolly zoom parameters
|
|
28
|
+
|
|
29
|
+
// Quality of Life
|
|
30
|
+
|
|
31
|
+
With the raw OpenGL bindings provided by ModernGL, the shader compilation
|
|
32
|
+
process is much smarter. It simply fixes a lot of your pain and frustration
|
|
33
|
+
on ShaderToy, and adds a lot of premium features:
|
|
34
|
+
|
|
35
|
+
- Inter-operability between types like float and int:
|
|
36
|
+
- No more `cannot convert from 'const int' to 'highp float'` and similar!
|
|
37
|
+
- Smooth animations everywhere with a Dynamics system
|
|
38
|
+
- Native Fractional Super Sampling Anti Aliasing for first class quality
|
|
39
|
+
- Live-reloadable shaders on Path mode, just save the .{frag,glsl,vertex} shader
|
|
40
|
+
- Fastest rendering times you'll ever see. Many years of trickery and optimizations
|
|
41
|
+
|
|
42
|
+
// Expansible
|
|
43
|
+
|
|
44
|
+
There's no amount and limit of textures channels you can use, defined
|
|
45
|
+
on the Scene's Python file. For audio reactiveness, the Spectrogram
|
|
46
|
+
math is already there, converting to a log2(y) scale for you.
|
|
47
|
+
|
|
48
|
+
- Waveforms are already chunked and reduced at your parameters will
|
|
49
|
+
- Video as textures are also available, 4k60 fps fluent playback
|
|
50
|
+
- Low memory usage, progressively reads the Audio File channels or Real Time mode
|
|
51
|
+
- Piano Roll as a texture support. Check out Pianola project for a full example!
|
|
52
|
+
|
|
53
|
+
// Buffers and Layers
|
|
54
|
+
|
|
55
|
+
Simply set `texture.layers = L` and `texture.temporal = T` to
|
|
56
|
+
create a matrix of LxT 'rolling' textures
|
|
57
|
+
|
|
58
|
+
Access them by the name of iNameTxL, iName0x* is the current frame and its layers,
|
|
59
|
+
iName1x2 is the last frame's layer 2, and so on. Layers starts at 0 and ends in T
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
void main() {
|
|
63
|
+
vec3 col = 0.5 + 0.5*cos(iTime + stuv.xyx + vec3(0, 2, 4));
|
|
64
|
+
fragColor = vec4(col, 1.0);
|
|
65
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// (c) MIT, Tremeschin, I Hate This Code
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Not proud of this shader :v
|
|
6
|
+
void main() {
|
|
7
|
+
vec2 uv = iCamera.gluv;
|
|
8
|
+
vec3 space = vec3(1, 11, 26) / 255;
|
|
9
|
+
|
|
10
|
+
if (iCamera.out_of_bounds) {
|
|
11
|
+
fragColor.rgb = space;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Draw background
|
|
16
|
+
vec2 background_uv = zoom(gluv2stuv(uv), 0.95 + 0.01*sin(iTime) - 0.02*iAudioVolume - 0.03, vec2(0.5));
|
|
17
|
+
background_uv += 0.005 * vec2(cos(iTime*3.25135), sin(iTime*1.153469));
|
|
18
|
+
fragColor = stexture(background, background_uv);
|
|
19
|
+
|
|
20
|
+
/* Blur background on audio volume */ {
|
|
21
|
+
float intensity = 0.01*clamp(pow(iAudioVolume, 2.5), 0, 0.3);
|
|
22
|
+
float quality = 10;
|
|
23
|
+
float directions = 8;
|
|
24
|
+
vec4 color = fragColor;
|
|
25
|
+
for (float angle=0; angle<TAU; angle+=TAU/directions) {
|
|
26
|
+
for (float walk=1.0/quality; walk<=1.001; walk+=1.0/quality) {
|
|
27
|
+
vec2 displacement = vec2(cos(angle), sin(angle)) * walk * intensity;
|
|
28
|
+
color += stexture(background, background_uv + displacement);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
fragColor = color / (quality*directions);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Blink on snare/kick
|
|
35
|
+
fragColor *= 1 + 5*iAudioSTD*pow(clamp(length(agluv) - 0.3, 0, 1), 6);
|
|
36
|
+
|
|
37
|
+
// Music bars coordinates
|
|
38
|
+
vec2 music_uv = rotate2d(-PI/2) * uv;
|
|
39
|
+
music_uv *= 1 - 0.4 * pow(abs(iAudioVolume), 0.5);
|
|
40
|
+
float radius = 0.17;
|
|
41
|
+
|
|
42
|
+
// Get spectrogram bar volumes
|
|
43
|
+
float circle = abs(atan1n(music_uv));
|
|
44
|
+
vec2 freq = sqrt(texture(iSpectrogram, vec2(0, circle)).xy / 1000);
|
|
45
|
+
freq *= 0.05 + 3*smoothstep(0, 2, circle);
|
|
46
|
+
|
|
47
|
+
// Music bars
|
|
48
|
+
if (length(music_uv) < radius) {
|
|
49
|
+
vec2 logo_uv = (rotate2d(0.3*sin(3*iAudioVolumeIntegral + iTime/2)) * music_uv / (1.3*radius));
|
|
50
|
+
logo_uv *= 1 - 0.02*pow(abs(iAudioVolume), 0.1);
|
|
51
|
+
fragColor = gtexture(logo, logo_uv * rotate2d(-PI/2));
|
|
52
|
+
} else {
|
|
53
|
+
float bar = (music_uv.y < 0) ? freq.x : freq.y;
|
|
54
|
+
float r = radius + 0.5*bar;
|
|
55
|
+
|
|
56
|
+
if (length(music_uv) < r) {
|
|
57
|
+
fragColor.rgb = mix(fragColor.rgb, vec3(1), smoothstep(0, 1, 0.5 + bar));
|
|
58
|
+
} else {
|
|
59
|
+
fragColor.rgb *= pow((length(music_uv) - r) * 0.5, 0.05);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fragColor.rgb = mix(fragColor.rgb, space, smoothstep(0, 1, length(uv)/20));
|
|
64
|
+
|
|
65
|
+
// Vignette
|
|
66
|
+
vec2 vig = astuv * (1 - astuv.yx);
|
|
67
|
+
fragColor.rgb *= pow(vig.x*vig.y * 20, 0.1 + 0.15*iAudioVolume);
|
|
68
|
+
fragColor.a = 1;
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// Waveform on top and bottom
|
|
72
|
+
vec2 wave = 0.2*texture(iWaveform, vec2(astuv.x, 0)).rg;
|
|
73
|
+
if (1 - gluv.y < wave.x) {fragColor *= 0.8;}
|
|
74
|
+
if (1 + gluv.y < wave.y) {fragColor *= 0.8;}
|
|
75
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// (c) MIT, Tremeschin
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
void main() {
|
|
6
|
+
vec2 wave = texture(iWaveform, vec2(astuv.x, 0)).rg;
|
|
7
|
+
fragColor = vec4(vec3(0.2), 1);
|
|
8
|
+
|
|
9
|
+
if (abs(gluv.y) < wave.x) {
|
|
10
|
+
fragColor.r = 1;
|
|
11
|
+
}
|
|
12
|
+
if (abs(gluv.y) < wave.y) {
|
|
13
|
+
fragColor.g = 1;
|
|
14
|
+
}
|
|
15
|
+
if (abs(gluv.y) < (wave.x + wave.y)/2) {
|
|
16
|
+
fragColor.b = 1;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// A basic cool shader that draws a grid and a ring
|
|
2
|
+
// Help: I can't code cool shaders :(
|
|
3
|
+
|
|
4
|
+
// A Checkerboard grid with `grid` blocks vertically
|
|
5
|
+
vec3 grid_layer(vec2 uv, float grid) {
|
|
6
|
+
|
|
7
|
+
// Get the grid block color
|
|
8
|
+
if (mod(floor(uv.x * grid/2) + floor(uv.y * grid/2), 2.0) > 0.5) {
|
|
9
|
+
return vec3(0.22);
|
|
10
|
+
} else {
|
|
11
|
+
return vec3(0.2);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// A Varying-hue ring that spins
|
|
16
|
+
vec4 ring_layer(vec2 uv) {
|
|
17
|
+
|
|
18
|
+
// Angle varying in time
|
|
19
|
+
float angle = atan2(uv.y, uv.x) + iTime;
|
|
20
|
+
|
|
21
|
+
// Fill the whole Hue range
|
|
22
|
+
vec4 color = hsv2rgb(vec4(angle, 1.0, 1, 1));
|
|
23
|
+
|
|
24
|
+
// Ring parameters
|
|
25
|
+
float d = length(uv);
|
|
26
|
+
float r = 0.5;
|
|
27
|
+
|
|
28
|
+
// Outside the ring
|
|
29
|
+
if (d > r) {
|
|
30
|
+
color = color * pow(r/d, 15.0);
|
|
31
|
+
} else {
|
|
32
|
+
color = color * pow(d/r, 15.0);
|
|
33
|
+
color.rgb += vec3(0.3);
|
|
34
|
+
color.a = 0.2;
|
|
35
|
+
|
|
36
|
+
// Draw a "Simon Says" axis
|
|
37
|
+
if (uv.x < 0) {color.r += 0.3;}
|
|
38
|
+
if (uv.y < 0) {color.g += 0.3;}
|
|
39
|
+
if (uv.x > 0 && uv.y > 0) {
|
|
40
|
+
color.b += 0.3;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Cool transparency
|
|
44
|
+
color.a = pow(length(uv/r), 2);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return color;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ------------------------------------------------------------------------------------------------|
|
|
51
|
+
|
|
52
|
+
void main() {
|
|
53
|
+
vec2 uv = iCamera.gluv;
|
|
54
|
+
|
|
55
|
+
if (iCamera.out_of_bounds) {
|
|
56
|
+
float theta = angle(iCamera.UP, iCamera.ray);
|
|
57
|
+
fragColor.rgb = mix(vec3(0, 0, 0.129), vec3(0.1), pow(abs(theta)/PI, 2.0));
|
|
58
|
+
fragColor.a = 1.0;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fragColor.rgb = grid_layer(uv, 8);
|
|
63
|
+
fragColor = alpha_composite(fragColor, ring_layer(uv));
|
|
64
|
+
fragColor.a = 1.0;
|
|
65
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// (c) MIT, Tremeschin
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
void main() {
|
|
6
|
+
fragColor.rgb = vec3(0);
|
|
7
|
+
|
|
8
|
+
// Loading icon options
|
|
9
|
+
float radius = 0.5;
|
|
10
|
+
float width = 15.0;
|
|
11
|
+
float glow = 2.0;
|
|
12
|
+
|
|
13
|
+
// Fixme: Should this be a uniform
|
|
14
|
+
float pixel = 1.0/min(iResolution.x, iResolution.y);
|
|
15
|
+
|
|
16
|
+
// Convert to pixel-space
|
|
17
|
+
width *= pixel;
|
|
18
|
+
glow *= pixel*2;
|
|
19
|
+
|
|
20
|
+
// Calculate Tail Size based on Angle
|
|
21
|
+
float angle = atan(gluv.y, gluv.x);
|
|
22
|
+
float tail = smoothstep(0.3, 1, fract((1.5*angle/PI) - iTime));
|
|
23
|
+
|
|
24
|
+
// Calculate
|
|
25
|
+
width = (width - pixel)*0.5*tail;
|
|
26
|
+
|
|
27
|
+
float ring = abs(length(gluv) - radius) - width;
|
|
28
|
+
|
|
29
|
+
// Get the final height of the effect
|
|
30
|
+
float height;
|
|
31
|
+
height += smoothstep(pixel, 0.0, ring) * tail;
|
|
32
|
+
height += smoothstep(glow*tail, 0.0, ring) * tail*0.5;
|
|
33
|
+
|
|
34
|
+
// Add loading ring
|
|
35
|
+
fragColor = hsv2rgb(vec4(angle-iTime, height, 1, 1)) * height;
|
|
36
|
+
|
|
37
|
+
// Dark theme
|
|
38
|
+
fragColor.rgb += vec3(0.15);
|
|
39
|
+
fragColor.a = 1.0;
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Missing texture shader. Definitely not inspired in Source Shader
|
|
2
|
+
|
|
3
|
+
void main() {
|
|
4
|
+
|
|
5
|
+
// Walk through the texture
|
|
6
|
+
vec2 uv = stuv + vec2(iTime) / 64.0;
|
|
7
|
+
|
|
8
|
+
// Vertical grid size
|
|
9
|
+
float size = 8.0;
|
|
10
|
+
|
|
11
|
+
// Create missing texture
|
|
12
|
+
for (int x = -5; x < 5; x++) {
|
|
13
|
+
for (int y = -5; y < 5; y++) {
|
|
14
|
+
vec2 block = floor(size * uv);
|
|
15
|
+
if (mod(block.x + block.y, 2.0) == 0.0) {
|
|
16
|
+
fragColor.rgb += vec3(1.0, 0.0, 1.0) / 25.0;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Lots of transparency to see other elements
|
|
22
|
+
fragColor.a = 0.2;
|
|
23
|
+
}
|