# Disabling Custom Depth Rendering on certain objects

**URL:** <https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716>\
**Category:** Rendering\
**Tags:** Post-Processing, outline, highlight, custom-depth, depth, unreal-engine, question\
**Created:** [November 24, 2014, 4:43am UTC](https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716 "2014-11-24T04:43:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tobbo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tobbo](https://forums.unrealengine.com/u/Tobbo)\
**Post date:** [November 24, 2014, 4:43am UTC](https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716/1 "2014-11-24T04:43:28Z")

</div>

In my project I have interact-able objects outlined to show that they can be interacted with.

The problem is that the outline is shown through the player mesh (third person template). Is there a way to make the outline not render through the player mesh?

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/1/c/01cdcd1e9f77732778f601423d22362205f5c179.jpeg) ](https://i.imgur.com/r3FBoze.jpg)

Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b93dca7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b93dca7](https://forums.unrealengine.com/u/anonymous_user_4b93dca7)\
**Post date:** [November 26, 2014, 4:38pm UTC](https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716/2 "2014-11-26T16:38:02Z")

</div>

I assume the outline is implemented as PostprocessMaterial reading CustomDepth.  
You can read SceneDepth there as well and with some depth comparison you can mask or dim the areas you want.

---

<div class="post-metadata">

**Author:** ![lion032](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lion032](https://forums.unrealengine.com/u/lion032)\
**Post date:** [April 23, 2015, 8:49am UTC](https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716/3 "2015-04-23T08:49:17Z")

</div>

I know it is an old question but I wanted to share a way to achieve that effect since I couldn’t find one anywhere.  
Just modify M\_Highlight in the following way:  
To outline only unoccluded parts of objects:

 ![39842-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/1/eb136116033ea7081b67c515ca0a86dc71770bc9.png)

To outline only occluded parts of an object just switch the inputs of the if node (A\>=B and A).

What it dose is the following:  
When we want to draw an outline we compare the depth value of the custom depth buffer and the depth value of the buffer at that uv.  
If the value of the depth buffer is less then the value of the custom depth buffer at that uv then it means that that uv is occluded and we discard the outline draw at that uv coordinate.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b41c45bd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b41c45bd](https://forums.unrealengine.com/u/anonymous_user_b41c45bd)\
**Post date:** [June 2, 2015, 8:20am UTC](https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716/4 "2015-06-02T08:20:28Z")

</div>

I cannot thank you enough!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d01016e4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d01016e4](https://forums.unrealengine.com/u/anonymous_user_d01016e4)\
**Post date:** [September 27, 2016, 10:11pm UTC](https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716/5 "2016-09-27T22:11:46Z")

</div>

Thanks so much ! When u change the upper SceneTexture:SceneColor to SceneTexture:PostProccessInput0 then it works with UDK 4.13 too.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_ce85cb9f1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_ce85cb9f1](https://forums.unrealengine.com/u/anonymous_user_ce85cb9f1)\
**Post date:** [January 2, 2019, 5:10am UTC](https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716/6 "2019-01-02T05:10:39Z")

</div>

Dude! It’s been years… but THANK YOU!!! hahaha

---

<div class="post-metadata">

**Author:** ![artakmes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@artakmes](https://forums.unrealengine.com/u/artakmes)\
**Post date:** [March 11, 2022, 6:38pm UTC](https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716/7 "2022-03-11T18:38:46Z")

</div>

Not working on 4.27 for me:(

---

<div class="post-metadata">

**Author:** ![VelikyPanda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/velikypanda/32/1008648_2.png) [@VelikyPanda](https://forums.unrealengine.com/u/VelikyPanda)\
**Post date:** [October 2, 2022, 11:46pm UTC](https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716/8 "2022-10-02T23:46:18Z")

</div>

I was also in search of a fix. Check out this blog, it has everything you need and also downloadable material:

[Outline effect (Part 3) – Parallelcube](https://www.parallelcube.com/2018/12/18/outline-effect-part-3/)

Don’t forget to turn this on **Project Settings** \> Rendering \> Postprocessing \> Custom-Depth Stencil Pass \> Enabled With Stencil.

**Otherwise, the material will not work!**
