Color Replacer

Node-based Shader Editor

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:

Editor: https://imgur.com/a/qm5v6Md

Without Replacing Color: https://imgur.com/a/dcrmMfW

Replacing Color Red with Blue: https://imgur.com/a/uIrhtSA - 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: https://imgur.com/a/efu6K9c

Replacing color but then using inverted mask to add back unchanged colors: https://imgur.com/a/RqSjNeL

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: https://i.imgur.com/xLSi65B.png - Gray Scale is Classic old school.
Result: https://i.imgur.com/2GIfB8W.png

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...
Shader: https://imgur.com/a/s430tw7
Result: https://imgur.com/hcKhp3I

Somehow Compare With Range is returning a color that isn't white or black: https://i.imgur.com/Gf5kd93.png
______________________________________________________________________________________________________

Goteeeeeee: https://i.imgur.com/FPAGcgJ.png
savvamadar
 
Posts: 2
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
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: Bing [Bot] and 58 guests