Hello, fellow devs! My first post here. I decided to bring this issue to the forum because I didn’t manage to find any other thread discussing anything like this.
I have a problem regarding materials and colour masking.
Recently I came up with the idea of using non-basic colours to package masks within a texture (like yellow, cyan and magenta). I am working on a model which requires several of them and I didn’t want to have more than a single material applied to it. So I started wondering if I could package more than three masks —four if you consider alpha— inside one texture. The point is that I should use some channel overlapping trickery to differentiate all the colours.
Finally I ended up creating a very simple texture with three coloured dots on a black background, being these pure red, yellow and green:
As you can see, we are only working with two basic colours now just for the sake of simplicity. If we took off the red and green channels, we would see:
-Firstly, two white dots at left and center, representing the red channel.
-Secondly, other two white dots at center and right, representing the green channel.
Both channels overlap at center, giving us yellow. So my idea was to convert the green channel to the red (or first) channel of a vector by appending it sequentially two zeros and then subtracting it to the “real” red channel in order to leave us only with the dot at the left. That, I thought, should cause the center dot to become black (one minus one, red “minus” red) and the right dot to become black too (technically its area would contain negative values, but since their colour representation is clamped in the range 0-1 they wouldn’t go beyond pure black).
The thing is… this didn’t work out as intended!
Do you see the preview of the Subtract node? Where the hell did that light blue come from?? And why does this method not work? I think the most confusing part of it is that it seems correct until that very Subtract node: both Append previews show the expected green-to-red dots. My only guess is that blue comes from how Unreal works with channels “under the hood”; maybe the colour conversion has more to it than I thought.
Some insight on this issue?
Thanks for reading!,
.