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

Fix bug rendering transparent meshes using their own materials in effect layer #13179

Merged
merged 1 commit into from
Oct 27, 2022

Conversation

djn24
Copy link
Contributor

@djn24 djn24 commented Oct 27, 2022

I believe I found a corner-case bug in effectLayer.ts. I've posted about it on the forum here:

https://forum.babylonjs.com/t/bug-and-proposed-fix-effectlayer-with-meshes-using-their-own-materials-ignores-transparency/35194

Since (I think) I have found the fix already and it's just a one-liner, here is a PR with the fix. I've run "npm run test:unit" and "npm run build:dev" in GitPod, both were OK. The one-line change fixed the bug in my local repro.

Details of the bug (copied from the forum post):

  1. Add two meshes to a scene, add both to the glow layer, set both to use their own material (referenceMeshToUseItsOwnMaterial).
  2. Make the meshes partially transparent.
  3. Move the camera so it is looking through transparent parts of one mesh to see the other.
  4. The far-away mesh will lose its glow effect when seen through the transparent parts of the close mesh.

Demo: https://playground.babylonjs.com/#SRZRWV#1139
(Move the camera so that you are looking at parts of one glowing ball through the transparent parts of another ball. Observe that the parts of the far-away ball seen through the close-up ball do not glow.)

Copy link
Contributor

@Popov72 Popov72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, thanks for the fix!

@sebavan
Copy link
Member

sebavan commented Oct 27, 2022

Thanks a lot for the fix !!!

@azure-pipelines
Copy link

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@azure-pipelines
Copy link

@azure-pipelines
Copy link

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13179/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

@sebavan sebavan merged commit 39632a6 into BabylonJS:master Oct 27, 2022
RaananW pushed a commit that referenced this pull request Dec 9, 2022
Fix bug rendering transparent meshes using their own materials in effect layer

Former-commit-id: dad4355f9bcc86894d1d7a94a9a3e5ed9f4e6aec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants