I cannot for the life of me work out why what I’m doing below is a problem, and I’m 99.99% sure I’ve stumbled accross an engine bug but need someone to sanity-check it for me first.
The vehicles in my game have a bunch of masks (all textures use TC_Masks compression setting), which allow me to control various emissive parameters in their materials. I use this for things like weapon muzzle glow, engine overheating etc. One of my material functions that I use is causing me headaches with colours.
This material function let’s me mask in a ‘colour’ for four different channels separately. Pretty basic right? Below it is the MF_MapRange function - which is just supposed to scale scalar values from one range to another.
However, the Map Range function seems to be confusing the Shader Compiler when used inside another material function like this, and it can’t seem to deduce the channels properly. Currently if I have this node plugged into my chain of nodes up to the emissive channel, it causes the following colour corruption:
I have to drive the emissive parameters much harder too. If I unhook MapRange from that material function, everything works as it’s supposed to - but this makes no sense? I even tried adding a Mask (R) node after the MapRange node, but that still didn’t work.
^ What it’s supposed to look like.
In short, I think the engine is unable to correctly deduce channels for colours when material functions are used inside other material functions - since I really can’t see anything I’m doing wrong here.