js实现材质球在槽中流动动画背景效果代码

代码语言:html

所属分类:背景

代码描述:js实现材质球在槽中流动动画背景效果代码

代码标签: 槽中 流动 动画 背景 效果

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

<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  
  
  
<style>
html {
  height: 100%;
}
img {
  display: none;
}
body {
  background: #000;
  overflow: hidden;
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  text-align: center;
}

canvas {
  height: 100%;
  width: 100%;
  margin: auto;
}
</style>


</head>

<body>
  <!-- VertexShader code here -->
<script id="vertexShader" type="x-shader/x-vertex">#version 300 es
precision highp float;
in vec4 vPosition;
void main() {
	gl_Position = vPosition;
}
</script>
<!-- FragmentShader code here -->
<script id="fragmentShader" type="x-shader/x-fragment">#version 300 es
precision highp float;
out vec4 fragColor;
  
uniform vec4 mouse;
uniform vec2 resolution;
uniform float time;
#define R          resolution
#define M          mouse
#define T          time
#define PI         3.14159265359
#define PI2        6.28318530718
#define SQ3        1.732

mat2 rot(float a)
{
    return mat2(cos(a),sin(a),-sin(a),cos(a));
}

float hash21(vec2 p)
{
    return fract(sin(dot(p, vec2(27.609, 57.583)))*43758.5453);
}

vec3 hue(float t)
{ 
    vec3 d = vec3(0.725,0.153,0.153);
    return .55 + .45*cos(PI2*t*(vec3(.85,.97,.98)*d)); 
}

vec4 hexGrid(vec2 uv, float scale)
{
    uv*=scale;
    const vec2 s = vec2(SQ3, 1.);
    vec4 hC = floor(vec4(uv, uv - vec2(1, .5))/s.xyxy) + .5;
    vec4 h4 = vec4(uv - hC.xy*s, uv - (hC.zw + .5)*s);
    return dot(h4.xy, h4.xy) < dot(h4.zw, h4.zw) ? vec4(h4.xy, hC.xy) : vec4(h4.zw, hC.zw + .5);
}

void main( )
{
    vec3 C = vec3(0);
    v.........完整代码请登录后点击上方下载按钮下载查看

网友评论0