GlowLayer does not take Mesh.visibility into account. Unless the visibility is set to 0

Hello,

I am not sure if this is a bug. It might be just an inconsistency.

I noticed that revision 4.2.0 introduced Mesh.visibility specified as a <0, 1> range.

  • set visibility(value: number): any
    Gets or sets mesh visibility between 0 and 1 (default is 1)

I tried do make use of this to perform smooth fading away of an object, and then I realised that the glow surrounding it does not change its brightness. Even if the visibility of object is set to a very small value like 0.00000001, the glowLayer does not take it into account and gives full glow.

(line #94 sets visibility)

As I said I am not sure if this is a bug. One could argue that glowLayer is an independent layer and should be modified somehow separately. But then, if I set visibility to 0, glowLayer does take it into account and switches the glowing for the given object off. So sometimes the visibility is taken into account and sometimes not. It somehow does not feel right.

Visibility is not used by the glow layer. Visibility=0 is used to mean mesh not visible, that’s why it disappears when you reach this value.

In your case, I think you should decrease the glow layer intensity to simulate a fade out of the layer.

@Evgeni_Popov thank you. I was thinking about that, but then I realised this causes some problems. My meshes change visibility (fade in/out) independently from each other, and this effectively implies that each mash would effectively need to have its own GlowLayer. This does not feel to be most efficient. That’s why I was happy to see the new “partial visibility” concept introduced by 4.2, hoping it would spare the hassle of managing separate layers. But now it looks like some parts of mesh fade, some parts do not. It somehow breaks mesh integrity.

Maybe you can try to update the emissiveTexture.level property as you fade out:

https://playground.babylonjs.com/#8T11QY#2

that’s nice! It feels like a workaround, but I am taking it. Thank you @Evgeni_Popov !

And I am terribly sorry. It looks like this partial visibility idea was introduced earlier. I simply first noticed it while upgrading my project to 4.2, and I was convinced it didn’t work before like that.

Still I think the partial visibility should be extended to GlowLayer functionality as well. Otherwise the Mesh abstraction does not hold. That’s just an opinion, but intuitively I would expect that partial visibility applies to entire mesh, and I would expect this to work like this out of the box without resorting to low level mechanisms like this nice emissiveTexture.level trick.

It looks like this partial visibility idea was introduced earlier. I simply first noticed it while upgrading my project to 4.2, and I was convinced it didn’t work before like that.

The visibility property does exist in Babylon.js for quite some time (was already there in a commit from 2018) and AFAIK it has always worked the same way: it makes your mesh more and more transparent, and at visibility=0 the mesh is not drawn anymore.

The effect layer does not use this property and I don’t know if the technic used is compatible with this property… That’s something that would need to be investigated.

1 Like

On a side note, the emissiveTexture.level solution also leads to some inefficiencies. If meshes are supposed to fade independently, they cannot reuse materials. Each needs to have its own clone.

But for now it is good enough for my project. Thank you for your help.

1 Like