How to mask a single color?

Hey,

I have a pink color on a texture how do i replace this color and its tones with an another color?
Also i would like to use a material instance to change the color.

Thanks.

Correct me if I am wrong, but as far as I know, there’s no simple workaround for this. You can however open any photo editor, select the pink area, and save that selection as an Alpha channel. This way you can recolour that part with any kind of color/texture.

My image had black pixels that i already replaced, so the image has transparency in use. I did this with a simple C# script. Any complicated solutions may help! :slight_smile:

I’m not talking about transparency. You can, for example, put your original texture, and your custom into A-B of a lerp node, and use the alpha channel of your original texture. If by masking you mean you already use the alpha, then you can just save the image of yours, with a White-Where-Pink and black everywhere else, and use that for lerping :slight_smile:

For example, I have a texture, wich is the following:

And then here’s the alpha of it:

And here’s the pink selection saved out for a separate mask texture:

After utilizing all of the masks/textures in the engine, this is what an example lerp combination looks like :slight_smile:

You can try to take a look at the red channel of your texture, and see if it only covers the pink part. Other than that, There’s no such node - wich I know of - what masks only one color.

Any solution to use only one texture? I have a lots of images :confused: 1000-2000
So i need a solution that can fit on multiple images without much work.

It helped me a lot too, thanks for sharing! In my case I have need to also change the color of blue, and some characters, up to 5 different colors, how would this blueprint?

You can create a lerp-ception and put lerps in lerps. For example you take the setup up there, and the lerp result doesn’t go into the base color, but into an A of another lerp, wich then with another alpha masks out what you want to. Then if you need more, you can put this lerp result to another lerp, and so on…

If anyone is still following, I know it’s been a long time, but on the forums a user named Christian Ronchi (www.chricchio.com) shared an amazing Material Function to get a mask of a single color in the material. I’ve added a tiny bit to the function, namely just the Input (Sensitivity).

The IFs are rather easy but can be annoying:

A input is always the MASK(R/G/B). B input is always the Input(Sensitivity) and Scalar (1) is always “A > B”, while Scalar (0) goes to the rest of the inputs. Adding a Sensitivity Input helps a lot, because in the main material, you can add a Scalar Parameter, and you can adjust the sensitivity of the color check in a Material Instance.

The usage is fairly easy. Just add a MaterialFunctionCall to your materal, and specify this function in the details panel in your material. Then you can add a color, a sensitivity, and a texture to cut from. The result of the function will be a black-white mask (only your colors) or if you use “1-x” then the colors cut and rest kept, as you can see on the screen here.

Have fun and good luck!

4 Likes

This is amazing! Thanks a lot for sharing. Really helped me out.

1 Like

thanks for sharing! I made a modified version based on this one but cheaper.

6 Likes

This is AMAZING! Thank you so much! This allows to have a single-texture mask with alot of variants. Far beyond the usual 4-channel packed black-and-white mask.

1 Like

Just what I quickly needed, much appreciated everyone!

Hey y’all. Just needed something like this for a project and was able to boil down the concept into a much smaller graph. The distance node is doing the heavy lifting.