Alpha fadeOut an Emissive Mesh with Glow Layer

Hey !

When I need to fadeOut a mesh, I use to smoothly set its visibility to 0.0
But when using a glow layer, the mesh will still glow :

  • Left : No glow
  • Right : Glow

As you can see, the mesh on the right never realy disappear


So, 2 questions about this :

  • Is it a bug ?
  • Is there a way to fadeOut my mesh without going through a custom GLSL shader ? (please note that I want to avoid editing the material itself, since many meshes use the same, and I want to control the fading of independent meshes)

++
Tricotou

I found a solution specific to my usecase, using the GlowLayer.customEmissiveColorSelector :

glow.customEmissiveColorSelector = function(mesh, subMesh, material, result) {
    if(material && material.emissiveColor && mesh.visibility!=undefined){
        result.copyFrom(material.emissiveColor);
        result.a = mesh.visibility;
    }
};

Both glow and no glow will fade :


Still, I’m interested to know if this behavior (mesh glows whatever the visibility>0) is intended :thinking:

1 Like

Visibility is not taken into account when generating the glow texture. What you can do, is set the intensity of the glow for the mesh, based on its visibility:

2 Likes

Ah yes, I had missed this glow.setEffectIntensity method, thanks ! :slight_smile:
Moving the solution checked to your post since it’s smoother than my emissiveColor set :face_with_tongue: