WebGL Chromatic Distortion
🟠 WebGLAn interactive, fluid screen-warp simulation featuring dynamic chromatic aberration. Watch red, green, and blue wave vectors split and refract in real-time as you move the cursor.
Responsive Horizontal Leaderboard
Slot ID: ca-pub-detail-below-preview
Interactive Settings
Medium Rectangle Block
Slot ID: ca-pub-detail-after-customization
Quick Copy Actions
Download File Packages
Keyboard Shortcuts
Responsive Horizontal Leaderboard
Slot ID: ca-pub-detail-before-related
More in WebGL
Loading Canvas Shader...
WebGL Aurora
A gorgeous, high-performance WebGL-powered Aurora Borealis simulation. Watch glowing ribbons of green and violet light wave gracefully across the deep cosmos.
Loading Canvas Shader...
Midnight JDM Street Race
A deeply motion-blurred late-night street race simulation. Glowing red and white headlights and taillights continuously warp past with responsive speed-boosting scroll wheel and immersive camera shake.
Loading Canvas Shader...
Retro Topographic Grid
A gorgeous 3D wireframe topographic landscape under a neon retro sun. Features a procedural Web Audio synthesizer playing an interactive, heavy-bass ambient beat that drives real-time landscape morphing, pulse lighting, and camera vibrations.
WebGL Chromatic Distortion - WebGL 3D GPU WebGL background for React & Tailwind
Integrate the WebGL Chromatic Distortion directly into your website. This asset is rendered using raw WebGL shader context. It is optimized for zero layout-shifts and runs with high-performance hardware-accelerated processing.
⚡ Performance Specifications
- Render Mode: WEBGL (WebGL 3D GPU)
- Fluidity: Locked at 60fps dynamic loop
- Bundle Footprint: Zero external NPM dependencies
- SEO Indexing status: 100% Crawlable static semantic HTML
🛠️ Integration Capabilities
Our templates expose inline design tokens like --color-1 and --color-2 for infinite color palettes. This template is designed to fit inside hero elements, full-screen landing pages, and interactive presentation cards.
Technical Code Reference & Syntaxes for Googlebot & Crawlers
The snippets below display the direct, unminified source code utilized for rendering this background.
HTML & Inline CSS Snippet (Vanilla)
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebGL Chromatic Distortion</title>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #09090b;
}
#canvas-webgl-distortion {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}
</style>
</head>
<body>
<canvas id="canvas-webgl-distortion"></canvas>
<script>
(function() {
const canvas = document.getElementById('canvas-webgl-distortion');
const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
if (!gl) return;
const vertices = new Float32Array([
-1, -1, 1, -1, -1, 1,
-1, 1, 1, -1, 1, 1
]);
const buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
function createShader(gl, type, source) {
const shader = gl.createShader(type);
gl.shaderSource(shader, source);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
console.error(gl.getShaderInfoLog(shader));
gl.deleteShader(shader);
return null;
}
return shader;
}
const vsSource = `
attribute vec2 position;
void main() {
gl_Position = vec4(position, 0.0, 1.0);
}
`;
const fsSource = `
precision mediump float;
uniform vec2 u_resolution;
uniform float u_time;
uniform vec2 u_mouse;
void main() {
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
vec2 p = (gl_FragCoord.xy - 0.5 * u_resolution.xy) / u_resolution.y;
vec2 mouse = (u_mouse - 0.5 * u_resolution.xy) / u_resolution.y;
float wave = sin(p.x * 4.0 + u_time) * 0.15 + cos(p.y * 3.0 - u_time * 1.2) * 0.15;
float distToMouse = length(p - mouse);
float mouseWarp = exp(-distToMouse * 5.0) * 0.12;
vec2 rOffset = vec2(wave * 0.05 + mouseWarp, 0.0);
vec2 gOffset = vec2(0.0, wave * 0.03 + mouseWarp);
vec2 bOffset = vec2(-wave * 0.04 - mouseWarp, -wave * 0.02);
float r = sin((p.x + rOffset.x) * 10.0 + u_time) * sin((p.y + rOffset.y) * 10.0 - u_time);
float g = sin((p.x + gOffset.x) * 10.0 + u_time) * sin((p.y + gOffset.y) * 10.0 - u_time);
float b = sin((p.x + bOffset.x) * 10.0 + u_time) * sin((p.y + bOffset.y) * 10.0 - u_time);
vec3 col = vec3(
smoothstep(0.1, 0.9, r * 0.5 + 0.5),
smoothstep(0.1, 0.9, g * 0.5 + 0.5),
smoothstep(0.1, 0.9, b * 0.5 + 0.5)
);
col = mix(col * vec3(0.5, 0.2, 0.9), vec3(0.02, 0.01, 0.06), 0.7);
gl_FragColor = vec4(col, 1.0);
}
`;
const vs = createShader(gl, gl.VERTEX_SHADER, vsSource);
const fs = createShader(gl, gl.FRAGMENT_SHADER, fsSource);
if (!vs || !fs) return;
const program = gl.createProgram();
gl.attachShader(program, vs);
gl.attachShader(program, fs);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return;
gl.useProgram(program);
const positionLoc = gl.getAttribLocation(program, 'position');
gl.enableVertexAttribArray(positionLoc);
gl.vertexAttribPointer(positionLoc, 2, gl.FLOAT, false, 0, 0);
const uResolution = gl.getUniformLocation(program, 'u_resolution');
const uTime = gl.getUniformLocation(program, 'u_time');
const uMouse = gl.getUniformLocation(program, 'u_mouse');
let mouseX = 0, mouseY = 0;
window.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = canvas.height - e.clientY;
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
if (canvas.width !== width || canvas.height !== height) {
canvas.width = width;
canvas.height = height;
gl.viewport(0, 0, width, height);
}
}
window.addEventListener('resize', resize);
resize();
let startTime = Date.now();
function render() {
let elapsed = (Date.now() - startTime) / 1000.0;
gl.uniform2f(uResolution, canvas.width, canvas.height);
gl.uniform1f(uTime, elapsed);
gl.uniform2f(uMouse, mouseX, mouseY);
gl.drawArrays(gl.TRIANGLES, 0, 6);
requestAnimationFrame(render);
}
requestAnimationFrame(render);
})();
</script>
</body>
</html>React Component Wrapper (TSX)
import React from 'react';
export default function WebGLChromaticDistortionBackground() {
return (
<div
style={{ width: '100%', height: '100%', position: 'relative', overflow: 'hidden' }}
>
<style dangerouslySetInnerHTML={{ __html: `
#canvas-webgl-distortion {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}
` }} />
{/* HTML Structure */}
<div
style={{ width: '100%', height: '100%' }}
dangerouslySetInnerHTML={{ __html: `
<canvas id="canvas-webgl-distortion"></canvas>
<script>
(function() {
const canvas = document.getElementById('canvas-webgl-distortion');
const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
if (!gl) return;
const vertices = new Float32Array([
-1, -1, 1, -1, -1, 1,
-1, 1, 1, -1, 1, 1
]);
const buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
function createShader(gl, type, source) {
const shader = gl.createShader(type);
gl.shaderSource(shader, source);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
console.error(gl.getShaderInfoLog(shader));
gl.deleteShader(shader);
return null;
}
return shader;
}
const vsSource = \`
attribute vec2 position;
void main() {
gl_Position = vec4(position, 0.0, 1.0);
}
\`;
const fsSource = \`
precision mediump float;
uniform vec2 u_resolution;
uniform float u_time;
uniform vec2 u_mouse;
void main() {
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
vec2 p = (gl_FragCoord.xy - 0.5 * u_resolution.xy) / u_resolution.y;
vec2 mouse = (u_mouse - 0.5 * u_resolution.xy) / u_resolution.y;
float wave = sin(p.x * 4.0 + u_time) * 0.15 + cos(p.y * 3.0 - u_time * 1.2) * 0.15;
float distToMouse = length(p - mouse);
float mouseWarp = exp(-distToMouse * 5.0) * 0.12;
vec2 rOffset = vec2(wave * 0.05 + mouseWarp, 0.0);
vec2 gOffset = vec2(0.0, wave * 0.03 + mouseWarp);
vec2 bOffset = vec2(-wave * 0.04 - mouseWarp, -wave * 0.02);
float r = sin((p.x + rOffset.x) * 10.0 + u_time) * sin((p.y + rOffset.y) * 10.0 - u_time);
float g = sin((p.x + gOffset.x) * 10.0 + u_time) * sin((p.y + gOffset.y) * 10.0 - u_time);
float b = sin((p.x + bOffset.x) * 10.0 + u_time) * sin((p.y + bOffset.y) * 10.0 - u_time);
vec3 col = vec3(
smoothstep(0.1, 0.9, r * 0.5 + 0.5),
smoothstep(0.1, 0.9, g * 0.5 + 0.5),
smoothstep(0.1, 0.9, b * 0.5 + 0.5)
);
col = mix(col * vec3(0.5, 0.2, 0.9), vec3(0.02, 0.01, 0.06), 0.7);
gl_FragColor = vec4(col, 1.0);
}
\`;
const vs = createShader(gl, gl.VERTEX_SHADER, vsSource);
const fs = createShader(gl, gl.FRAGMENT_SHADER, fsSource);
if (!vs || !fs) return;
const program = gl.createProgram();
gl.attachShader(program, vs);
gl.attachShader(program, fs);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return;
gl.useProgram(program);
const positionLoc = gl.getAttribLocation(program, 'position');
gl.enableVertexAttribArray(positionLoc);
gl.vertexAttribPointer(positionLoc, 2, gl.FLOAT, false, 0, 0);
const uResolution = gl.getUniformLocation(program, 'u_resolution');
const uTime = gl.getUniformLocation(program, 'u_time');
const uMouse = gl.getUniformLocation(program, 'u_mouse');
let mouseX = 0, mouseY = 0;
window.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = canvas.height - e.clientY;
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
if (canvas.width !== width || canvas.height !== height) {
canvas.width = width;
canvas.height = height;
gl.viewport(0, 0, width, height);
}
}
window.addEventListener('resize', resize);
resize();
let startTime = Date.now();
function render() {
let elapsed = (Date.now() - startTime) / 1000.0;
gl.uniform2f(uResolution, canvas.width, canvas.height);
gl.uniform1f(uTime, elapsed);
gl.uniform2f(uMouse, mouseX, mouseY);
gl.drawArrays(gl.TRIANGLES, 0, 6);
requestAnimationFrame(render);
}
requestAnimationFrame(render);
})();
</script>
` }}
/>
</div>
);
}Next.js App Router Component (use client)
'use client';
import React from 'react';
export default function WebGLChromaticDistortionBackground() {
return (
<div
className="w-full h-full relative overflow-hidden"
>
<style dangerouslySetInnerHTML={{ __html: `
#canvas-webgl-distortion {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}
` }} />
{/* HTML Structure */}
<div
className="w-full h-full"
dangerouslySetInnerHTML={{ __html: `
<canvas id="canvas-webgl-distortion"></canvas>
<script>
(function() {
const canvas = document.getElementById('canvas-webgl-distortion');
const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
if (!gl) return;
const vertices = new Float32Array([
-1, -1, 1, -1, -1, 1,
-1, 1, 1, -1, 1, 1
]);
const buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
function createShader(gl, type, source) {
const shader = gl.createShader(type);
gl.shaderSource(shader, source);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
console.error(gl.getShaderInfoLog(shader));
gl.deleteShader(shader);
return null;
}
return shader;
}
const vsSource = \`
attribute vec2 position;
void main() {
gl_Position = vec4(position, 0.0, 1.0);
}
\`;
const fsSource = \`
precision mediump float;
uniform vec2 u_resolution;
uniform float u_time;
uniform vec2 u_mouse;
void main() {
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
vec2 p = (gl_FragCoord.xy - 0.5 * u_resolution.xy) / u_resolution.y;
vec2 mouse = (u_mouse - 0.5 * u_resolution.xy) / u_resolution.y;
float wave = sin(p.x * 4.0 + u_time) * 0.15 + cos(p.y * 3.0 - u_time * 1.2) * 0.15;
float distToMouse = length(p - mouse);
float mouseWarp = exp(-distToMouse * 5.0) * 0.12;
vec2 rOffset = vec2(wave * 0.05 + mouseWarp, 0.0);
vec2 gOffset = vec2(0.0, wave * 0.03 + mouseWarp);
vec2 bOffset = vec2(-wave * 0.04 - mouseWarp, -wave * 0.02);
float r = sin((p.x + rOffset.x) * 10.0 + u_time) * sin((p.y + rOffset.y) * 10.0 - u_time);
float g = sin((p.x + gOffset.x) * 10.0 + u_time) * sin((p.y + gOffset.y) * 10.0 - u_time);
float b = sin((p.x + bOffset.x) * 10.0 + u_time) * sin((p.y + bOffset.y) * 10.0 - u_time);
vec3 col = vec3(
smoothstep(0.1, 0.9, r * 0.5 + 0.5),
smoothstep(0.1, 0.9, g * 0.5 + 0.5),
smoothstep(0.1, 0.9, b * 0.5 + 0.5)
);
col = mix(col * vec3(0.5, 0.2, 0.9), vec3(0.02, 0.01, 0.06), 0.7);
gl_FragColor = vec4(col, 1.0);
}
\`;
const vs = createShader(gl, gl.VERTEX_SHADER, vsSource);
const fs = createShader(gl, gl.FRAGMENT_SHADER, fsSource);
if (!vs || !fs) return;
const program = gl.createProgram();
gl.attachShader(program, vs);
gl.attachShader(program, fs);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return;
gl.useProgram(program);
const positionLoc = gl.getAttribLocation(program, 'position');
gl.enableVertexAttribArray(positionLoc);
gl.vertexAttribPointer(positionLoc, 2, gl.FLOAT, false, 0, 0);
const uResolution = gl.getUniformLocation(program, 'u_resolution');
const uTime = gl.getUniformLocation(program, 'u_time');
const uMouse = gl.getUniformLocation(program, 'u_mouse');
let mouseX = 0, mouseY = 0;
window.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = canvas.height - e.clientY;
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
if (canvas.width !== width || canvas.height !== height) {
canvas.width = width;
canvas.height = height;
gl.viewport(0, 0, width, height);
}
}
window.addEventListener('resize', resize);
resize();
let startTime = Date.now();
function render() {
let elapsed = (Date.now() - startTime) / 1000.0;
gl.uniform2f(uResolution, canvas.width, canvas.height);
gl.uniform1f(uTime, elapsed);
gl.uniform2f(uMouse, mouseX, mouseY);
gl.drawArrays(gl.TRIANGLES, 0, 6);
requestAnimationFrame(render);
}
requestAnimationFrame(render);
})();
</script>
` }}
/>
</div>
);
}Raw CSS Stylesheet Snippet
#canvas-webgl-distortion {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}