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

Alpha blended mesh ordering issue #177

Open
MCArth opened this issue Mar 25, 2022 · 2 comments
Open

Alpha blended mesh ordering issue #177

MCArth opened this issue Mar 25, 2022 · 2 comments

Comments

@MCArth
Copy link
Contributor

MCArth commented Mar 25, 2022

Hi,

I've noticed some issues with alpha blended meshes, where the sorting order chosen by Babylon is wrong (and inconsistent as you move the camera)

It seems very likely its due to Babylon sorting meshes according to the center of the bounding sphere (at least from what I can tell):

Avoid having heavily-stretched alpha blended meshes (i.e. large planes); since the center of its bounding sphere is used for depth sorting, doing this may result in a mesh being sorted as far away from the camera but actually closer to many other meshes.

https://doc.babylonjs.com/divingDeeper/materials/advanced/transparent_rendering#rendering-order

It can be seen in test with the shadow:

image

(and when I zoom out)

image

I imagine this could be fixed by raycasting towards the mesh from the camera and manually setting alpha indexes dependent on if you hit a transparent voxel before reaching the mesh

I'm wondering if you've thought about this at all or have a simpler solution?

@MCArth
Copy link
Contributor Author

MCArth commented Mar 25, 2022

I've also noticed this issue affecting non-opaque blocks in noa-test, which seems like less of an easy fix
image

But I couldn't get it to affect the a/b/c/d/1/2 blocks (I assume they are alpha-tested instead of blended?)

@MCArth
Copy link
Contributor Author

MCArth commented Sep 7, 2022

As of babylon 5.0, it sounds like there's a feature that will fix this, though I haven't tested it - https://doc.babylonjs.com/divingDeeper/materials/advanced/transparent_rendering#generality

It notes there could be a perf hit (and it's also applied to alpha-tested meshes, which is unneeded)

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

No branches or pull requests

1 participant