Mesh sometimes becomes invisble when Material.opacityFresnel is true

Hi everyone,


Symptom: mesh invisible even though enabled and visible. Mesh.renderingGroupId is increased. It is not backface culling. Bounding box renders fine. Using “BackgroundMaterial”.

Solution: Material.opacityFresnel = false

Long version

Sorry for the terribly vague description but I can’t even reproduce this potential bug reliably in my local project.

I use “cover plates” to indicate whether a wall or an obstacle gives an actor full or only half cover. There are four plates on a tile I switch on or off depending on cover in that direction. I use two BackgroundMaterials (for full cover and half cover) and re-assign on demand. Here is the setup I use: Babylon.js Playground (the playground does NOT reproduce the bug).

Sometimes cover plates become invisible even though they are enabled. So far switching materials is required for the potential bug to occur. But after that I do not know: I randomly move the mouse from cover the cover until it happens. To get the cover plate visible again, I need to move the mouse randomly again AND need to rotate the camera.

Its noteworthy that if you rotate the invisble plate so that its frontface starts looking into the sky, while it rotates, it is fading from invisible to fully visible.

Anyway, thanks to the Inspector, it seems if you set Material.opacityFresnel to false (or Inspector->Material->Rendering->Opacity fresnel), it fixes the potential bug.

Took me a while to figure this out because initially I though the plate was still visible and just rendered inside the obstacle. Hope this post saves someone some time :slight_smile:

Best wishes

1 Like

opacityFresnel=true is using the sceneCenter property to compute the alpha fade factor. Make sure you have some sensible value for each of your background material for this property.

However, without a repro, I think it will be difficult to help more.

Oh! Thanks @Evgeni_Popov for the heads up. But on my end I am fine with disabling opacityFresnel.

Or is there a significant chance that there might be an actual bug? Then I would keep tinkering with it some more.

Maybe there’s no bug, as it is the purpose of opacity fresnel to update the alpha value => at some point it can become too low for the mesh to be visible, depending on the camera position and your setting for the background material. But as you implied there was a bug somewhere, I though I had to answer!