Skip to content

Expose Bayer 2/4 dither modes and add Bayer 16 dither mode - #9117

Merged
mvaligursky merged 1 commit into
mainfrom
mv-bayer16
Jul 24, 2026
Merged

Expose Bayer 2/4 dither modes and add Bayer 16 dither mode#9117
mvaligursky merged 1 commit into
mainfrom
mv-bayer16

Conversation

@mvaligursky

Copy link
Copy Markdown
Contributor

Fixes #6097. The engine already had bayer2/bayer4 GLSL/WGSL helper functions implemented but unreachable, and no way to get a coarser or finer ordered-dither pattern than the existing Bayer 8. This adds DITHER_BAYER2 and DITHER_BAYER4 as selectable opacity dither modes, and introduces a new DITHER_BAYER16 mode for finer dithering.

Changes:

  • Add DITHER_BAYER2 and DITHER_BAYER4 constants, wiring up the existing bayer2()/bayer4() shader functions to the opacityDither chunk (GLSL + WGSL)
  • Add DITHER_BAYER16 constant and a new bayer16() function (GLSL + WGSL), extending the existing Bayer matrix recursion
  • Update StandardMaterial#opacityDither / #opacityShadowDither JSDoc to document the new modes

API Changes:

  • New exports: DITHER_BAYER2, DITHER_BAYER4, DITHER_BAYER16

Examples:

  • materials/material-transparency: added Bayer2, Bayer4 and Bayer16 columns alongside the existing dither modes
  • graphics/dithered-transparency: added Bayer2, Bayer4 and Bayer16 to the Dither Color / Dither Shadow dropdowns

@github-actions

Copy link
Copy Markdown

Public API report

This PR changes the public API surface (+3 / −0), per the docs' rules (@ignore / @Private / undocumented are excluded).

Show API diff
+const DITHER_BAYER16: "bayer16"
+const DITHER_BAYER2: "bayer2"
+const DITHER_BAYER4: "bayer4"

Informational only — this never fails the build.

@github-actions

Copy link
Copy Markdown

Build size report

This PR changes the size of the minified bundles.

Bundle Minified Gzip Brotli
playcanvas.min.js 2325.6 KB (+1.7 KB, +0.07%) 598.3 KB (+0.3 KB, +0.05%) 465.2 KB (+0.2 KB, +0.05%)
playcanvas.min.mjs 2323.0 KB (+1.7 KB, +0.07%) 597.1 KB (+0.3 KB, +0.05%) 464.7 KB (+0.4 KB, +0.09%)

@mvaligursky
mvaligursky merged commit 45160f6 into main Jul 24, 2026
10 checks passed
@mvaligursky
mvaligursky deleted the mv-bayer16 branch July 24, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bayer matrix

1 participant