# 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:** 1\
**Showing post:** 3

<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.

---

_[View the full topic](https://forums.unrealengine.com/t/disabling-custom-depth-rendering-on-certain-objects/299716)._
