Dither Shader
A powerful canvas-based component that applies various dithering effects to images. Supports multiple dithering algorithms (Bayer, Halftone, Noise, Crosshatch) and color modes (Original, Grayscale, Duotone, Custom) with extensive customization options.Usage
Basic Grayscale Dithering
Duotone Effect
Animated Noise Effect
Custom Palette
Props
Source URL of the image to apply dithering effects to. Can be a relative path or absolute URL.
Size of the dithering grid cells in pixels. Smaller values create finer dithering patterns. Typical range: 2-8.
Type of dithering pattern to apply:
bayer: Ordered dithering using Bayer matrix (classic dithering)halftone: Rotated dot pattern similar to print halftonesnoise: Random noise-based ditheringcrosshatch: Crosshatch line pattern
Color processing mode:
original: Preserves colors with quantizationgrayscale: Converts to black and whiteduotone: Maps to two custom colorscustom: Uses a custom color palette
Inverts the dithered output colors (dark becomes light, light becomes dark).
Pixelation multiplier. Values greater than 1 create larger pixelated blocks. Useful for retro effects.
Primary (dark) color for duotone mode. Accepts hex, rgb, or named colors.
Secondary (light) color for duotone mode. Accepts hex, rgb, or named colors.
Array of colors for custom color mode. Can be 2 colors for binary dithering or more for multi-tone effects.
Brightness adjustment from -1 (darker) to 1 (brighter). 0 is neutral.
Contrast adjustment from 0 (no contrast) to 2 (high contrast). 1 is neutral/normal.
Background color behind the dithered image. Useful when image has transparency.
How the image should fit within the container:
cover: Fills container, crops as neededcontain: Fits entirely within containerfill: Stretches to fill containernone: Uses original dimensions
Dithering threshold bias from 0 to 1. Lower values make the image darker, higher values make it lighter.
Enables continuous animation effect. Works best with
noise dither mode.Speed of animation effect. Lower values are slower. Only applies when
animated is true.Additional CSS classes for the container. Use this to set the size of the component (e.g.,
"h-64 w-80").Dithering Modes Explained
Bayer Dithering
Uses an ordered Bayer matrix (4×4 or 8×8) to create a classic dithered look. This is the most common dithering technique used in computer graphics and provides consistent, repeatable patterns.Halftone Dithering
Creates a rotated dot pattern similar to traditional print halftones. The pattern rotates at 45 degrees and creates circular or diamond-shaped dots that vary in size based on image brightness.Noise Dithering
Applies random noise-based dithering that creates a more organic, film-grain-like appearance. When animated, creates a dynamic, constantly-shifting effect.Crosshatch Dithering
Generates a crosshatch line pattern similar to hand-drawn cross-hatching. Creates intersecting diagonal lines that darken areas based on image luminance.Color Modes Explained
Original Mode
Preserves the original colors of the image while applying dithering. Colors are quantized to fewer levels (typically 4 per channel) to create the dithered appearance while maintaining the original color palette.Grayscale Mode
Converts the image to pure black and white using luminance values. Creates high-contrast, newspaper-style images.Duotone Mode
Maps the image to two colors of your choice. Dark areas use the primary color, light areas use the secondary color. Perfect for creating branded images or artistic effects.Custom Mode
Allows you to define a custom color palette. With 2 colors, works like duotone. With 3+ colors, creates multi-tone effects by quantizing the image to your specific palette.Performance Considerations
CORS Considerations
The component sets
crossOrigin="anonymous" on the image. If you’re loading images from external domains, ensure they have proper CORS headers set, or you’ll receive a canvas security error.