Ask your agent
What it does
This skill guides production WebGL interfaces with procedural GLSL materials, sub-250ms motion, synchronized inertial scrolling, and safe Three.js cleanup. It also checks layout stability, GPU usage, accessibility, reduced motion, and runtime errors before shipping.
SKILL.md
---
name: tactile-webgl-architecture
description: Production-grade Swiss tactile interface engineering, procedural Three.js/GLSL shaders (Fresnel titanium rim lighting, optical chromatic dispersion), sub-250ms spring physics, Lenis inertial scroll sync, and zero-leak WebGL memory disposal for React, Next.js, and modern web frontends. Use whenever building high-craft landing pages, interactive 3D showcases, or auditing frontends to eliminate generic AI aesthetics.
---
# Tactile WebGL & Anti-Slop Interface Architecture
> Studio-grade visual materiality, procedural GLSL shaders, tactile spring physics, and strict GPU lifecycle engineering. Zero generic templates.
---
## 1. Visual Materiality & Anti-Slop Mandate
Match the target brand's physical DNA with disciplined restraint. Never force dark mode or neon aesthetics onto a brand that calls for paper, stone, or gallery white.
### Approved Material Substrates
- **Editorial Swiss White:** `#FAFAFA` paper canvas, `#111111` ink typography, `1px solid rgba(17, 17, 17, 0.10)` hairline rules, high-contrast typographic hierarchy.
- **Obsidian & Brushed Titanium:** `#050508` / `#0A0A0D` deep matte substrate, `#E5E5E7` titanium ink, `1px solid rgba(255, 255, 255, 0.08)` hairline dividers, subtle 35mm monochrome grain.
- **Architectural Warm Earth:** Warm limestone `#F4F1EA`, deep espresso ink `#1C1917`, muted terracotta accents, editorial serif display headlines.
### Banned Generic Patterns
- Generic purple/magenta neon gradients, glowing orbs, and over-blurred glassmorphism cards.
- Floating "Ask AI" chat bubbles, sparkle badges, and decorative fake typing loaders.
- Heavy unthrottled client JS animation bundles where native CSS transitions or GPU transforms suffice.
- Layout-shifting WebGL canvases (always mount WebGL on a fixed or explicitly sized container with `pointer-events: none` unless direct orbit interaction is intentional).
### Typography & Grid Discipline
- Fluid display scales using `clamp()` (e.g., `clamp(2.25rem, 5vw, 5.5rem)`) with tight optical tracking (`-0.03em`) and controlled line-height (`0.98–1.08`).
- Asymmetric Swiss grids with generous negative space and aligned metadata rails in monospace (`tabular-nums` for all live metrics and counters).
---
## 2. Procedural GLSL Shaders (Three.js / R3F)
Prefer lightweight procedural shaders over multi-megabyte environment HDRIs or baked video loops.
### A. Fresnel Brushed-Titanium Rim Shader
Produces crisp grazing-angle metallic reflectance on dark obsidian and sculptural geometry:
```glsl
// Vertex Shader
varying vec3 vNormal;
varying vec3 vViewPosition;
void main() {
vNormal = normalize(normalMatrix * normal);
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
vViewPosition = -mvPosition.xyz;
gl_Position = projectionMatrix * mvPosition;
}
```
```glsl
// Fragment Shader
uniform vec3 uBaseColor; // e.g. vec3(0.03, 0.03, 0.04)
uniform vec3 uRimColor; // e.g. vec3(0.84, 0.87, 0.90)
uniform float uPower; // e.g. 2.8
uniform float uIntensity; // e.g. 1.15
varying vec3 vNormal;
varying vec3 vViewPosition;
void main() {
vec3 normal = normalize(vNormal);
vec3 viewDir = normalize(vViewPosition);
float fresnel = 1.0 - max(dot(viewDir, normal), 0.0);
fresnel = pow(fresnel, uPower) * uIntensity;
vec3 finalColor = mix(uBaseColor, uRimColor, clamp(fresnel, 0.0, 1.0));
gl_FragColor = vec4(finalColor, 1.0);
}
```
### B. Optical 35mm Chromatic Dispersion Pass
Subtle perimeter lens dispersion (keep `uDistortion` between `0.004` and `0.012` — never cartoonish RGB split):
```glsl
uniform sampler2D tDiffuse;
uniform float uDistortion; // recommended: 0.006
varying vec2 vUv;
void main() {
vec2 dir = vUv - vec2(0.5);
float dist = length(dir);
vec2 uvR = vUv + dir * (dist * uDistortion);
vec2 uvG = vUv;
vec2 uvB = vUv - dir * (dist * uDistortion);
float r = texture2D(tDiffuse, uvR).r;
float g = texture2D(tDiffuse, uvG).g;
float b = texture2D(tDiffuse, uvB).b;
gl_FragColor = vec4(r, g, b, 1.0);
}
```
---
## 3. Tactile Physics & Motion Restraint
Interfaces must respond like precision physical hardware, never sluggish or bouncy.
### Micro-Interaction Curves
- **Max UI transition duration:** `<= 250ms`.
- **Deceleration spring curve:**
```css
.tactile-surface {
transition:
transform 220ms cubic-bezier(0.16, 1, 0.3, 1),
opacity 180ms ease,
border-color 180ms ease;
}
.tactile-surface:active {
transform: scale(0.98);
transition-duration: 40ms;
}
```
- **GPU-only properties:** Animate exclusively `transform`, `opacity`, and `clip-path`. Never animate `width`, `height`, `top`, `left`, or `box-shadow` on scroll.
### Lenis Inertial Scroll & Camera Sync
- Configure smooth inertia with restrained damping (`lerp: 0.1` or `duration: 1.15`).
- Read scroll progress inside the same `requestAnimationFrame` loop driving the Three.js scene to prevent scroll-vs-canvas frame tear.
- Respect reduced motion globally:
```ts
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
```
When enabled, disable Lenis smoothing, freeze ambient shader rotation, and swap reveals to instant opacity fades.
---
## 4. Zero-Leak WebGL Lifecycle Guard
Uncollected WebGL buffers, textures, and zombie contexts crash tabs on constrained laptops and mobile GPUs. Every mounted Three.js scene MUST enforce three invariants:
1. **DPR Cap:** `renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.5))` on mobile/high-DPI viewports.
2. **Off-Screen Pause:** Attach an `IntersectionObserver` to the canvas container and pause `requestAnimationFrame` whenever `entry.isIntersecting === false` or `document.hidden === true`.
3. **Complete Disposal on Unmount:** Execute recursive cleanup and verify `renderer.info.memory.geometries === 0` and `renderer.info.memory.textures === 0`:
```ts
import * as THREE from 'three';
function isDisposableTexture(val: unknown): val is THREE.Texture {
return Boolean(val && typeof val === 'object' && 'isTexture' in val);
}
export function disposeThreeScene(
scene: THREE.Scene | null,
renderer: THREE.WebGLRenderer | null,
forceContextLoss = false
): void {
if (scene) {
scene.traverse((node) => {
if (!(node instanceof THREE.Mesh)) return;
node.geometry?.dispose();
const materials = Array.isArray(node.material)
? node.material
: node.material
? [node.material]
: [];
for (const mat of materials) {
for (const value of Object.values(mat)) {
if (isDisposableTexture(value)) value.dispose();
}
if ('uniforms' in mat && mat.uniforms && typeof mat.uniforms === 'object') {
for (const uniform of Object.values(mat.uniforms as Record<string, { value?: unknown }>)) {
if (isDisposableTexture(uniform?.value)) uniform.value.dispose();
}
}
mat.dispose();
}
});
}
if (renderer) {
renderer.renderLists?.dispose();
renderer.dispose();
if (forceContextLoss) {
const gl = renderer.getContext();
gl?.getExtension('WEBGL_lose_context')?.loseContext();
}
}
}
```
---
## 5. Pre-Ship Verification Gate
Before delivering any interactive frontend or WebGL scene, verify every item:
- [ ] **Zero Layout Shift (CLS = 0):** Canvas container has explicit aspect ratio / dimensions before hydration; static CSS substrate fallback renders immediately if WebGL fails.
- [ ] **GPU Budget:** Canvas pauses off-screen via `IntersectionObserver` and `visibilitychange`; DPR clamped to `<= 1.5` on mobile.
- [ ] **Memory Safety:** Unmounting the view invokes `disposeThreeScene()` with zero leaked geometries or textures.
- [ ] **Motion Restraint:** All UI micro-interactions complete in `<= 250ms` and degrade cleanly under `prefers-reduced-motion: reduce`.
- [ ] **Accessibility (WCAG 2.2 AA):** Text contrast `>= 4.5:1`, interactive controls `>= 44x44px`, full keyboard focus-visible rings (`Tab` / `Enter` / `Escape`).
- [ ] **Zero Console Noise:** Zero runtime warnings, WebGL shader compile errors, or unhandled hydration mismatches.
---
Authored by **ASSEMBLAGE** — High-End Interactive Architecture & Sovereign AI Systems
https://point-of-assemblage.vercel.app
1 file
- SKILL.md8.1 KB