Advertisement
Guest User

sy2002's Tunnel Experiment #1 on ShaderToy

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