Help with materials :))

Hello, I am confused a bit and would like clarification and maybe advice how to proceed.

So I have been making some voxel art assets in in MagicaVoxel and using VoxCleaner addon for blender to clean them up a bit and it gives me texture map that is made from vox colors of imported assets from .vox file.

I tried using that texture that I get from cleaning as an ID map to paste my own textures I painted in Asprite on top and also tint in MI specific regions the way I please (It’s UE5). and that works I made myself some giant mushrooms that are waaay bigger then character and since I use 16x16 textures on them they don’t look like out of place and actually fit the scene especially since floor itself is being generated in engine as voxel island (on dirt I have dirt textures on grass I have grass textures etc). I have made a new asset pack that I wanted to place all over that island and make some POIs now that asset pack has way more variation. Some assets are stone, some are wood and it has way more colors for IDs then mushrooms themselves.

I am wondering weather it’s possible to make something like Parent material where I will be able to say “this asset pack needs to use 3, or more textures” and also it has different amount of those ID colors. I say parent material cuz my mushrooms have WPO for breathing and I don’t want stone to breath. I saw you can kinda solve that with MF but I still dont know how I would tell engine that some asset packs should have different amounts of ID’s colors or different amount of textures that they would need.

Is this even a correct approach or should I just make master material for each asset pack and just forget about this nonsense?

One parent can serve every pack if the textures and ID colors come in through parameters, with each pack getting a child instance that overrides them. A material instance keeps its own scalar and texture parameter values under a parent material, so packs with different texture counts or ID colors do not need a copied graph.

Welcome to the community @Mirko_Gligic !

First off, that workflow with MagicaVoxel, VoxCleaner and 16x16 Aseprite textures sounds really cool, keeping that consistent voxel texel density on giant assets is always a great touch.

Continuing from the point that @ImYourBeast made, sounds right in suggesting that having a single Master Material with child Material Instances which then modify values means that you do not need to duplicate material graphs.
However, I believe that we can further this by specifically explaining how to inform the engine of the differing numbers of textures which should be applied to different texture packs and also how to stop your stone objects from moving (morphing) but still allow World Position Offset on your mushrooms.

Could you share a couple of quick details?

  • How are you currently separating the ID colors in your graph?
    Are you using something like an If node, Distance + Step or a ColorMask Material Function to isolate each color from your VoxCleaner texture?

  • Roughly how many ID colors/textures does your largest asset pack need (e.g, around 4–6 or closer to 15+)?

  • Which exact version of UE5 are you working in?

In the meantime, here some tests to handle variable texture counts and toggleable effects inside a single Parent Material.

Toggling the Mushroom “Breathing”

Since you don’t want your stones or wood breathing like your mushrooms, I would put a StaticSwitchParameter right before your World Position Offset pin on the Main Material Node

  • Create a StaticSwitchParameter node and name it something like “Enable_Breathing_WPO”.

  • Connect your breathing WPO math into the True input and leave the False input empty (or plug in a “0” constant)

  • In your Material Instances for the stones and wood, leave “Enable_Breathing_WPO” unchecked. Because it is a static switch, Unreal compiles out that branch for those instances so your stones won’t move or pay any extra shader instruction cost.

Handling Variable Numbers of IDs and Textures

Parameters alone let you swap which texture or ID color is used while Material Functions paired with StaticSwitchParameters let you control how many layers are active per Material Instance

  • Package your ID-color isolation and texture-blending logic into a reusable Material Function using FunctionInput nodes (for the ID Color, Texture Sample and Previous Layer Color)

  • In your Parent Material, chain together the maximum number of these Material Function blocks your biggest asset pack needs (for example, 6 or 8 blocks)

  • Add a StaticSwitchParameter (e.g, “Enable_Layer_04”, “Enable_Layer_05”, etc) on the extra blocks, defaulting to “False” so they simply pass the previous color straight through.
    When you create a Material Instance for a simpler asset pack that only needs 3 textures, you just leave the extra layer switches unchecked.

Epic Documentation: Material Instances · Material Functions · Material Expressions Reference

Let me know how you’re currently reading those ID colors (or feel free to drop a screenshot of your current material graph) and I’d be happy to help you structure the setup. Regards!