prevent artifacts in packed normal maps

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!

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!

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.

1 Like

That worked perfectly, thank you so much!