djn24
October 27, 2022, 9:24pm
1
Add two meshes to a scene, add both to the glow layer, set both to use their own material (referenceMeshToUseItsOwnMaterial).
Make the meshes partially transparent.
Move the camera so it is looking through transparent parts of one mesh to see the other.
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.)
I think I have found the bug:
return;
}
const hardwareInstancedRendering = batch.hardwareInstancedRendering[subMesh._id] || renderingMesh.hasThinInstances;
this._setEmissiveTextureAndColor(renderingMesh, subMesh, material);
this.onBeforeRenderMeshToEffect.notifyObservers(ownerMesh);
if (this._useMeshMaterial(renderingMesh)) {
renderingMesh.render(subMesh, hardwareInstancedRendering, replacementMesh || undefined);
} else if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
const renderingMaterial = effectiveMesh._internalAbstractMeshDataInfo._materialForRenderPass?.[engine.currentRenderPassId];
let drawWrapper = subMesh._getDrawWrapper();
if (!drawWrapper && renderingMaterial) {
drawWrapper = renderingMaterial._getDrawWrapper();
}
if (!drawWrapper) {
return;
renderingMesh.render(subMesh, hardwareInstancedRendering, replacementMesh || undefined);
should be
renderingMesh.render(subMesh, enableAlphaMode, replacementMesh || undefined);
Happy to run the tests and open a PR with this suggested fix.
1 Like
djn24
October 27, 2022, 9:40pm
2
Since it was just a one-liner I’ve tried a PR with the fix:
BabylonJS:master
← djn24:master
opened 09:38PM - 27 Oct 22 UTC
I believe I found a corner-case bug in effectLayer.ts. I've posted about it on t… he 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.)
3 Likes
Thanks a lot for the fix… and I d blame copy paste
djn24
October 28, 2022, 5:31am
4
No problem! Thanks for the super-speedy response.
1 Like