shader-doodle实现音乐声音可视化粒子变换效果

代码语言:html

所属分类:粒子

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
body {
  background: #000;
  font-size: 24px;
  color: #fff;
  font-family: 'Dosis', sans-serif;
  text-transform: uppercase;
}
shader-doodle {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 100vw;
}
.credit {
  z-index: 1;
  position: fixed;
  top: 8px;
  left: 8px;
}
.sd {
  z-index: 1;
  position: fixed;
  right: 8px;
  bottom: 8px;
}
.help {
  z-index: 1;
  position: fixed;
  left: 8px;
  bottom: 8px;
}
.credit, .sd, .help {
  mix-blend-mode: difference;
}
a:hover,
a:link,
a:visited,
a:active {
  color: inherit;
}
</style>

</head>
<body translate="no">

<shader-doodle>
<sd-audio src="http://repo.bfw.wiki/bfwrepo/sound/5e1528f1dca14.mp3" autoplay loop crossorigin="anonymous"></sd-audio>
<sd-node name="audioviz" prevbuffer>
<sd-audio src="./audio.mp3" autoplay loop></sd-audio>
<script type="x-shader/x-fragment">
      uniform sampler2D u_prevbuffer;
      uniform sampler2D u_audio0;

      float amplitude(sampler2D audio, float f) {
        return texture2D(audio, vec2(f, .25)).x;
      }

      float wave(sampler2D audio, float t) {
        return texture2D(audio, vec2(t, .75)).x;
      }

      void main() {
        vec2 uv = gl_FragCoord.xy / u_resolution.xy; 
        vec2 warped = (uv - ..........完整代码请登录后点击上方下载按钮下载查看

网友评论0