three+gsap+webgl实现炫酷流体液体彩色流动动画效果代码

代码语言:html

所属分类:动画

代码描述:three+gsap +webgl实现炫酷流体液体彩色流动动画效果代码

代码标签: three gsap webgl 炫酷 流体 液体 彩色 流动 动画

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

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

<head>

  <meta charset="UTF-8">
  

  
<style>
*{ margin: 0px;}
</style>




</head>

<body >
  <div id="shader"></div>
<script id="vertex" type="x-shader/x-vertex">
  varying vec2 vUv;
	void main() { gl_Position = vec4(position, 1.0);
               vUv = uv;
              }
</script>



<script id="fragment" type="x-shader/x-fragment">
precision highp float;

uniform vec2 u_resolution;
uniform float uTime;
  uniform float u_number;
  varying vec2 vUv;
  uniform vec2 uMouse;
  

 
const float PI = 3.1415926535897932384626433832795;
const float TAU = PI * 2.;
  
uniform float u_progress;

void coswarp(inout vec3 trip, float warpsScale ){

    trip.xyz += warpsScale * .1 * sin(3. * trip.yzx + (uTime * .15));
    trip.xyz += warpsScale * .05 * sin(11. * trip.yzx + (uTime * .15));
    trip.xyz += warpsScale * .025 * sin(17. * trip.yzx + (uTime * .15));
    
  }  

  void uvRipple(inout vec2 uv, float intensity){

	vec2 p = uv -.5;


    float cLength=length(p);

     uv= uv +(p/cLength)*cos(cLength*15.0-uTime*.5)*intensity;

} 
  
void main() {
	vec2 uv = (gl_FragCoord.xy - u_resolution * .5) / u_resolution.yy + 0.5;
  
  //uv = vUv;
  
 
 
float t = (uTime * .4) + length(uv-.5);
  
   uv.x += sin(t);
  uv.y+= cos(t);
  
 vec3 color = vec3(uv.x, uv.y, 1.);
  coswarp(color, 2.);
  coswarp(color, 2.);
  coswarp(color, 2.);
 
  
  vec3 color2 = color;
  vec2 uv2 = uv;
  uv = fract(vec2(uv.x * (3. + cos(t)) * color.r, uv.y * (2. + sin(t)) * color.g));
  
  color = vec3(uv.x, uv.y, 1.);
  
  color = vec3(step(color.r, .8), step(color.r, .7), step(color.r, .6));
  
  

  
  
color = mix(color, 1.-color, step(length(uv), color2.b));
  
  color = mix(color, color2, step(length(uv-.5),.5));
  
   color = mix(color, 1.-color, step(length(uv2-.5),.6));
  
  
    gl_FragColor = vec4(vec3(color.r, color.g, color.b), 1.);
  
  
	

}
</script>

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.10.4.js"></script>
<script type="text/javascript.........完整代码请登录后点击上方下载按钮下载查看

网友评论0