debug_audio.shader 803 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. shader_type canvas_item;
  2. render_mode blend_mix;
  3. uniform sampler2D iChannel0;
  4. void vertex() {
  5. }
  6. vec4 mi(vec2 uv)
  7. {
  8. const float bands = 30.0;
  9. const float segs = 40.0;
  10. vec2 p;
  11. p.x = floor(uv.x*bands)/bands;
  12. p.y = floor(uv.y*segs)/segs;
  13. float fft = texture( iChannel0, vec2(p.x,0.0) ).x;
  14. vec3 color = mix(vec3(0.0, 2.0, 0.0), vec3(2.0, 0.0, 0.0), sqrt(uv.y));
  15. float mask = (p.y < fft) ? 1.0 : 0.1;
  16. vec2 d = fract((uv - p) *vec2(bands, segs)) - 0.5;
  17. float led = (1.-smoothstep(0.35, 0.5, abs(d.x))) *
  18. (1.-smoothstep(0.35, 0.5, abs(d.y)));
  19. vec3 ledColor = led*color*mask;
  20. return vec4(ledColor, clamp(dot(ledColor*10.,vec3(1.)),0.,3.)/3.);
  21. }
  22. void fragment() {
  23. vec2 tuv=UV;
  24. vec4 col=mi(tuv);
  25. COLOR = vec4(col.rgb,col.a);
  26. }