Glow effect does not respect the depth order

Rotate camera: https://playground.babylonjs.com/#QCJQR4#75

Looks like meshes are not sorted by depth before rendering to glow effect.

I tried to sort meshes manually in scene hierarchy, this does not help. However this method work with rendering to framebuffer. But does not work with rendering to effect.

And I tried to use scene.setRenderingOrder(). This also work with rendering to framebuffer but does not work with rendering to effect.

Transparency is important: meshes sometimes should be partially masked.

cc @sebavan

Glow and highlights layer do not support transparency or in a pretty limited way :frowning: Let me see if I can find smthg to improve this

        // Custom render function
        this._mainTexture.customRenderFunction = (
            opaqueSubMeshes: SmartArray<SubMesh>,
            alphaTestSubMeshes: SmartArray<SubMesh>,
            transparentSubMeshes: SmartArray<SubMesh>,
            depthOnlySubMeshes: SmartArray<SubMesh>
        ): void => {
            this.onBeforeRenderMainTextureObservable.notifyObservers(this);

            let index: number;

            const engine = this._scene.getEngine();

            if (depthOnlySubMeshes.length) {
                engine.setColorWrite(false);
                for (index = 0; index < depthOnlySubMeshes.length; index++) {
                    this._renderSubMesh(depthOnlySubMeshes.data[index]);
                }
                engine.setColorWrite(true);
            }

            for (index = 0; index < opaqueSubMeshes.length; index++) {
                this._renderSubMesh(opaqueSubMeshes.data[index]);
            }

            for (index = 0; index < alphaTestSubMeshes.length; index++) {
                this._renderSubMesh(alphaTestSubMeshes.data[index]);
            }

            const previousAlphaMode = engine.getAlphaMode();

            for (index = 0; index < transparentSubMeshes.length; index++) {
                this._renderSubMesh(transparentSubMeshes.data[index], true);
            }

            engine.setAlphaMode(previousAlphaMode);
        };

why not sort the transparent objects in the effectLayer?from far to near

The support is not related to sorting but to the internal technique we use with stencil and such.