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

Add order-independent transparency for translucent blocks #519

Closed
wants to merge 1 commit into from
Closed

Conversation

silversquirl
Copy link
Member

The algorithm used is "Weighted, Blended Order-Independent Transparency", which allows for a fast and simple implementation at a small cost to color accuracy. This should solve all issues of translucent faces not rendering behind others, such as with water behind stained glass or with blocks containing translucent faces, such as slime and honey blocks.

More testing is required to confirm compatibility with limited OpenGL 2.0 implementations, such as those of macOS or older iGPUs, as well as to determine the impact on performance. This PR should not be merged until this testing has been done and any issues addressed.

Fixes #38

The algorithm used is "Weighted, Blended Order-Independent Transparency"[1], which allows for a
fast and simple implementation at a small cost to color accuracy. This should solve all issues of
translucent faces not rendering behind others, such as with water behind stained glass or with blocks
containing translucent faces, such as slime and honey blocks.

More testing is required to confirm compatibility with limited OpenGL 2.0 implementations, such as
those of macOS or older iGPUs, as well as to determine the impact on performance.

Fixes #38

[1]: https://casual-effects.blogspot.com/2015/03/implemented-weighted-blended-order.html
@Genau6502
Copy link

Any luck with turning up the opacity of honey/slime blocks?

@pwouik
Copy link

pwouik commented Feb 12, 2021

transparency blending isn't correct,every layer seem to have the same factor, and we cant clearly see depth

@MeeniMc
Copy link
Contributor

MeeniMc commented Mar 3, 2021

There is the following defect with culling the back-face of the 'targeted block' wire mesh: what we are looking at is a tower of white stained glass (6 tall), over white concrete. The first block is targeted, hence has the selected block wire-mesh around it rendered:

2021-03-03_03 32 34

Otherwise the improvement in correctness is impressive. I have found that water-bubble columns in stained glass (as found in bubblevators) work properly, and, unlike reported earlier, layered multiplicative blending does work properly for me.
(AMD Rx580, MultiDraw 4.3)

@MeeniMc
Copy link
Contributor

MeeniMc commented Mar 3, 2021

Test setup for transparency blending:

2021-03-03_03 58 01
(rendered with vk patch

Vanilla vktec:oit Sodium
Smooth 'fog' effect Fog effect works, but edges are more defined, are you using additive blending instead of multiplicative? Completely broken
2021-03-03_04 11 14 2021-03-03_03 57 39 2021-03-03_04 07 47
2021-03-03_04 11 25 2021-03-03_04 00 24 2021-03-03_04 07 40
--- --- ---
2021-03-03_04 11 34 2021-03-03_03 59 39 2021-03-03_04 08 29
Bubblevator, water renders through glass water AND BUBBLES render through glass water renders incorrectly through glass, sometimes not at all

Slime blocks in front of honey blocks behind stained glass work properly (although again blending appears to be different than vanilla, could again be explained by a difference in the blending operator).
2021-03-03_05 09 22

@MeeniMc
Copy link
Contributor

MeeniMc commented Mar 3, 2021

The bug where multiple layers of stained glass are not rendered correctly across chunk boundaries is also fixed. In prior versions of sodium, looking through multiple horizontal layers of glass (separated by 1 air layer inbetween), when looking from the bottom (looking towards the sky) would render only one layer for blocks outside the current chunk. This is now rendering correctly.

Overall, the improvement in correctness is MASSIVE. Performance drop is negligible with a 256px resource pack. It is more substantial with 16px textures.

@pwouik
Copy link

pwouik commented Mar 3, 2021

2021-03-03_11 41 23
transparent blocks behind have too much weight compared to blocks in front
with a lot of transparent blocks it make front blocks blend with further blocks and sometimes blocks behind completely override blocks in front
2021-03-03_11 55 44
@Meeni-mc oit doesn't really use a blending operator,but an order independant function

@MrJake222
Copy link

  • Clouds not visible through stained glass and water.
  • Water looks weird when seen through another water.

@silversquirl
Copy link
Member Author

Clouds not visible through stained glass and water.

This is a vanilla issue that will not be fixed by this PR. Whether Sodium should fix it is a separate issue.

As for the blending issues, I'm aware of them and will work on a fix after I've fixed OpenGL 2.0 support (which is basically only used on macOS). However, this may take a while as I have a lot going on irl right now.

@CalXee
Copy link

CalXee commented Mar 3, 2021

  • Clouds not visible through stained glass and water.

Does turning on Fabulous graphics fix this?

@MrJake222
Copy link

Does turning on Fabulous graphics fix this?

No.

@Boobies
Copy link

Boobies commented Mar 10, 2021

Subchunk boundary issue in current Sodium (vk suggested that I upload it here):

2021-03-10_19 33 16

@pwouik
Copy link

pwouik commented Mar 10, 2021

reported here:#38 (comment)

@PastelRobot
Copy link

Resource packs without transparency on normally transparent blocks have some faces visible threw them.

2021-03-10_19 32 18

2021-03-10_19 40 24

@MeeniMc
Copy link
Contributor

MeeniMc commented Mar 12, 2021

Subchunk boundary issue in current Sodium (vk suggested that I upload it here):

Are you using this PR, or a sodium release (or sodium-0.1.1 as provided by JellySquid in Nov?). Asking because in my tests this bug was present in prior versions, but is fixed with this PR.

@Boobies
Copy link

Boobies commented Mar 12, 2021

Are you using this PR, or a sodium release (or sodium-0.1.1 as provided by JellySquid in Nov?). Asking because in my tests this bug was present in prior versions, but is fixed with this PR.

I said "current Sodium," didn't I? That means the latest release. As your tests confirmed already. Anyway, I don't know whether the PR solves the issue or not as I have not tested it but I'm assuming there might be issues regarding it since vktec said that it was new information that I should upload here so he does not forget about it. He probably wants to at least review the issue.

@silversquirl
Copy link
Member Author

Ah, I had thought you were observing this behaviour with this PR

@silversquirl
Copy link
Member Author

silversquirl commented Mar 12, 2021

Resource packs without transparency on normally transparent blocks have some faces visible threw them.

Thanks, this is useful information. I expect it's because those blocks use translucent rendering despite not actually being translucent, meaning they get blended.
Not sure if there's much I can do about it, but hopefully when I fix the other blending issues it'll become less noticeable at least.

@MrJake222
Copy link

Also water bubbles seem to have issues with rendering.

@Heitzenberg
Copy link

Do you plan on rebasing this on the current sodium-next, to resolve the merge conflicts?

@machinesmith42
Copy link

any luck with this?

@MeeniMc
Copy link
Contributor

MeeniMc commented Apr 27, 2021

Do you plan on rebasing this on the current sodium-next, to resolve the merge conflicts?

I have merged this PR on top of PR #581 (Indium/LBG patch), on top of build 352
https://github.com/MeeniMc/sodium-fabric/commits/pr/519

@MeeniMc
Copy link
Contributor

MeeniMc commented Jun 3, 2021

@jellysquid3
Copy link
Member

Closing as abandoned. The author (vktec) has talked about not having the time available to continue updating this PR, and many changes have occurred in Sodium since which break this. Furthermore, while WBOIT is a (very fast) approximate function for OIT, it has significant trouble with mostly opaque/translucent surfaces, something which many users reported resulted in major graphical downgrades. Given that the original paper doesn't really acknowledge this outside of saying "don't do it", it's safe to say that this is just an issue with the algorithm and not something we can really correct for.

There are other OIT functions such as Moment-based OIT (MBOIT), which appear very promising, offering both decent performance (at least relative to sorting all translucent geometry on the CPU) and good rendering quality even in the cases Minecraft often sees. We may at some point want to investigate these options instead.

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.

Translucent blocks do not render correctly (fixed in Sodium 0.6)