kgl实现的玻璃体流体发散动画效果
代码语言:html
所属分类:粒子
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Instancing Box & Curl Noise</title>
<style>
html,
body {
height: 100%;
}
body {
overflow: hidden;
margin: 0;
}
canvas {
width: 100%;
height: 100%;
}
</style>
</head>
<body translate="no">
<script type="x-shader/x-fragment" id="reset-velocity">
precision highp float;
void main () {
gl_FragColor = vec4(vec3(0.), 1.);
}
</script>
<script type="x-shader/x-fragment" id="reset-position">
precision highp float;
uniform vec2 size;
// https://github.com/mattdesl/glsl-random
highp float random(vec2 co) {
highp float a = 12.9898;
highp float b = 78.233;
highp float c = 43758.5453;
highp float dt = dot(co.xy, vec2(a, b));
highp float sn = mod(dt, 3.14);
return fract(sin(sn) * c);
}
void main () {
vec2 nPosition = gl_FragCoord.st / size * 2. - 1.;
vec4 position = vec4(
nPosition * size,
0.,
random(nPosition)
);
gl_FragColor = position;
}
</script>
<script type="x-shader/x-fragment" id="velocity">
precision highp float;
uniform vec2 size;
uniform sampler2D prevVelocityTexture;
uniform sampler2D prevPositionTexture;
//
// Description : Array and textureless GLSL 2D/3D/4D simplex
// noise functions.
// Author : .........完整代码请登录后点击上方下载按钮下载查看
















网友评论0