I’m trying to match colors inside a Material and have trouble doing so.
For example, I want to pass a Linear Color to a Material as a parameter and inside match the colors coming from a Texture Sample with the color to replace it or overlay it with an emissive color.
To match colors, I sum up the absolute differences of all components of both colors. This will be compared to some threshold and if at or below this threshold, the texture color is seen as a match.
With my hand drawn texture it works well and I seem to be able to replace colors even with a threshold of 0 (tested with [0,0,0,0], [1,0,0,0] and [2,0,0,0] in RGB values, so veery similar color values).
The problem now is with some textures, some colors do not get matched up to a very high threshold, and when I push up that high, some colors get matched wrongly.
Why is it that for some textures colors can be very accurately matched and for some they cannot? What color values does the Texture Sample node output?
The “Sampler” setting in the Texture Sample node as well as the texture Compression and sRGB settings have an effect too… Can I somehow just read raw color value from a texture inside a material?
Thanks and cheers!