โ† All examples

godot shaders

Ordered dithering to few colours or one bit

Dither the screen with an 8 x 8 Bayer matrix: reduce each channel to a few levels, or the image to two colours like a one-bit display, with adjustable dot scale and contrast.

Recorded render of Ordered dithering to few colours or one bit

What this component contains

  • ATTRIBUTION.md
  • LICENSE
  • README.md
  • component.json
  • demo.tscn
  • inspect_shader.py
  • material.tres
  • post_bayer_dither.gdshader
  • preview.png
  • test_package.py
  • verification/native.json

How it works

Shader type
spatial
Render modes
unshaded, cull_disabled, depth_test_disabled, depth_draw_never, skip_vertex_transform, fog_disabled
Parameters
screen_texture (sampler2D), levels (int = 4), dot_scale (float = 2), one_bit (bool = no), dark_color (vec4 = 0.1, 0.08, 0.16, 1), light_color (vec4 = 0.92, 0.9, 0.8, 1), contrast (float = 1.1)
Use it on
A MeshInstance3D with a 2 x 2 QuadMesh, `material.tres` as its material override and a large extra cull margin, as in `demo.tscn`.
Result
The scene reduced to four levels per channel with a fine crosshatch-like dot pattern.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/post_bayer_dither/

Recorded checks

godot 4.7.2.stable.official.ed1daf0bf

  • contract_static
  • engine_run
  • engine_log_clean
  • shader_in_scene
  • capture_written
  • render_not_uniform
  • shader_changes_pixels

Limits to consider

Ordered dithering shows a regular grid pattern by design. When the output is scaled by a non-integer factor the pattern beats into moire. The pass reads Godot's screen texture after opaque geometry, so transparent objects drawn after it are not processed and its order among other transparent passes is not controlled.