# Material depthFunction value for "Less or Equal"?

**URL:** <https://forum.babylonjs.com/t/material-depthfunction-value-for-less-or-equal/38912>\
**Category:** Questions\
**Tags:** material\
**Created:** [March 10, 2023, 6:14am UTC](https://forum.babylonjs.com/t/material-depthfunction-value-for-less-or-equal/38912 "2023-03-10T06:14:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShaderRig](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@ShaderRig](https://forum.babylonjs.com/u/ShaderRig)\
**Post date:** [March 10, 2023, 6:14am UTC](https://forum.babylonjs.com/t/material-depthfunction-value-for-less-or-equal/38912/1 "2023-03-10T06:14:15Z")

</div>

Hi! I’m trying to set the depthFunction within a script.

I found this post: [depthFunction (materials) might need a bit of a cleaning in doc and playground](https://forum.babylonjs.com/t/depthfunction-materials-might-need-a-bit-of-a-cleaning-in-doc-and-playground/29144)

Which Mawa went through the same journy as me today. Trying to change the setting within the 0 - 8 range always returns “Engine Default”

I tried using 519 (as Mawa mentioned) and I also finally got it to change to “Always” In my case I’m trying to use “Less or Equal”

Does anyone know what value I have to use to set the value to Less or Equal ?

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [March 10, 2023, 8:17am UTC](https://forum.babylonjs.com/t/material-depthfunction-value-for-less-or-equal/38912/2 "2023-03-10T08:17:38Z")

</div>

Easiest is to ask @RaananW 😝 When searching for depthFunction in the API, I still get the 4.7k of useless PGs and still couldn’t find the explanation in the doc.  
May be the explanation itself can be given to you by @Evgeni_Popov . I haven’t reused this since my previous attempt, so I have no faen clue. Sorry,

 ![Capture d’écran 2023-03-10 à 09.14.42](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/b/bb40168769007884d2a87fd87c633c0749a1211f.png)

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [March 10, 2023, 11:33am UTC](https://forum.babylonjs.com/t/material-depthfunction-value-for-less-or-equal/38912/3 "2023-03-10T11:33:34Z")

</div>

Our playground search functionality needs a revamp. I have already made some internal tests to improve it, it’s just a matter of finding the time and implement it.

The values you are searching for are in the Constants file:

```auto
    // Depth or Stencil test Constants.
    /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
    public static readonly NEVER = 0x0200;
    /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
    public static readonly ALWAYS = 0x0207;
    /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
    public static readonly LESS = 0x0201;
    /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
    public static readonly EQUAL = 0x0202;
    /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
    public static readonly LEQUAL = 0x0203;
    /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
    public static readonly GREATER = 0x0204;
    /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
    public static readonly GEQUAL = 0x0206;
    /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
    public static readonly NOTEQUAL = 0x0205;

```

In UMD they would be BABYLON.Constants.WHATEVER\_YOU\_CHOOSE

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [March 10, 2023, 11:36am UTC](https://forum.babylonjs.com/t/material-depthfunction-value-for-less-or-equal/38912/4 "2023-03-10T11:36:26Z")

</div>

LOL. I sort of had the feeling that they might be the same as the stencil (kind of makes sense) but of course lazy me didn’t check it out 🤭. Thanks a lot @ShaderRig There you go.  
Both of you, have a great day 🕶

---

<div class="post-metadata">

**Author:** ![ShaderRig](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@ShaderRig](https://forum.babylonjs.com/u/ShaderRig)\
**Post date:** [March 10, 2023, 12:28pm UTC](https://forum.babylonjs.com/t/material-depthfunction-value-for-less-or-equal/38912/5 "2023-03-10T12:28:51Z")

</div>

Thank you, worked perfectly.  
Also thank you to @mawa for the original post.
