three实现canvas液态流动动画效果代码
代码语言:html
所属分类:动画
代码描述:three实现canvas液态流动动画效果代码
下面为部分代码预览,完整代码请点击下载或在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; float t = (uTime * .2) + length(uv-.5); uvRi.........完整代码请登录后点击上方下载按钮下载查看
网友评论0