Problem:
when trying to use component mask, it returns masked channel, however in many cases unreal material still thinks is it whole RGBA texture, but with masked channels. Which makes problems in some materials.
So today i finally got tired of this and i made tiny HLSL code/custom node, that i think is worth sharing:
- really simple custom hlsl code"
int ch = clamp((int)ChannelIndex, 0, 3);
if (ch == 0) return MaskRGBA.r;
if (ch == 1) return MaskRGBA.g;
if (ch == 2) return MaskRGBA.b;
if (ch == 3) return MaskRGBA.a;
return MaskRGBA.r;
-
settings in custom node:
make sure you have input parameters spelled exactly like they are inside code.
-
custom node inside function
-
and how you use it in materials: