Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* sy2002's first shader toy experiment
- done on 23rd of March 2019
- inspired by the "GPU Technology Conference 2014.
- Shadertoy: Do You Know What a Fragment Shader Can Do?" presentation
- */
- void mainImage( out vec4 fragColor, in vec2 fragCoord )
- {
- // normalized pixel coordinates (from 0 to 1)
- vec2 uv = fragCoord.xy/iResolution.xy;
- // center screen
- vec2 p = uv - 0.5;
- // transform to polar coordinates (radius, angle)
- float r = length(p);
- float a = atan(p.x, p.y);
- // first row is frequency data (48Khz/4 in 512 texels, meaning 23 Hz per texel)
- float fft = texture(iChannel1, vec2(30.0/512.0, 0)).x;
- // get tunnel texture using polar coordinates and animate (time, bass of sound)
- vec3 tex = texture(iChannel0, vec2(1.0 / r + iTime, a + fft)).xyz;
- // darken the center of the tunnel
- vec3 c = tex.xyz * r * 2.0;
- // output to screen
- fragColor = vec4(c, 1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement