# How to access the Custom Depth Stencil inside a global shader?

**URL:** <https://forums.unrealengine.com/t/how-to-access-the-custom-depth-stencil-inside-a-global-shader/672373>\
**Category:** Rendering\
**Tags:** unreal-engine, Anti-Aliasing, question, Global-Shaders\
**Created:** [October 19, 2022, 2:05am UTC](https://forums.unrealengine.com/t/how-to-access-the-custom-depth-stencil-inside-a-global-shader/672373 "2022-10-19T02:05:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Azeew27](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Azeew27](https://forums.unrealengine.com/u/Azeew27)\
**Post date:** [October 19, 2022, 2:05am UTC](https://forums.unrealengine.com/t/how-to-access-the-custom-depth-stencil-inside-a-global-shader/672373/1 "2022-10-19T02:05:15Z")

</div>

Hey, there!  
I’m trying to modify Unreal’s TAA source code, and I need to access the Custom Depth Stencil buffer inside the shader itself. But I have no idea how to do that! Do I need to modify the .cpp code and link it to the shader somehow? Or is there a way to just access it directly inside the shader?

Thanks!

---

<div class="post-metadata">

**Author:** ![Azeew27](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Azeew27](https://forums.unrealengine.com/u/Azeew27)\
**Post date:** [October 23, 2022, 11:35am UTC](https://forums.unrealengine.com/t/how-to-access-the-custom-depth-stencil-inside-a-global-shader/672373/2 "2022-10-23T11:35:11Z")

</div>

Bump! Still haven’t really figured this out. I’ll update this if I manage to find a solution.

---

<div class="post-metadata">

**Author:** ![Ceriatinho](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ceriatinho/32/476121_2.png) [@Ceriatinho](https://forums.unrealengine.com/u/Ceriatinho)\
**Post date:** [March 15, 2023, 5:58pm UTC](https://forums.unrealengine.com/t/how-to-access-the-custom-depth-stencil-inside-a-global-shader/672373/3 "2023-03-15T17:58:20Z")

</div>

any news?

---

<div class="post-metadata">

**Author:** ![Davit\_Masia](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davit_masia/32/1008648_2.png) [@Davit\_Masia](https://forums.unrealengine.com/u/Davit_Masia)\
**Post date:** [April 14, 2023, 7:36am UTC](https://forums.unrealengine.com/t/how-to-access-the-custom-depth-stencil-inside-a-global-shader/672373/4 "2023-04-14T07:36:01Z")

</div>

Im interested on this too. Nobody knows the answer? Even if is not possible to discard this option?

Im looking a way to include/exclude objects from the shader. The first thing that comes to my mind is by stencil. Is there an other way?

---

<div class="post-metadata">

**Author:** ![Azeew27](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Azeew27](https://forums.unrealengine.com/u/Azeew27)\
**Post date:** [April 27, 2023, 3:15pm UTC](https://forums.unrealengine.com/t/how-to-access-the-custom-depth-stencil-inside-a-global-shader/672373/5 "2023-04-27T15:15:23Z")

</div>

Sorry for the delay guys, I haven’t opened the forums in a while. I figured out a way to do it, yes!

All I did was download and build Unreal from source and modify a couple of files in \Engine\Source\Runtime\Renderer. You can check the code in TemporalAA.cpp and backtrack from there. I’m a bit busy at this moment, but I’ll need to update the engine version and possibly redo all changes cause I screwed up version control lol, I can give more precise details once I get to that point!

Good luck!

---

<div class="post-metadata">

**Author:** ![Davit\_Masia](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davit_masia/32/1008648_2.png) [@Davit\_Masia](https://forums.unrealengine.com/u/Davit_Masia)\
**Post date:** [April 27, 2023, 4:41pm UTC](https://forums.unrealengine.com/t/how-to-access-the-custom-depth-stencil-inside-a-global-shader/672373/6 "2023-04-27T16:41:04Z")

</div>

Oh! yes please, that will help a lot!

---

<div class="post-metadata">

**Author:** ![Azeew27](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Azeew27](https://forums.unrealengine.com/u/Azeew27)\
**Post date:** [July 2, 2023, 11:34am UTC](https://forums.unrealengine.com/t/how-to-access-the-custom-depth-stencil-inside-a-global-shader/672373/7 "2023-07-02T11:34:52Z")

</div>

Sorry for the delay!  
There’s certainly a better way to share this, but I can’t make the repo public and I suck at git lmao, so hopefully this works.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/3/c/23c3e047d339400cc76ba02be986e68f5df2e3db.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/c/3fce58c1c450f1eec1ecd55f0a6825e19f442bd5.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/6/2/06220da599729328f7e5a1c211eb57bb1fcdc3c1.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/3/603624b7c1f936dc40d5bb3310ccce0ca73c6499.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/e/f/8efc7c91865e99725144997093eedd0502d5d83f.png)
