x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: Not Selected
Tags:
more ▼

asked Mar 13 '15 at 10:49 AM in Rendering

avatar image

Azarus
1.9k 61 52 191

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

more ▼

answered Mar 13 '15 at 11:11 AM

avatar image

Lostra01
138 14 19 26

avatar image Azarus Mar 13 '15 at 12:33 PM

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! :)

avatar image Lostra01 Mar 13 '15 at 12:48 PM

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 :)

avatar image Lostra01 Mar 13 '15 at 01:02 PM

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

And then here's the alpha of it: alt text

And here's the pink selection saved out for a separate mask texture: alt text

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

t_diffuse.png (79.1 kB)
t_alpha.png (14.2 kB)
t_pinkmask.png (20.7 kB)
final.png (246.7 kB)
avatar image Azarus Mar 13 '15 at 01:32 PM

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

avatar image Lostra01 Mar 13 '15 at 01:35 PM

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.

avatar image marlonalves Oct 09 '15 at 05:37 PM

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?

avatar image Lostra01 Oct 14 '15 at 12:24 PM

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..

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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).

alt text

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.

alt text

Have fun and good luck!

mf_colormask.png (218.0 kB)
colormaskmat.png (217.2 kB)
more ▼

answered Apr 27 '17 at 05:09 PM

avatar image

Lostra01
138 14 19 26

avatar image Priareos Sep 22 '17 at 01:55 PM

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

avatar image LiuYang Jan 01 '19 at 01:00 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question