How do I change a specific color within a texture?

I have a texture that has 5 colors (see below…red, blue, orange, black, white). Ideally I would like to change those colors in the material editor. I can see from the tutorials how to do this with RGBA, but, that’s too limited. In the attached texture the red and blue are actually red and blue, I can manage to change these but changing the red also changes the orange (because it has red in it). So, how can I change the orange color?

UPDATE:
I’m using Qubicle Constructor to create models. I want my models in the game to by very dynamic, think reusable meshes in an RPG. The weapon models will only have 3 colors (base, effect, extra effect). I can then make the base chrome, plastic, wood etc etc and the effects be something more dynamic to represent ammo type and some glow. But, creatures and armor will have up to 5 possibly…but no more (imagine my texture screenshots here having two more rows, but different colors). I can then use these colors in the material editor to make the game dynamic/random.

6539-liquid_gun.png

Why dont you use green instead of orange and then use the green channel as a mask and fill it with orange in the material editor?

That was going to be my next step, but, that gives me 3 colors, what about if I wanted 4 or 5? Attached is what Im doing to change the blue to purple, which works.

1 Like

You can use the alpha channel as well, that makes 4. What exactly are you trying to do with this texture? If you can tell more maybe we can think of other ways too because i cant think of and i dont know of any other way to store more information in a 4 channel texture right now.

I just added more info to my original question. I don’t want to use alpha as that would require some extra workflow in Blender or some other tool. So I currently have RGB and the black stripes. Is there not a material node “replace color” or something similar?

Did you try something like this?

With result:

The If nodes have a threshold of 0.025 but you can change this to get more or fewer mask colors in. I had problems with getting the colors right. It seems 0.5 if not equal to 128 in Photoshop. However if you select the vector3 node, the click the color in the Details panel you get a Color Picker window. If you type in the RGB hex you used to create the texture it works.

3 Likes

That worked, fantastic, thanks! Now I just need to put this into a function and get my black lines in a different channel as those are now causing problems.

Do you have any idea why the replacement doesn’t quite work up to the edge of another color on a texture? I’m replacing the red with the yellow (your stuff is in a function now).

Never mind on the color not filling up fully, double clicking the texture and changing its “Filter” to “Nearest” tightened it up! Thanks again.

Sorry for the Necro but I’d like to know how I could replicate this for changing around 7 colors? I have a character with 7 distinct solid colors and would like to change them completely but could not gain success with what was given here. Any chance ya’ll guide me the right way with what you’ve posted here?

I’m doing the same thing myself, Demoneyejin. I’m probably just going to use a variation of Dieselhead’s function and package it into a material function. Then I’ll just use N instances of that material function in the material, where N is the number of colors in my palette (in your case, 7).

Can you post here in please a screenshot of your Material Function :slight_smile:

I tried to make a material function out of it, but it doesn’t work.

Thank you! This helped me solve my issue too!