niccolofanton/dithering-shader
À propos
Real-time ordered (Bayer) dithering post-processing effect for 3D scenes, built with React Three Fiber and Three.js
Développement web et applicatifWhat you can do
- Custom ordered-dithering effect using a 4x4 Bayer matrix
- Adjustable dithering grid resolution and pixelation strength
- Grayscale-only or color mode toggle
- Independent pre- and post-dithering bloom passes
Progression mesurée des étoiles
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +2
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalDithering Shader

Real-time ordered dithering as a post-processing effect for 3D scenes, built with React Three Fiber
What it does
This project applies a classic ordered (Bayer) dithering effect to a rendered Three.js scene as a full-screen post-processing pass. The scene renders a 3D model with custom environment-map lighting, and a GLSL shader pixelates the frame and quantizes brightness through a 4x4 dither matrix to produce the retro halftone look. Key parameters are exposed through an on-screen Leva control panel so you can tweak the effect in real time.
Quick start
Requires Node.js and Yarn (a yarn.lock is committed).
git clone https://github.com/niccolofanton/dithering-shader.git
cd dithering-shader
yarn install
yarn start
Then open the local dev server printed in your terminal. To create a production build:
yarn build
How the shader works
The dithering pass (src/dithering-shader/) runs after the scene is rendered:
- The frame is pixelated according to the grid size and pixel-size ratio.
- Luminance is computed per pixel.
- The pixel position is mapped into a 4x4 Bayer threshold matrix; the brightness is compared against the matrix value to decide whether the pixel is drawn or knocked out.
- The result can be rendered in grayscale or color.
Bloom can be added before (pre-dithering) and/or after (post-dithering) the dither pass,
chaining postprocessing effect passes through an EffectComposer.
Features
- Custom ordered-dithering effect using a 4x4 Bayer matrix
- Adjustable dithering grid resolution and pixelation strength
- Grayscale-only or color mode toggle
- Independent pre- and post-dithering bloom passes
- Live tweaking of grid resolution, pixelation strength, grayscale mode, and the bloom passes via Leva controls
- 3D model lit with a custom environment map
- Responsive, full-window canvas
Tech stack
- React + TypeScript
- Three.js via React Three Fiber and drei
- postprocessing for the effect composer
- Leva for the controls panel
- Create React App (configured with craco)
Credits
- 3D Model: Jousting Helmet by The Royal Armoury, CC-BY-4.0
- Original dithering pattern by Klems on Shadertoy
- Environment lighting inspired by @0xca0a
License
Released under the MIT License.
Explorer des projets similaires
Chargement…