Fading Between Multiple Materials on a Single Mesh

Hi All,

Please forgive another newbie question. I have a static mesh that I want to be able to change the material on by fading from material A to material B to material C, what would be the best approach to do that? The transition would take place at specific frames on the level sequence actor.

I tried to use a layered material but I couldn’t seem to figure out how to use a constant or a scalar parameter to drive the alpha of the materials to make them appear and disappear. I also understand that the layered material approach is computationally expensive so maybe it’s not the best approach for realtime use. I tried another approach for switching materials but it was a hard transition, no fade. Currently I am using 3 identical static meshes (simple planes), each with their own material, then I animate the opacity of each material to fade them in and out.

Any help would be greatly appreciated, thanks in advance.

That is a far worse idea then having it all contained in one material. With that solution, you’ll be able to see through the mesh, and there will be terrible Z-fighting.

It’s an odd thing to try to make, but I would try to aim for having it all contained in one material.
You’ll need to use my favorite material node of all time: Lerp (Linear Interpolate). Lerp gives a linear blend between two Scalars, V2s, V3s, or V4s. It’s very convenient.

Here are some examples of the usage of Lerp:

  • A = 0, B = 1, Alpha = 0.5. Result: 0.5
  • A = 5, B = 10, Alpha = 0.1. Result: 5.5
  • A = 3, B = 7, Alpha = 0. Result: 3
  • A = 3. B = 7, Alpha = 1. Result: 7

So Alpha is just the percentage that the Result will be B rather than A.

Hope this helps!

Thanks @NachoMonkey2. I have slightly offset the 3 meshes to prevent Z fighting, but I would still like to find a more elegant solution. Can you expand on the above at all? I should also mention that there are 3 materials, and that they are media elements. I am currently working with 2 video files and 1 NDI feed but eventually it could be 3 live video feeds, although at that point it would likely be an upstream switcher that would handle the switch between feeds.

I have created 3 Material Functions, each with their own attributes and I have tried feeding the first two into a Material with a MatLayerBlend_Simple and I have connected a Constant to the Alpha pin but I can’t seem to get the Top Material to display. I have also tried creating the 3 material networks inside the Material using MakeMaterialAttributes and then feed the first two into a MatLayerBlend_Simple and connect a Constant to the Alpha pin. This seems to work for two, but as soon as I add a third, by either adding another MatLayerBlend_Simple on the output of the first MatLayerBlend_Simple or by using the MatLayerBlend_TenLayerBlend, I can’t get the third Material to appear.

You’ll want to use dynamic material instances as shown on the following page:

Thanks @pookemon. It ended up being much easier than I realised. Instead of having three materials and switching between them, I used 3 textures inside one material and then user LERP to switch between them.

I’ve been searching for hours on how to do this but with two Seperate materials, I’ve got a kitchen, with worktops, flooring, cabinet doors etc… I want to trigger an event to play an animation that switches between Mat A with Mat B using some sort of mask / linear gradient. All the tutorials I’ve seen focus with having the mask set up in the material, and they are just switching between textures. my materials are much more complicated and need to be thier own seperate entity’s. it’d be way to chaotic in one material…

Any clue on how to achieve this? I want to do the animating in sequencer so when our meta human model taps the worktop, the material changes and not just a blink and swap, somthing that transitions across.

In the end i decided to do what a lot of people have suggested always have a in-between material, a ‘default’ to revert back to, that way you can got from A > B > A > C > A > D >A (A being the default).

in my head though sounds like there should be a way easier method to transition from one material to another to another etc… without it all being housed within one massive mat.