# Enable project setting programatically: Custom Depth-Stencil Pass

**URL:** <https://forums.unrealengine.com/t/enable-project-setting-programatically-custom-depth-stencil-pass/383172>\
**Category:** Rendering\
**Tags:** settings, stencil, unreal-engine, Scripting, Rendering, question\
**Created:** [January 27, 2017, 10:44pm UTC](https://forums.unrealengine.com/t/enable-project-setting-programatically-custom-depth-stencil-pass/383172 "2017-01-27T22:44:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_24cff47d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_24cff47d](https://forums.unrealengine.com/u/anonymous_user_24cff47d)\
**Post date:** [January 27, 2017, 10:44pm UTC](https://forums.unrealengine.com/t/enable-project-setting-programatically-custom-depth-stencil-pass/383172/1 "2017-01-27T22:44:55Z")

</div>

If it possible to set “Custom Depth-Stencil Pass” setting (in Project Settings \> Rendering \> Postprocessing) programmatically using either C++ or Blueprint at runtime?

---

<div class="post-metadata">

**Author:** ![kgamble](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kgamble](https://forums.unrealengine.com/u/kgamble)\
**Post date:** [January 27, 2017, 11:33pm UTC](https://forums.unrealengine.com/t/enable-project-setting-programatically-custom-depth-stencil-pass/383172/2 "2017-01-27T23:33:38Z")

</div>

Looks like the Console Command r.CustomDepth will do what you want. So you can run an Execute Console Command node with r.CustomDepth 0 it turns it off and r.CustomDepth 1 turns it on.

As an example, this will turn it on when you press ‘K’ and off when you release it

![123901-customdepth.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/e/e5e0ea9350ffbca3a70e319a9d3a44c669f286a7.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_24cff47d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_24cff47d](https://forums.unrealengine.com/u/anonymous_user_24cff47d)\
**Post date:** [January 29, 2017, 3:53am UTC](https://forums.unrealengine.com/t/enable-project-setting-programatically-custom-depth-stencil-pass/383172/3 "2017-01-29T03:53:50Z")

</div>

This works! Also to enable Custom-Depth Pass with Stencil use r.CustomDepth 3.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_24cff47d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_24cff47d](https://forums.unrealengine.com/u/anonymous_user_24cff47d)\
**Post date:** [May 6, 2017, 4:07am UTC](https://forums.unrealengine.com/t/enable-project-setting-programatically-custom-depth-stencil-pass/383172/4 "2017-05-06T04:07:07Z")

</div>

Apparently GetWorld()-\>Exec(…) doesn’t work to set above option from C++. You must instead do,

```
UKismetSystemLibrary::ExecuteConsoleCommand(GetWorld(), FString("r.CustomDepth 3"));

```

You will need,

```
#include "Kismet/KismetSystemLibrary.h"

```

---

<div class="post-metadata">

**Author:** ![WildeHoney](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/wildehoney/32/1111549_2.png) [@WildeHoney](https://forums.unrealengine.com/u/WildeHoney)\
**Post date:** [October 20, 2024, 6:58am UTC](https://forums.unrealengine.com/t/enable-project-setting-programatically-custom-depth-stencil-pass/383172/5 "2024-10-20T06:58:09Z")

</div>

> [@kgamble](#):
>
> r.CustomDepth 0

when using this command, my project will not maximise, it stays in taskbar shows it on hover but i am unable see it on any screen.
