Best way to mix shadergraph materials on sprite?

Hi guys, I’ aware that you can add multiple materials to one sprite through the script, the materials are been add correctly but the problem is that each material have its own sprite as output, not 100% if that is the correct terminology but I mean this:

5094221--501971--upload_2019-10-22_14-18-7.png

so only the last applied material is visible even when all of them are being assigned to the object, I guess that the last material overlaps everything else before it.

this is my current code

5094221--501980--upload_2019-10-22_14-23-0.png

the problem is that I have a lot of materials for different effects for example the classics:

-burning.
-poisoned.
-electrified.

but I also have materials that apply different clothes and weapon colors, they all work perfectly by itself but after a day trying I can’t see a way to blend them all together and make all the changes visible at the same time.

Could someone give me a guide of how to achieve it? I assume that is a pretty common situation in google I only see instructions about how to add all the materials but not how to display them all

You cannot “mix” two materials in the sense that you tell Unity to “mix material A and B”. Unity does have Material.Lerp (Unity - Scripting API: Material.Lerp). It blends the color and float values, but doesn’t crossfade/blend your textures in any way.

Depending on how many items you have on the screen, you could fake the cross-fade by having two elements that fade in and fade out at the same time.

One way might be to create a shader/shader graph that contains the features that you need for all the different states that you want your material to have. Then change those material parameters based on the different states like your burning, poisoned and so on. But this way you still run into the same texture blending case.

Of course you can work around this with some design choices so that you don’t directly blend from from a state with full texture A to a state with texture B. Instead, go from texture A to zero texture A visible, then change texture and fade the texture B in. But that’s all up to you how you want design your game/effects.

P.S. I wouldn’t mix effect states and clothing (and all the other animation). I’d keep them separate from the character look. You could also consider splitting the effects to separate “layer” that you just overlay on top of the sprite. But all that depends a lot on your art style, aesthetics and so on.

thanks for the advices Olmi, so far I created subgraphs with the states and added a boolean that turn it on and off , so if true the current texture goes through the “burning” node (subgraph) and the burning effect is applied, I would prefer something more “automatic” but as you point there doesn’t seem to be a way