Multiple Channel Use in Texture Sample [Exposed in Instances]

Hi everyone,

I’m currently in the process of creating some decal sheets, and was wondering if there was any way to prepare it in a way that I could potentially use all 4 texture channels (R, G, B + A) all feeding into one base colour and alpha. I’ve got this working with 2 texture samples currently using StaticSwitchParameters, but short of using some really finicky logic I don’t really want to have a nest of parameters that other people may not be able to read so well.

Basically the setup I’m looking for is…

A single 32-bit TGA file with various texture sheets (each sheet is also being used as the alpha):
R: Sheet 01
G: Sheet 02
B Sheet 03

I would like to pop these individual channels into some sort of user specified selection where either R, G, B or A can be selected to be fed into the opacity and base colour options so these can be used independently in material instances, without someone having to work around true/false logic.

As previously stated, I have this working with 2 channels already but it is a true/false parameter as opposed to something that can just be selected by the end user.

Any help or guidance you guys can provide on this would be greatly appreciated!

  • Ant

4.19 added a new material node that should help here, the Channel Mask Parameter. Just realized this didn’t give an visual example in the release notes, but it’s something like the following:

Note how the mask channel value is set to green, so it pulls the matching data (in this case the quads containing data in the green channel).
Internally it’s just a wrapper for a vector parameter, so you can swap it at runtime or in an instance without creating a new permutation:

If you don’t want to update engine version, you can do the same thing with a vector parameter going into a dot product, just set the vector to the color of the channel you want to extract. This was introduced primarily to help with material layers where masks and blends are reused and we need to avoid compiling a separate shader for every variation.

Hey! Thanks for the reply.

Yeah, we’re not currently able to upgrade to 4.19 so what you suggested at the end there might be the better option.

This should make things a lot less complicated for our other artists, so thanks again!

This has led to another problem I’m finding with Mesh Decals (of which I’m sure you’re fully aware) - Mesh decal visibility is clipping through other meshes when using the deferred decal shader type and unfortunately there’s no way to resolve this short of using a translucent material type for mesh decals instead. That’s fine, but do you know if there’s a way to have a translucent material not be super bright even in shadows without simply reducing its opacity?

If I could figure that out, I’m sure we could stick with separate master materials for mesh decals and deferred decals as the limitations of each don’t cover both meshes and decal options.

Many thanks again!

Make a regular Mask node, right click it, Convert to Parameter. This is less expensive than the Channel Mask Parameter node.

Alternatively, if you don’t want to create more shaders to compile, you can append the RGB and A of the texture sample, multiply it by an RGBA Vector parameter, and put them through the V4 slot of an AddComponents function.