How to mask a normal map?

I’m able to mask normal textures using a Lerp and a mask texture (as shown in the screenshot) and then blending the result with another texture but I don’t know how to do that with a Normal map. Since there’s no Alpha Channel in the Normal node, I’m uncertain as to how to build that inside my material.

I would really appreciate if someone could post an example showcasing how to do so.

Masking a texture

http://puu.sh/c7jhW/1df4d671d1.png

Thanks!

You blend normals maps just like this as well, you dont need a special alpha channel. Plug your mask texture to the alpha input of a Lerp and your normal maps to A and B.

Check out the rock materials in the starter content to se examples of it.

I think he wasn’t asking how to blend normal maps, he was asking how to MASK them which is slightly different. IE he only wants the normal map to show up in the masked area. The confusion is that he thought he was masking a texture using the LERP node which is incorrect.

Linear Interpolate isn’t typically for masking, it’s for blending. You plug one texture into A, another into B and then the alpha controls the blend strength. In the OP’s example he’s using it incorrectly.

To mask a texture, you simply multiply the texture by an alpha where white will show the texture and black will hide it. Here’s an example setup where I also blend in another texture to fill in the masked area:

Though you could just use a LERP if you want to blend two textures together based on an alpha mask, it’s not quite the same thing. For example, you might want to simply remove the texture information without blending in another texture in which case a Multiply is easier.

I’m not exactly sure how to mask a normal but when I figure it out I’ll post here.

2 Likes

So from what I can figure the easiest way to do this is using a lerp but if you want the masked area to have no normal, then you need to create a “Blank” normal texture. Inside your image editor (Photoshop for example) create a texture of any resolution (I chose 64x64) and fill it with RGB 128,128,255:

Then use a lerp node with your alpha texture to mask out the normal information in the specified area.

1 Like

I stumbled into this thread while looking for something else, but I wanted to add that you don’t need to make a “blank” normal texture and sample it, as sampling this is overally expensive for no good reason, instead you can simply make a color node or a vector3 node, and set it to be blue, it should be exactly (0,0,1).

This is because normal values are ranged between -1 and 1, but since you can’t store negative values in images, when saving normal maps, the normal values are normalized into the 0-1 range, unreal automatically tries to detect normal maps and automatically remaps them to -1 to 1 (this is done simply with the equation N*2-1) so a value of (0,0,1) means that the normal vector is just on the z axis, meaning it’s flat.

You do not need an alpha on the normal map itself. The mask is a separate texture. Put the mask into the Alpha of a Lerp, and put the two normal maps into A and B, exactly like a color mask. The Lerp node will blend the normal vectors, not a color, as long as both inputs are Normal type.

If the blend looks wrong, the mask is probably in the wrong color space. Set the mask texture to a plain mask: compression None or BC4, no sRGB, and plug it in raw. Do not run the mask through a color node first. Also set the Lerp output type to Normal so it does not get treated as a color and then renormalized incorrectly. After the blend, use a Normal from Flat or a Transform Vector node if the result is inverted or too strong.

A second way, when you want a hard edge instead of a soft lerp, is to use a step on the mask and then a select. Branch or a custom node on the mask above a threshold, then pick between the two normals. The starter content rock materials do the soft version with Lerp (mask to Alpha, normals to A and B). If your normals are already in tangent space, leave them that way. Do not convert to world space before the lerp, or the blend will not match the color mask you already have.