three+webgl实现文字悬浮拖拽水滴效果代码
代码语言:html
所属分类:其他
代码描述:three+webgl实现文字悬浮拖拽水滴效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body { margin: 0; overflow: hidden; position: fixed;}
canvas { width: 100%; height: 100% }
</style>
</head>
<body>
<!-- partial:index.partial.html -->
<script id="vertexShader" type="x-shader/x-vertex">
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
</script>
<script id="fragmentShader" type="x-shader/x-fragment">
varying vec2 vUv;
uniform sampler2D texture;
uniform sampler2D mask;
uniform sampler2D blur;
uniform float scale;
uniform float frequency;
uniform float amplitude;
uniform float speed;
uniform sampler2D uDistortionTexture;
uniform float time;
uniform float uDistortionFactor; // Factor used to control severity of the effect
uniform float uRiseFactor; // Factor used to control how fast air rises
void main() {
vec2 uv = vUv;
vec4 mask = texture2D(mask, uv);
vec4 blur = texture2D(blur, uv);
vec2 scaleCenter = vec2(0.5, 0.5);
vec2 distMapUV = uv;
// distMapUV.x -= time / 14.0;//* uRiseFactor;
distMapUV.y -= time / 20.0;//* uRiseFactor;
vec4 distMap = texture2D(uDistortionTexture, distMapUV);
vec2 distPositionOffset = distMap.xy - vec2(0.1, 0.1);
distPositionOffset -= vec2(0.25, 0.25);
distPositionOffset.y *= 1.5;
distPositionOffset.x *= -1.0;
distPositionOffset *= 0.005 * (mask.a * 26.0);
// distPositionOffset *= uDistortionFactor * 6.0 + (mask.a * 0.15);
// distPositionOffset *= (mask.a) * (0.05 * 16.0);//uDistortionFactor * 16.0 + (mask.a * 0.55);
vec2 distortedTextureCoordinate = uv.xy - vec2(0.0, 0.0) + distPositionOffset;
vec4 final = texture2D(texture, (distortedTextureCoordinate - scaleCenter) * scale + scaleCenter );
gl_FragColor = final;
}
</script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.84.js&.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0