How to blend between two materials

Hi I have a scene where I would like to blend between two different material using a time line. However I’m not sure how to do this. Anyone got any recommendation on the best practice. I was trying in the material however it could not work out the blend function.

Thanks in advance.

I don’t think you can blend between two materials per se, but you can blend between two different things within one material.

You can feed whatever you want into Lerp A and B, any complex thing. And then just change the Alpha parameter with your timeline.

Hi, personally, I use the node : BlendMaterialAttributes you just need to use the same attributes for the two materials and your Material output.
I create materials using functions and blend the output using a parameter :

You will need a dynamic material instance as seen on the Set Scalar node:

I can’t recall if one can create a dynamic material instance out of a regular material instance. I want to say yes but not 100% sure.

Sorry for my previous answer which was out of the scope of your question. But it’s not possible to use custom data for that ? Like describe in this link ?

You can, but you have to assign it to the mesh thereafter:

Great thanks. how could I reference the value and change it in a blueprint?

Made it a scalar parameter in the material instance, but I don’t seem to be able to change it.

I tried this:

Another option is to create a dynamic material and save it to a variable; here’s a nice tutorial: WTF Is? A Dynamic Material Instance in Unreal Engine 4 - YouTube

But that would work with the setup I posted, you’d simply feed material instance as the source instead. Just to clarify what I mean, this works:

That’s primarily for instanced static meshes, no? So you can store the data on the GPU.

I’ve made a try before making another mistake in my answer :slight_smile: It’s not necessarily on instanced static meshes, the variant for instances is perInstanceCustomData which plays the same role.
So I can confirm, it’s possible to make a blueprint with a timeline and setting from it custom primitive data which can be used directly in the material.

So I can confirm, it’s possible to
make a blueprint with a timeline and
setting from it custom primitive data
which can be used directly in the
material.

@AquaFab: Could you explain why you would want to do this as opposed to using a simple dynamic parameter? What am I missing? Could you demonstrate with an example?


I fully understand the appeal (and utilise the functionality) when dealing with 40k hisms asteroids floating about; the instances use the same material but need variance, that extra data is stored on the primitive itself. That makes sense to me, who wants tens of thousands of avoidable draw calls and pushing data forth and back? I was under the impression the long requested perInstanceCustomData was (recently) introduced to do just that. No?

As described in the performance part of Storing Custom Data in a Material Per Primitive | Unreal Engine Documentation the two mechanisms are similar but using Custom Primitive Data is more efficient in terms of drawcalls if the number of objects increases.
For me, functionally, there is no difference in the result of the two workflows.

For me, functionally, there is no
difference in the result of the two
workflows.

Thanks for sharing.