Amplifying your potential.

Color Replacer

Node-based Shader Editor
2 posts • Page 1 of 1

Color Replacer

Postby savvamadar » Fri Jul 06, 2018 8:36 pm

I'm trying to make a shader that takes a color as an input, finds all its occurrences in a texture, and makes a mask out of it.

I have something that seems to work in editor, it makes the selected color black, and then using "Compare with Range" (RangeMin=(0,0,0,255), RangeMax=(1,1,1,255)) , because for some reason the color "black" being returned from the math operations isn't (0,0,0) but (1,0,1), I can make everything that isn't in that range black and make everything that is in that range white. So It seems to me like my masking logic should work. But I get very odd results in practice:


Without Replacing Color:

Replacing Color Red with Blue: - Works great! All areas that aren't that color should be black.

Like I said works like I expect it to. Now using the
mask we got we can invert it and multiply it by the input texture so that the areas that haven't been replaced aren't just black:

Replacing color but then using inverted mask to add back unchanged colors:

Why is there leaking?? Shouldn't my mask consists of only pure whites and pure blacks?
Does anyone know how to fix this/ have an alternative for color replacement?

After tinkering a bit more this yields "not terrible" results. Had to disable compression on the texture:
Shader: - Gray Scale is Classic old school.

The reason I say it's not terrible is because I'm checking the UV maps of the book and color that I am replacing appears on top of the book too. However that is not being replaced.

I'm closer but there's still some sort of leaking happening...

Somehow Compare With Range is returning a color that isn't white or black:

Posts: 1
Joined: Fri Jul 06, 2018 8:08 pm

Re: Color Replacer

Postby Amplify_Borba » Mon Jul 09, 2018 10:45 am

Hey there!

Thank you for sharing your developments with the community, we apologize that we couldn't get back to you sooner on this.

Please don't hesitate to let us know if you have any further questions or come across any issues.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Posts: 1089
Joined: Mon Jul 24, 2017 9:50 am

2 posts • Page 1 of 1

Return to Amplify Shader Editor

Who is online

Users browsing this forum: Google [Bot] and 1 guest