HighlightLayer colours whole meshes when needsAlphaTesting returns true

Hi,

I’m new on the forums but have been using Babylon for quite a while now. Something I noticed in the app I’m developing after updating from 3.3.0 to 4.1.0 (seems to happen on any 4.x.x in the playground) with highlightlayers is that meshes that return true from needAlphaTesting and overlap with highlighted meshes are fully coloured with the highlight colour. Not sure if this is actually intended behaviour, but as it didn’t happen in 3.3.0, the behaviour is different which is why I opened up a bug post about it. I tried looking at the release notes but didn’t see anything that could’ve caused this?

I set the diffuseTexture’s hasAlpha to true (even if it might not have it) to demonstrate the issue. The same thing happens if you override the needAlphaTesting method to always return true.

I tried searching around and this problem has usually been about problems with the stencil buffer; different renderingGroupId’s and clearing the buffer in between, stencil not being enabled on engine creation etc etc. But failed to find one about this (might be bad at searching using correct keywords). My guess is that it still has something to do with the stencil buffer but I can’t say I’m too familiar with debugging such stuff so I was unable to find the cause.

I tried including some screenshots but due to being a new user, I can only attach one screenshots which might or might not make sense here as I was trying to do comparison. You can see the difference in the playground by switching to babylon version 3.3 and then to any of the 4.x.x ones.

I tried looking at my scene with spector and noticed that when the higlighted mesh is drawn in to the higlight buffer, in the older one there used to be “holes” where overlapping meshes with hasAlpha was true were, and in the new one it just draws the whole mesh. The only difference I was able to spot up till that point (might’ve missed something obv) was that the internal format of the Depth Attachment renderbuffer was different. But I’m guessing this was because the older one for me used WebGL 1 and the new one uses WebGL 2? Initialising the engine in the new version of babylon with webgl 1 had no effect.

Playground example: Babylon.js Playground
You can observe different behaviour when using babylon version 3.3.0 and 4.x.x

1 Like

Thanks for reporting it and yes it is a bug, I will fix it for the next nightly.

2 Likes

Thanks for the quick reply, gonna keep an eye out for it then and try and understand what’s going on :slight_smile:

Everything will be updated in 30 minutes in alpha 8 thanks again for reporting the issue.

2 Likes