# prevent artifacts in packed normal maps

**URL:** <https://forums.unrealengine.com/t/prevent-artifacts-in-packed-normal-maps/407501>\
**Category:** Rendering\
**Tags:** unreal-engine, UE4, question, texture-channel\
**Created:** [October 20, 2017, 12:24pm UTC](https://forums.unrealengine.com/t/prevent-artifacts-in-packed-normal-maps/407501 "2017-10-20T12:24:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fozwroth](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fozwroth](https://forums.unrealengine.com/u/Fozwroth)\
**Post date:** [October 20, 2017, 12:24pm UTC](https://forums.unrealengine.com/t/prevent-artifacts-in-packed-normal-maps/407501/1 "2017-10-20T12:24:03Z")

</div>

Hi there!

I’ve been using channel packed normal maps in UE4 for quite some time now and its working pretty well except some artifacts that occurs. Usually it doesn’t impact the end result but in some cases it can be prominent so I’m wondering if anyone has some input to my current setup so it can be refined a bit more.

So my current setup is using Bc7 Normal maps with alpha in linear space. Then inside my transform function I bring it back into the correct space and add in a blue channel then normalize (see attached image) This works great except the mentioned artifacting that can occur. I am aware that doing normal maps this way will mess a little with the precision but for me it is worth that sacrifice if I can utilize my maps to the fullest. This essentially cuts down all my tiled materials to 2 samples.

Could anything be done to prevent the black spots from appearing in the normal pass? Any advice would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![Deathrey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deathrey](https://forums.unrealengine.com/u/Deathrey)\
**Post date:** [October 20, 2017, 12:53pm UTC](https://forums.unrealengine.com/t/prevent-artifacts-in-packed-normal-maps/407501/2 "2017-10-20T12:53:58Z")

</div>

Sir, the black spots are caused by NANs, when retrieving square root from negative value me thinks.

Use a safe unpack, as it is implemented in the engine. Either use a custom node, calling UnpackNormalMap(), or look up how it is implemented in Common.USH shader file, and re-create the same with material graph.

---

<div class="post-metadata">

**Author:** ![Fozwroth](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fozwroth](https://forums.unrealengine.com/u/Fozwroth)\
**Post date:** [October 20, 2017, 1:29pm UTC](https://forums.unrealengine.com/t/prevent-artifacts-in-packed-normal-maps/407501/3 "2017-10-20T13:29:26Z")

</div>

I see! I’m having a bit of trouble getting the custom node to work, you don’t happen to have any examples to point me to? The existing unpack function doesn’t seem to take texture inputs as it is so might need some re-work. Good to know what is causing it though so thanks!

---

<div class="post-metadata">

**Author:** ![Deathrey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deathrey](https://forums.unrealengine.com/u/Deathrey)\
**Post date:** [October 20, 2017, 2:18pm UTC](https://forums.unrealengine.com/t/prevent-artifacts-in-packed-normal-maps/407501/4 "2017-10-20T14:18:51Z")

</div>

![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/2/1/b2126a548e749faf5a4ed5a894bfb1895f2702fe.png)

---

<div class="post-metadata">

**Author:** ![Fozwroth](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fozwroth](https://forums.unrealengine.com/u/Fozwroth)\
**Post date:** [October 21, 2017, 8:03am UTC](https://forums.unrealengine.com/t/prevent-artifacts-in-packed-normal-maps/407501/5 "2017-10-21T08:03:19Z")

</div>

That worked perfectly, thank you so much!
