Download

Creating a master material with channel switch for different texture channels

Hey all,

I’ve put together a foliage pack from various free and purchased packs (for personal use) - some grasses from this pack, other grasses and foliage from a separate pack etc. As I currently am using assets from about 5 different packs, I have a ton of master materials. I’m trying to reduce that as much as possible and have material instances for the various meshes.

For the most part I’m able to condense to a primary master material (say for all my grasses) but I’m having a problem when some packs use specific channels for Specular/AO/Roughness masks. As they each have their own set up, I need a way for the material instance to channel select from the given texture parameter, and I can’t figure out how to do it. I can set up a static bool to select say, the red or green channel, but then I can’t select the blue channel or the alpha. Ideally, I would have a 4 way switch that would take a parameter I can set in the instance to choose which channel to use for a given material attribute. I don’t need to set this dynamically, just in the instance.

Is there a way to do this?

EDIT: I realize I could literally add a unique texture parameter 4 times with each hooked up to a bool and then set 3 of them to false and one to true - but I’d like a more elegant way if possible.

Just place a Component Mask node, right click on it, then “Convert to Parameter.” Do that for each material input, so for instance 1 texture parameter for RMA/OMR/etc with 3 Component Mask parameters to roughness, metalness, and AO, or whatever you use the channels for.

Ooooh, so hook up the RGBA channel of my texture parameter to the component mask, then the output of the mask to the material attribute, then I can use the checkbox to choose the channel?

https://answers.unrealengine.com/que…ic-switch.html

Check the screenshot with the if nodes. :slight_smile:

Edit: @rosegoldslugs Solution is better, I didnt knew that this is possible to convert the component mask to a parameter. @Alwaysusa yes, exactly like that you described.

That’s great. I’m going to use the component mask. It’s exactly what I wanted just sitting there all along. I tried to figure out that static bool logic but couldn’t get past it for some reason. That screenshot seems so obvious now I look at it lol.

Anyway - great tips all round. Thank you!