# Is there a way to make debug shapes exempt from postprocessing?

**URL:** <https://forums.unrealengine.com/t/is-there-a-way-to-make-debug-shapes-exempt-from-postprocessing/431534>\
**Category:** Rendering\
**Tags:** Post-Processing, outline, debug-draw, unreal-engine, Shaders, question\
**Created:** [August 13, 2018, 4:57am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-make-debug-shapes-exempt-from-postprocessing/431534 "2018-08-13T04:57:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![neofuturelabs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/neofuturelabs/32/1194562_2.png) [@neofuturelabs](https://forums.unrealengine.com/u/neofuturelabs)\
**Post date:** [August 13, 2018, 4:57am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-make-debug-shapes-exempt-from-postprocessing/431534/1 "2018-08-13T04:57:15Z")

</div>

Hi, in our game we’re using a post-process material to draw dark outlines around all the objects in the environment via a scene depth comparison with the neighboring pixels. This effect looks good on the environment, but as an unfortunate side-effect all the debug shapes (spheres, lines, cones, etc) are also getting outlines, and as a result they are often turning black and it becomes hard to tell their color or differentiate them.

Besides completely disabling the post-process material when debugging, is there a way to exclude debug shapes from being affected by the post-process material? A couple sub-optimal methods I was considering was to a) somehow change the blend mode of all debug shapes to Translucent so that they will not be affected or b) somehow give all debug shapes a specific stencil value that is explicitly ignored in our post-process material. Although I’m not sure how I would implement either of these solutions.

Also, I typically create debug shapes from C++ like this:

DrawDebugSphere(world, position, 25.0f, 6, FColor::Blue);

Here is a screenshot of how the debug shapes are turning black:

 ![250358-debuglinesissue-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/9/5/c957894460028b72c6f81e4755aa742aa805fa77.jpeg)

Any ideas?

Thanks!

---

<div class="post-metadata">

**Author:** ![zoomcns](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zoomcns](https://forums.unrealengine.com/u/zoomcns)\
**Post date:** [August 13, 2018, 8:17am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-make-debug-shapes-exempt-from-postprocessing/431534/2 "2018-08-13T08:17:55Z")

</div>

Using a Custom Depth pass might be a solution. Here is a cel shader tutorial that uses Custom Depth to make specific objects be exempt from post processing:

> **[Unreal Engine 4 Cel Shading Tutorial](https://www.raywenderlich.com/146-unreal-engine-4-cel-shading-tutorial)**
>
> In this Unreal Engine 4 tutorial, you will learn how to use post process materials to create a cel shader.

(“Isolating the Cel Shader” section)

---

<div class="post-metadata">

**Author:** ![neofuturelabs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/neofuturelabs/32/1194562_2.png) [@neofuturelabs](https://forums.unrealengine.com/u/neofuturelabs)\
**Post date:** [August 13, 2018, 8:24am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-make-debug-shapes-exempt-from-postprocessing/431534/3 "2018-08-13T08:24:43Z")

</div>

Yes, this would work if I could set the Engine built-in debug shapes to use a specific custom depth stencil value. Any idea as to how one would accomplish this?

---

<div class="post-metadata">

**Author:** ![zoomcns](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zoomcns](https://forums.unrealengine.com/u/zoomcns)\
**Post date:** [August 13, 2018, 9:06am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-make-debug-shapes-exempt-from-postprocessing/431534/4 "2018-08-13T09:06:56Z")

</div>

Oh yeah… if they can’t have a material applied then this might be harder to achieve. Sorry, I don’t have much experience with debug shapes 🙂

---

<div class="post-metadata">

**Author:** ![neofuturelabs](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/neofuturelabs/32/1194562_2.png) [@neofuturelabs](https://forums.unrealengine.com/u/neofuturelabs)\
**Post date:** [August 14, 2018, 4:45am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-make-debug-shapes-exempt-from-postprocessing/431534/5 "2018-08-14T04:45:24Z")

</div>

I found the scene proxies used for drawing the built-in debug shapes, so I almost found a way to do it:

```
#include "PrimitiveSceneProxy.h"
#include "Components/LineBatchComponent.h"
#include "Engine/World.h"

// call the below once somewhere
GetWorld()->LineBatcher->SceneProxy->SetCustomDepthStencilValue_GameThread(stencilValue);
// also call on world->PersistentLineBatcher and world->ForegroundLineBatcher if necessary

```

Unfortunately, this causes an external link error because the SetCustomDepthStencilValue\_GameThread function is missing the “ENGINE\_API” specifier and thus can’t be accessed externally.

Any ideas?
