Files
pbakaus_impeccable/public/js/effects/hero-shader.js
T
Paul BakausandClaude Opus 4.5 97c83fc51a Add animated mesh gradient hero with overlay content
- Add @paper-design/shaders for WebGL mesh gradient effect
- Create hero-shader.js with liquid ink gradient (grayscale palette)
- Add overlay content: title, tagline, and CTA on shader
- Update hero section structure and styling
- Fix accessibility: gallery dot buttons, toggle ARIA attributes
- Fix undefined --color-terracotta CSS variable
- Update distribution structure for Codex/Cursor skills

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 17:46:49 -08:00

58 lines
1.3 KiB
JavaScript

import {
ShaderMount,
meshGradientFragmentShader,
getShaderColorFromString,
ShaderFitOptions
} from '@paper-design/shaders';
export function initHeroShader() {
const container = document.getElementById('hero-shader');
if (!container) return;
// Respect user's motion preferences
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
container.style.display = 'none';
return;
}
// Liquid ink mesh gradient
const shader = new ShaderMount(
container,
meshGradientFragmentShader,
{
// Colors - liquid ink effect (grayscale tones for editorial look)
u_colors: [
getShaderColorFromString('#ffffff'),
getShaderColorFromString('#e8e4df'),
getShaderColorFromString('#b5b0a8'),
getShaderColorFromString('#1a1a1a'),
],
u_colorsCount: 4,
// Effect parameters
u_distortion: 1.0,
u_swirl: 0.2,
u_grainMixer: 0,
u_grainOverlay: 0,
// Sizing uniforms (required by mesh gradient)
u_fit: ShaderFitOptions.cover,
u_scale: 1,
u_rotation: 0,
u_offsetX: 0,
u_offsetY: 0,
u_originX: 0.5,
u_originY: 0.5,
u_worldWidth: 0,
u_worldHeight: 0,
},
undefined,
1.0 // speed
);
// Cleanup
window.addEventListener('beforeunload', () => {
shader.dispose();
});
}