Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opacity dithering support #5903

Merged
merged 5 commits into from Dec 19, 2023
Merged

Opacity dithering support #5903

merged 5 commits into from Dec 19, 2023

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Dec 19, 2023

Fixes #5159

  • Order independent transparency using dithering.
  • uses procedural Bayer pattern with 64 dither levels (8x8 grid)
  • dithering can be independently enabled for the shadows as well - this works the best with soft shadows such as VSM, otherwise a pattern is more obvious.

new API / example on how to enable:

StandardMaterial.opacityDither = true;
StandardMaterial.opacityShadowDither = true;

material.blendType would ideally be set to pc.BLEND_NONE
dither2.mov

Limitations:

  • if two objects are behind each other, with the same opacity, their pattern is the same and that causes the object behind to not be seen. Possible improvement here would be to have some per drew call random ID (meshInstance.id would work well) and the pattern would be offset along x and y based on this number. This is not done in this PR.
  • Bayer pattern is used. Other great option without obvious pattern include a blue noise. This was considered, but would require a small blue noise texture to be available, and so this can be done in a separate PR if needed / alternatively the dither chunk can be overriden and implement this.

Co-authored-by: Will Eastcott <will@playcanvas.com>
@mvaligursky mvaligursky merged commit 62fe0b4 into main Dec 19, 2023
7 checks passed
@mvaligursky mvaligursky deleted the mv-opacity-dithering branch December 19, 2023 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement dither transparency as one solution for order independent transparency
3 participants