Decals on closest point

HI, I’m trying to add a decal on a sphere on his closest point to the camera. Once the sphere is created, I calculate the closest point to the camera to show the decal. This point looks correct because if I draw a box in the same place it is in the correct position.
But if I use that point to insert the decal I don’t see it applied to the sphere. Can you tell me why?
here my PG Babylon.js Playground


cc @Evgeni_Popov

Welcome aboard!

Your normal is not correctly computed, you should reuse normalised_vector instead.

Also, the world matrix of the sphere should be computed as it has not the right value at that point in the program because there has not been any rendering yet.

Lastly, you should set localMode to true, to be sure the decal is displayed at the right location even if the source mesh has some non zero position/rotation.

However, it still does not work because there is a conflict with the outline effect. The latter is also using zOffset (-4) by default, so you need to use a lower value for the decal. And to avoid artefacts, you need to use a value like -500, which is not ideal:

Maybe you can try to use the glow or highlight layer, instead, which should not have the same problem?

1 Like

Thank you so much! Yeah probably I’'ll try with highlight layer