Mesh visibility vs Material alpha

Hello,

I really can’t understand what’s is the exact difference between the two ; Mesh visibility vs Material alpha.
I’ve seen a playground visually showing me the difference during my research but I would like to understand the difference.

Also, what if instead of using babylon material, I have my own shader material and I’m setting the frag alpha, is the same alpha as material alpha on babylon material, or is the same as the mesh visiblity ? I though mesh visibility was an added uniform to calculate material alpha so at the end mat.alpha = mesh.visibility * alpha but probably not.

The alpha value of the material is used as the starting value of all alpha computation:

  1. alpha = material.alpha
  2. alpha = alpha * baseColor.a
  3. alpha = alpha * opacityMap.a
  4. alpha = alpha * vertexColor.a
  5. alpha is modified by opacity Fresnel
  6. alpha is modified by “specular over alpha” / “reflection over alpha”

Note that some of those steps will be done only if some specifics flags are set / variables have some specific value.

Then, after all those computations are done, the mesh.visibility is applied:

  • final alpha = alpha * mesh.visibility