Hi, my scene started to occlude a mesh depending on the view angle of the camera. See the images bellow, on the first it’s ok, on the second, the selection box looks like it’s behind the box labels (that are particles in a solid particle system, created from a plane mesh with dynamic texture on it).
Here the problem occurs:
But moving the camera to another angle, the problem disappears:
I can’t reproduce in playground since I don’t know what’s wrong. The scene was ok in the past few months, but maybe I did something (that I don’t remember) that made the problem appear recently.
My question is actually asking tips to where I start looking/testing to see what is causing the issue.
I already checked the materials, none of them has zoffset defined (and this was working before).
See the video below, the problem appears while the camera is moving:
This looks like some issues with z sorting. can you make sure the SPS particle are not registered as transparent? (their material has no alpha or opacity texture)
Yes that’s it!
I have set hasAlpha = true in the dynamic texture recently.
This was necessary to remove the black borders when the shape of the particle is not a cube, such as bellow:
The text labels are being created from the same source mesh (a plane), with a big dynamic texture on it, and I just set the uvs of each particle to get the proper label part.
Is there a way to deal with transparent textures on SPS?
I’ve found the article about the transparency issue with SPS (Troubleshooting Solid Particle System Transparency Issues | Babylon.js Documentation).
But setting enableDepthSort when creating the SPS made my entire SPS not being rendered, maybe because of this part of the article (my SPS uses multi materials):
Note also that the particle sort can’t work with the MultiMaterials.
One think to consider is that the issue I’m facing is not inside the SPS itself (problem with transparency between the particles), since the selection box is a independent mesh from the SPS. So I don’t know if this is the same issue as described in the article.
What you could do is to simply not use alpha blending but only alpha testing
Make sure you are setting the diffuse texture to hasAlpha = true so it should turn on the alpha testing system
Best way to get more help would be a simpler repro in the PG as we know where to look now
I think the problem is because I’m using PBRMaterial. Switching to StandarMaterial the issue actually disappeared!
With PBRMaterial I tried to set material.alphaMode = PBRMaterial.PBRMATERIAL_ALPHATEST. The issue with z sorting stop occurring, but the texture got a lot brighter, like it’s over exposed:
I’m using PBRMaterial because with StandarMaterial, in some angles, the light source is fully reflected into the camera, and I couldn’t find a way to make this not to happen (I tried to change the roughness and specular power, but no success), such as shown below:
Is there a easy way to make the standard material not reflect the source light with such intensity?
Anyway, I’ll try to create a playground using pbr material/sps to reproduce the original issue.
For the StandardMaterial’s specular lighting, you can try changing the specular property of the light or the specularColor property of the StandardMaterial to reduce its intensity. For example the default color is white, black will disable it completely, gray (0.5, 0.5, 0.5) will be half as much specular effect as usual, etc.
material.alphaMode = PBRMaterial.PBRMATERIAL_ALPHATEST
material.transparencyMode that you should set to
@Blake tip to remove the light reflection with standard material worked as a charm!
@Evgeni_Popov and @Deltakosh solution for the transparency issue for PBR Material solved the original problem!