# \`material.needDepthPass = true\` hides the \`edgesRenderer\` edges behind it

**URL:** <https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681>\
**Category:** Questions\
**Tags:** material, depth-sorting, edges\
**Created:** [April 7, 2025, 7:30am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681 "2025-04-07T07:30:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heaust-ops](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/heaust-ops/32/45470_2.png) [@Heaust-ops](https://forum.babylonjs.com/u/Heaust-ops)\
**Post date:** [April 7, 2025, 7:30am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681/1 "2025-04-07T07:30:18Z")

</div>

PG:

> **[Babylon.js Playground](https://playground.babylonjs.com/#SXS73H%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

 ![Screenshot from 2025-04-07 12-58-53](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/8/b/8bedc3c7411fe3d5dbbbedf4fe83de9a33862354.png)

If I enable `material.needDepthPass = true` on the sphere’s material.

It hides the edges made by the edges renderer behind it.

Maybe bug? idk

How do I get it to show tho

---

<div class="post-metadata">

**Author:** ![Heaust-ops](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/heaust-ops/32/45470_2.png) [@Heaust-ops](https://forum.babylonjs.com/u/Heaust-ops)\
**Post date:** [April 7, 2025, 7:43am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681/2 "2025-04-07T07:43:02Z")

</div>

got it,

by setting `depthFunction` to `ALWAYS`

> **[Babylon.js Playground](https://playground.babylonjs.com/#SXS73H%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

essentially this,  
`ground.edgesRenderer.lineShader.depthFunction = BABYLON.Constants.ALWAYS;`

I have no clue what this does, but it works ig

---

<div class="post-metadata">

**Author:** ![Joe\_Kerr](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/joe_kerr/32/39017_2.png) [@Joe\_Kerr](https://forum.babylonjs.com/u/Joe_Kerr)\
**Post date:** [April 7, 2025, 7:48am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681/3 "2025-04-07T07:48:58Z")

</div>

Beware if there is more stuff going on: [https://playground.babylonjs.com/#SXS73H#3](https://playground.babylonjs.com/#SXS73H#3) 😮

---

<div class="post-metadata">

**Author:** ![Heaust-ops](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/heaust-ops/32/45470_2.png) [@Heaust-ops](https://forum.babylonjs.com/u/Heaust-ops)\
**Post date:** [April 7, 2025, 7:51am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681/4 "2025-04-07T07:51:46Z")

</div>

frick! xD

---

<div class="post-metadata">

**Author:** ![Joe\_Kerr](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/joe_kerr/32/39017_2.png) [@Joe\_Kerr](https://forum.babylonjs.com/u/Joe_Kerr)\
**Post date:** [April 7, 2025, 8:43am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681/5 "2025-04-07T08:43:19Z")

</div>

Is it possible that the edge shader does not handle transparency at all? Because whatever props related to alpha I have changed, there is no interaction with the line.

I did want to look it up but I could not find any shader with “\*edge\*” [here](https://github.com/BabylonJS/Babylon.js/tree/master/packages/dev/core/src/Shaders) 😕

---

<div class="post-metadata">

**Author:** ![Heaust-ops](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/heaust-ops/32/45470_2.png) [@Heaust-ops](https://forum.babylonjs.com/u/Heaust-ops)\
**Post date:** [April 7, 2025, 9:13am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681/6 "2025-04-07T09:13:10Z")

</div>

it couldn’t be anything related to the material,  
edges renderer uses a `ShaderMaterial` and this PG

> **[Babylon.js Playground](https://playground.babylonjs.com/#SXS73H%234)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

confirms shader material behaves properly : O

but you’re right maybe it just doesn’t care about transparency lol

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [April 7, 2025, 10:02am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681/7 "2025-04-07T10:02:06Z")

</div>

The problem is that `needDepthPass = true` first renders the object to the depth buffer, so the lines of the edge renderer won’t be drawn because they are drawn last, after all objects of the scene.

You can try to set `renderingGroupId = 1` for the objects with `needDepthPass = true`:

> **[Babylon.js Playground](https://playground.babylonjs.com/#SXS73H%235)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

---

<div class="post-metadata">

**Author:** ![Heaust-ops](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/heaust-ops/32/45470_2.png) [@Heaust-ops](https://forum.babylonjs.com/u/Heaust-ops)\
**Post date:** [April 7, 2025, 10:07am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681/8 "2025-04-07T10:07:37Z")

</div>

got it! tysm : D

I’m curious tho why edges renderer lines, which are meshes w/ shader material, behave differently than a mesh w/ shader material.

is the “render last” thing an extra optimization that’s added on top?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [April 7, 2025, 10:21am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681/9 "2025-04-07T10:21:14Z")

</div>

> [@Heaust-ops](#):
>
> I’m curious tho why edges renderer lines, which are meshes w/ shader material, behave differently than a mesh w/ shader material.

It’s because they are rendered after everything else.

> [@Heaust-ops](#):
>
> is the “render last” thing an extra optimization that’s added on top?

I think so, that way fewer lines will be drawn if some objects hide them, but it can lead to problems like in your PG. Maybe we should consider making the edge renderer render the lines at other places in the rendering pipeline…

---

<div class="post-metadata">

**Author:** ![Heaust-ops](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/heaust-ops/32/45470_2.png) [@Heaust-ops](https://forum.babylonjs.com/u/Heaust-ops)\
**Post date:** [April 7, 2025, 10:26am UTC](https://forum.babylonjs.com/t/material-needdepthpass-true-hides-the-edgesrenderer-edges-behind-it/57681/10 "2025-04-07T10:26:05Z")

</div>

I see, I get it now, thank you!
