-
Notifications
You must be signed in to change notification settings - Fork 7
/
Audio_Eclipse_MdsXWM.fs
110 lines (95 loc) · 2.3 KB
/
Audio_Eclipse_MdsXWM.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
/*
{
"IMPORTED" : [
],
"CATEGORIES" : [
"basic",
"reactive",
"audio",
"Automatically Converted"
],
"DESCRIPTION" : "Automatically converted from https:\/\/www.shadertoy.com\/view\/MdsXWM by airtight. Super basic audio-reactive HSL light ring. My first shader here :)",
"INPUTS" : [
{
"NAME":"volInput",
"TYPE": "float",
"DEFAULT": 0.5,
"MIN": 0.0,
"MAX": 1.5
},
{
"NAME": "dots",
"TYPE": "float",
"DEFAULT": 40.0,
"MIN": 0.0,
"MAX": 50.0
},
{
"NAME": "radius",
"TYPE": "float",
"DEFAULT": 0.25,
"MIN": 0.0,
"MAX": 1.0
},
{
"NAME": "brightness",
"TYPE": "float",
"DEFAULT": 0.02,
"MIN": 0.0,
"MAX": 0.2
},
{
"NAME": "rot_speed",
"TYPE": "float",
"DEFAULT": 10.0,
"MIN": 0.0,
"MAX": 100.0
},
{
"NAME": "black_inner",
"TYPE": "float",
"DEFAULT": 0.26,
"MIN": -0.1,
"MAX": 0.8
},{
"NAME": "black_smoth",
"TYPE": "float",
"DEFAULT": 0.05,
"MIN": 0.0,
"MAX": 0.1
}
]
}
*/
//const float dots = 40.; //number of lights
//const float radius = .25; //radius of light ring
//const float brightness = 0.02;
//convert HSV to RGB
vec3 hsv2rgb(vec3 c){
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main(){
vec2 p = (gl_FragCoord.xy-.5*RENDERSIZE.xy)/min(RENDERSIZE.x,RENDERSIZE.y);
vec3 c=vec3(0,0,0.1); //background color
for(float i=0.;i<dots; i++){
//read frequency for this dot from audio input channel
//based on its index in the circle
float vol = volInput;//IMG_NORM_PIXEL(AudioWaveformImage,mod(vec2(i/dots, 0.0),1.0)).x;
float b = vol * brightness;
//get location of dot
float x = radius*cos(2.*3.14*float(i)/dots);
float y = radius*sin(2.*3.14*float(i)/dots);
vec2 o = vec2(x,y);
//get color of dot based on its index in the
//circle + time to rotate colors
vec3 dotCol = hsv2rgb(vec3((i + TIME*rot_speed)/dots,1.,1.0));
//get brightness of this pixel based on distance to dot
c += b/(length(p-o))*dotCol;
}
//black circle overlay
float dist = distance(p , vec2(0));
c = c * smoothstep(black_inner, black_inner+black_smoth, dist);
gl_FragColor = vec4(c,1);
}