Skip to content
项目

关于

Real-time ordered (Bayer) dithering post-processing effect for 3D scenes, built with React Three Fiber and Three.js

网站与应用开发

这些数字如何统计

可以做什么

  • 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

实测星标增长

24小时
0
7天
0
15天
+2
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Dithering Shader

Dithering Shader

Real-time ordered dithering as a post-processing effect for 3D scenes, built with React Three Fiber

Live demo License: MIT GitHub stars

Open the live demo →

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:

  1. The frame is pixelated according to the grid size and pixel-size ratio.
  2. Luminance is computed per pixel.
  3. 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.
  4. 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

Credits

License

Released under the MIT License.

探索相关项目

加载中…