How do I get rid of outline after subtracting 2 masks from each other?

Hi, I have 2 masks and I’m trying to subtract one from the other in the material editor, it does subtract it but I end by with an outline of the subtracted mask.

Material:

Result:

I tried changing the compression settings and the mip map settings, but they didn’t have any effect at all. The only thing that seems to reduce it is increasing the texture size from 128 to 4096, but still this does not get rid of it.

I also tried adding an outline in photoshop around the mask, but all this did was make a bigger outline in unreal.

Any Idea what is causing this or how to fix it?
Thank you.

The two masks must be absolutely 100% perfect copies of each other, AND they must be sampled using the same resolution, sampler settings, MIP map, etc. Else you will get a difference.

Also, make sure you saturate the subtraction, such that you get saturate(A-B) so that you don’t accidentally get negative values. If you do that, you can make the B part be slightly bigger than the A part (add a small fringe) to make sure all of A gets subtracted out fully.

1 Like

That’s the problem they are the same texture, so this shouldn’t be happening. And I tried also to saturate the subtraction but I still get the same problem.

You seem to be working with somewhat imprecise values. The “Ceil” node rounds the float up. Due to the texture size there are semi-colored pixels in your image. Artifacts. So your image doesn’t go from WHITE to BLACK within the next Pixel. But Rather: White - Gray - Black within 2-3 pixels.
This margin is what is causing this rim. Adjusting the values (maybe ditch the “ceil”) should fix that.
To have a faster workflow, right-click on the B input of your Subtraction or Add nodes and click “Promote to parameter”, this way this value is user exposed when creating a material instance and changes are made way faster.

1 Like