This directory contains modular, reusable shader effects for Three.js applications.
Noise generation with three algorithms:
- Value Noise - Classic gridded noise with smooth interpolation
- Simplex Noise - Ken Perlin's improved noise algorithm
- Worley Noise - Cellular/voronoi patterns
Includes FBM (Fractional Brownian Motion) for layered detail.
Exports:
noiseHelperFunctions- GLSL code stringgradientNoiseUniforms- Default uniforms objectNOISE_TYPES- Type constants
16 dithering algorithms for quantization effects:
- Ordered dithering: Bayer 2x2, 4x4, 8x8
- Stochastic: Random, Blue Noise (animated), Pattern
- Error diffusion: Floyd-Steinberg, Atkinson, Burkes, Jarvis, Sierra2, Stucki, and more
Exports:
ditherFragmentShader- Full fragment shaderditherVertexShader- Vertex shaderditherShaderUniforms- Default uniformsDITHER_TYPES- Type constants
10 wave types for UV coordinate distortion:
- Sin - Smooth sine wave (classic)
- Saw - Linear ramp
- Triangle - Sharp up/down
- Square - Binary on/off
- Pulse - Adjustable duty cycle
- Bounce - Elastic/spring motion
- Perlin - Smooth noise-based
- Spiral - Circular rotation
- Steps - Quantized staircase
- Random - Chaotic noise
Exports:
waveDistortionFunctions- GLSL code stringwaveDistortionUniforms- Default uniformsWAVE_TYPES- Type constants
Comprehensive color grading controls:
- Brightness, Contrast, Exposure
- Saturation, Gamma, Clarity
- Shadows, Midtones, Highlights
- Black Point, White Point
Includes proper linear/sRGB conversion and tone mapping.
Exports:
colorGradingFunctions- GLSL code stringcolorGradingUniforms- Default uniforms
import { noiseHelperFunctions, gradientNoiseUniforms } from './shaders/gradientNoiseShader';
import { waveDistortionFunctions, waveDistortionUniforms } from './shaders/waveDistortionShader';
const fragmentShader = `
${noiseHelperFunctions}
${waveDistortionFunctions}
void main() {
// Your shader code using the functions
}
`;
const material = new THREE.ShaderMaterial({
uniforms: {
...gradientNoiseUniforms,
...waveDistortionUniforms
},
fragmentShader,
vertexShader: standardVertexShader
});Each module is independent and can be combined as needed:
- Gradient Noise + Dither = Posterized gradient
- Wave Distortion + Gradient = Flowing patterns
- Color Grading + Dither = Stylized post-processing
- All together = Complete shader playground
All modules include TypeScript types and proper default values.