webgl+canvas实现GLSL 着色器振荡梯度动画效果代码
代码语言:html
所属分类:动画
代码描述:webgl+canvas实现GLSL 着色器振荡梯度动画效果代码
代码标签: webgl canvas GLSL 着色器 振荡 梯度 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/reset.min.css">
<style>
html, body {
width: 100%; height: 100%;
overflow: hidden;
}
canvas {
display: block;
width: 100vw; height: 100vh;
background: #000;
}
</style>
</head>
<body translate="no">
<canvas id="c"></canvas>
<!-- Vertex Shader -->
<script id="vertex-shader" type="x-shader/x-vertex">
attribute vec2 a_position;
void main() {
gl_Position = vec4(a_position, 0, 1);
}
</script>
<!-- Fragment Shader -->
<script id="fragment-shader" type="x-shader/x-fragment">
precision mediump float;
uniform vec3 iResolution;
uniform float iTime;
uniform int iFrame;
uniform sampler2D iChannel0;
float adjustValue(float value, float progress) {
float offset = 0.7;
return tan(value * (1.0 - progress) + offset * progress);
}
float whiteNoise(vec2 uv) {
float x = (uv.x + 0.1) * (uv.y + 0.1);
return fract(sin(x) * 43758.5453123);
}
float fBm(vec2 uv) {
float sum = 0.0;
float scale = 1.0;
float amplitude = 1.0;
for (int i = 0; i < 4; ++i) {
sum += whiteNoise(uv * scale) * amplitude;
scale *= 2.0;
amplitude *= 0.5;
}
return sum;
}
void main()
{
float grainTileSize = 5.0; // the bigger the number, the finer the grain
float grainTileOpacity = 0.15; // the opacity of the grain tile
float fre.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0