How to use HighlightLayer to display the edges of objects to the top layer

As shown in the figure:

The edges of the selected object will always be displayed at the forefront.
Does HighlightLayer have a feature that prohibits deep writing?

three.js examples (
You may want to consider porting ThreeJS’s outline
Tips on how to create something like three postprocessing_outline in babylon js - Questions - Babylon.js
This is the relevant literature I found on the babylon forum

Thank you, bJS does not have high-quality outline effects. HighlightLayer always produces unexpected effects, and even after searching for a long time, I cannot solve my problem

HighlightLayer does not stack properly with translucent material - Questions - Babylon.js (
I used to be troubled by something like this, and then I found a compromise solution, you can take a look. For multiple meshes selected at the same time, you can merge multiple meshes into a single mesh and give it a material with a very high uniqueId level.

We have several options:

Thank you for your help. For setting transparency for materials, your uniqueId scheme is also invalid. Additionally, merging geometry is a performance intensive operation that cannot be easily used

Thank you for your answer,As far as I know, the BJS render outline is based on the direction of the object’s normal , Normal based contour drawing may not capture some small geometric details and sharp edges, especially in high polygon models. This can cause the contours of certain details to not be displayed correctly. Additionally, the width of the contour is based on world space and cannot be a fixed width for the screen. The render outline can be used, but it is not commonly used and has many limitations

Nope render outline simply render a second mesh with the color but slighly bigger:
Babylon.js/packages/dev/core/src/Rendering/outlineRenderer.ts at d33f4870bc032d8fd22768b23faeda61ac7330d2 · BabylonJS/Babylon.js (

Babylon.js/packages/dev/core/src/Shaders/outline.vertex.fx at d33f4870bc032d8fd22768b23faeda61ac7330d2 · BabylonJS/Babylon.js (