Thanks for your interest in contributing to Radiant! This guide covers everything you need to create and submit a new shader.
git clone https://github.com/nicebill/radiant.git
cd radiant
npm install
npm run devThe dev server runs at http://localhost:5174.
static/*.html — Standalone shader files (no build step)
src/lib/shaders.ts — Shader catalog (ALL entries)
src/lib/color-schemes.ts — 6 color scheme definitions
src/lib/inspiration-intros.ts — Poetic intros for inspiration pages
src/lib/inspiration-palettes.ts — Color palettes for inspiration pages
scripts/generate-previews.mjs — Preview sprite sheet generator
static/previews/*.webp — Generated preview sprites
Every shader is a single, self-contained HTML file in static/. No build step, no external dependencies. Follow all steps below — a shader isn't complete until each one is done.
Create static/your-shader-name.html with this structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Shader Name</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0a0a0a; }
canvas { display: block; width: 100vw; height: 100vh; }
.label {
position: fixed;
top: 20px;
left: 24px;
font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
font-size: 11px;
letter-spacing: 0.15em;
text-transform: uppercase;
color: rgba(200, 149, 108, 0.5);
z-index: 10;
pointer-events: none;
user-select: none;
}
</style>
</head>
<body>
<div class="label">Your Shader Name</div>
<canvas id="canvas"></canvas>
<script>
(function() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d'); // or use WebGL
var dpr = Math.min(window.devicePixelRatio || 1, 2); // cap at 2
var W, H;
var running = true;
function resize() {
W = window.innerWidth;
H = window.innerHeight;
canvas.width = W * dpr;
canvas.height = H * dpr;
canvas.style.width = W + 'px';
canvas.style.height = H + 'px';
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
}
window.addEventListener('resize', resize);
resize();
// ── Mouse/touch interaction ──
var mouse = { x: -9999, y: -9999, active: false };
window.addEventListener('mousemove', function(e) {
mouse.x = e.clientX;
mouse.y = e.clientY;
mouse.active = true;
});
window.addEventListener('mouseleave', function() {
mouse.active = false;
});
canvas.addEventListener('touchmove', function(e) {
e.preventDefault();
var t = e.touches[0];
mouse.x = t.clientX;
mouse.y = t.clientY;
mouse.active = true;
}, { passive: false });
canvas.addEventListener('touchend', function() {
mouse.active = false;
});
// ── Tunable parameters ──
var PARAM_A = 1.0;
var PARAM_B = 0.5;
// ── Animation loop ──
function draw() {
if (!running) { requestAnimationFrame(draw); return; }
// Your rendering code here
// Use mouse.x, mouse.y, mouse.active for interaction
requestAnimationFrame(draw);
}
ctx.fillStyle = '#0a0a0a';
ctx.fillRect(0, 0, W, H);
requestAnimationFrame(draw);
// ── Visibility pause ──
document.addEventListener('visibilitychange', function() {
running = !document.hidden;
});
// ── Parameter API ──
window.addEventListener('message', function(e) {
if (e.data && e.data.type === 'param') {
switch (e.data.name) {
case 'PARAM_A': PARAM_A = e.data.value; break;
case 'PARAM_B': PARAM_B = e.data.value; break;
}
}
});
})();
</script>
</body>
</html>Key requirements:
- Background: Always
#0a0a0a - Label: Fixed
.labeldiv with the shader name, using the exact CSS above - DPR: Use
Math.min(window.devicePixelRatio || 1, 2)— cap at 2 for performance - IIFE: Wrap all JS in an immediately-invoked function expression
- No dependencies: Everything is self-contained. Inline any noise functions or utilities you need
Every shader must respond meaningfully to user input. The interaction should visibly affect the visual — not just cosmetically.
mousemove/touchmovefor cursor trackingmouseleave/touchendto reset state- Use
{ passive: false }on touch listeners and calle.preventDefault()
Common patterns: repel/attract particles, distort geometry, shift focal points, apply forces.
Expose 2 or more parameters controllable via postMessage. The gallery uses this API to let users adjust shaders in real time through sliders on the detail page.
window.addEventListener('message', function(e) {
if (e.data && e.data.type === 'param') {
switch (e.data.name) {
case 'SPEED': SPEED = e.data.value; break;
case 'SCALE': SCALE = e.data.value; break;
}
}
});Choose parameters that meaningfully change the visual character (speed, density, complexity, intensity) — not internal implementation details.
The gallery applies color schemes via CSS filter on the iframe containing your shader:
| Scheme | Filter |
|---|---|
| Amber (default) | none — native colors |
| Mono | grayscale(1) |
| Blue | hue-rotate(175deg) |
| Rose | hue-rotate(300deg) saturate(1.1) |
| Emerald | hue-rotate(90deg) saturate(1.2) |
| Arctic | hue-rotate(180deg) saturate(0.5) brightness(1.1) |
Since schemes use hue-rotate, design your native colors in warm/amber tones (golds, corals, ambers — around rgba(200, 149, 108, ...)). This ensures all six schemes produce distinct, appealing results.
If your shader looks best in a non-amber scheme, you can set defaultScheme in the catalog entry.
Pause the animation when the tab is hidden to save CPU:
document.addEventListener('visibilitychange', function() {
running = !document.hidden;
});Add an entry to the shaders array in src/lib/shaders.ts:
{
id: 'your-shader-name', // URL-safe kebab-case, matches filename
file: 'your-shader-name.html', // filename in static/
title: 'Your Shader Name', // display name
desc: 'One-line description.', // concise, evocative
tags: ['fill', 'noise'], // see tag list below
technique: 'canvas-2d', // 'canvas-2d' or 'webgl'
params: [
{ name: 'PARAM_A', label: 'Speed', min: 0.1, max: 2.0, step: 0.1, default: 1.0 },
{ name: 'PARAM_B', label: 'Density', min: 0.3, max: 2.0, step: 0.1, default: 1.0 }
]
}Available tags: fill, object, particles, physics, noise, organic, geometric
fill— covers the full canvasobject— renders a distinct focal elementparticles— uses a particle systemphysics— simulates physical forcesnoise— driven by noise functionsorganic— fluid, natural formsgeometric— hard edges, mathematical shapes
Optional fields:
inspiration: 'Celebrity Name'— if inspired by a public figuredefaultScheme: 'blue'— override the default color schemecredit: 'Inspired by ...'/creditUrl: '...'— attribution for techniquesheroConfig— custom layout params for the homepage hero
If your shader is inspired by a celebrity not already in the project, add entries to:
src/lib/inspiration-intros.ts — A 3-4 sentence poetic description of their artistic identity:
'your-celebrity-slug': 'Poetic description of their artistic identity, aesthetic sensibility, and associated color palette.',src/lib/inspiration-palettes.ts — Colors for the inspiration gallery page:
'your-celebrity-slug': {
primary: '#hexcolor', // card border tint
colors: ['#hex1', '#hex2'] // 2-4 hex colors for ambient glow
},Run the preview generator (make sure the dev server is not running on the same port):
node scripts/generate-previews.mjs --only=your-shader-nameThis creates static/previews/your-shader-name.webp — a vertical sprite sheet with 6 frames (one per color scheme) used for gallery card thumbnails.
Before submitting:
- Opens correctly at
http://localhost:5174/shader/your-shader-name - All parameter sliders work on the detail page
- Mouse interaction is visible and meaningful
- Touch interaction works on mobile
- Runs at 60fps on a normal laptop (check DevTools Performance tab)
- Color scheme switching produces good results across all 6 schemes
- Preview sprite shows correctly in the gallery grid
-
visibilitychangepauses the animation when the tab is hidden - No console errors or warnings
60fps is non-negotiable. If a technique can't hit 60fps on a normal laptop, use a different technique.
- Cap DPR at 2 — high-DPI screens don't need 3x rendering
- Minimize allocations in the animation loop
- Use
requestAnimationFrame, neversetInterval - For WebGL: keep shader complexity reasonable, minimize draw calls
- For Canvas 2D: batch operations, avoid excessive path recreation
- Shaders should be beautiful, mesmerizing, and reusable — designed to drop into any website as a background, hero section, or design asset
- One stunning shader beats five mediocre ones
- Every shader should have a clear visual identity
Shaders are designed to be embedded anywhere. They should:
- Work at any aspect ratio
- Handle window resize gracefully
- Look good without interaction (interaction enhances, doesn't define)
- Have no hard-coded dimensions
Canvas 2D (technique: 'canvas-2d'): Good for particle systems, 2D geometry, and effects that benefit from immediate-mode drawing. Easier to work with for most contributors.
WebGL (technique: 'webgl'): Better for fragment shader effects (noise, fluid, raymarching), GPU-accelerated rendering, and effects that need per-pixel computation. Higher performance ceiling but more complex.
Choose the technique that best serves your visual. If you're unsure, Canvas 2D is a safe default.
- Fork the repo and create a branch:
git checkout -b shader/your-shader-name - Follow all steps above
- Open a PR with:
- A brief description of the visual concept
- A screenshot or screen recording
- Performance notes (technique used, any known limitations)
We'll review for visual quality, performance, code quality, and interaction design.
- Use
varin shader HTML files (they're standalone, not transpiled) - Wrap everything in an IIFE
- Keep code readable — comment non-obvious math or algorithms
- Inline any external utilities (noise functions, easing, etc.)
- No external CDN links or dependencies
Radiant is MIT licensed. By contributing, you agree that your contributions will be licensed under the same terms.