🌐 Live Demo: [http://liquid-glass.liziyang.design]
A WebGL liquid glass refraction effect project based on Vue3 + Vite.
- Vue 3 - Modern frontend framework
- Vite - Fast build tool
- WebGL2 - Hardware-accelerated graphics rendering
- GLSL ES 3.0 - Shader language
- SDF (Signed Distance Field) - Geometric shape definition
npm installnpm run devVisit http://localhost:3000 to see the effect
npm run buildnpm run previewUses mathematical functions to define geometric shapes, more efficient than traditional polygon rendering:
float sdCircle(vec2 uv, float r) {
return length(uv) - r;
}Simulates light refraction through transparent media based on physical optics principles:
vec2 offset = mix(vec2(0), normalize(st)/sd, length(st));Implements complete shadow casting including distance attenuation and soft edges.
- Chrome 56+
- Firefox 51+
- Safari 15+
- Edge 79+
Requires modern browsers with WebGL2 support.
- Shader code has been optimized to avoid expensive calculations
- Uses VAO (Vertex Array Object) to reduce state switching
- Implements high DPI screen support
MIT License
Issues and Pull Requests are welcome!
🌐 在线演示: http://liquid-glass.liziyang.design
一个基于 Vue3 + Vite 的 WebGL 液体玻璃折射特效项目。
- 🌟 实时折射特效 - 使用 WebGL2 和 SDF 技术实现的液体玻璃效果
- Vue 3 - 现代前端框架
- Vite - 快速构建工具
- WebGL2 - 硬件加速图形渲染
- GLSL ES 3.0 - 着色器语言
- SDF (Signed Distance Field) - 几何形状定义
npm installnpm run dev访问 http://localhost:3000 查看效果
npm run buildnpm run preview使用数学函数定义几何形状,比传统多边形渲染更高效:
float sdCircle(vec2 uv, float r) {
return length(uv) - r;
}基于物理光学原理模拟光线通过透明介质的折射效果:
vec2 offset = mix(vec2(0), normalize(st)/sd, length(st));实现了完整的阴影投射,包括距离衰减和柔和边缘。
- Chrome 56+
- Firefox 51+
- Safari 15+
- Edge 79+
需要支持 WebGL2 的现代浏览器。
- 着色器代码已经过优化,避免了昂贵的计算
- 使用 VAO (Vertex Array Object) 减少状态切换
- 实现了高 DPI 屏幕支持
MIT License
欢迎提交 Issue 和 Pull Request!