webgl+canvas实现shader线条波动炫酷动画效果代码
代码语言:html
所属分类:动画
代码描述:webgl+canvas实现shader线条波动炫酷动画效果代码
代码标签: webgl canvas shader 线条 波动 炫酷 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> body, html { margin: 0; padding: 0; overflow: hidden; width: 100%; height: 100%; } #canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; } </style> </head> <body class="bg-black"> <canvas id="canvas" class="w-full h-full"></canvas> <script> // Initialize WebGL const canvas = document.getElementById('canvas'); const gl = canvas.getContext('webgl'); if (!gl) { alert('WebGL not supported in your browser'); } // Vertex shader program const vsSource = ` attribute vec4 aVertexPosition; void main() { gl_Position = aVertexPosition; } `; // Fragment shader program (from your provided shader code) const fsSource = ` precision highp float; uniform vec2 iResolution; uniform float iTime; const float overallSpeed = 0.2; const float gridSmoothWidth = 0.015; const float axisWidth = 0.05; const float majorLineWidth = 0.025; const float minorLineWidth = 0.0125; const float majorLineFrequency = 5.0; const float minorLineFrequen.........完整代码请登录后点击上方下载按钮下载查看
网友评论0