How to fade out a material?

Hi there,

Can anyone tell me how to simply fade out a material? It should stay for 1 second, then fade out completely during the next 2.5 seconds.

I tried to use time as a input, connect it to the alpha of linear interpolation, A to the sample texture’s opacity (is this simply the alpha value?) and B to 0. I then connected the output of linear interpolation to the material’s opacity. But that doesn’t change anything.

I also couldn’t find a ‘fade-out’ node or something and couldn’t find any helpful ressources about that, just the usual shader rocket science.

Can anyone help me with that? Thanky you. :slight_smile:

Hi!

In this tutorial show how to create material and blueprint, which change opacity in this material.

Many thanks. But for some reason it’s not allowed to use a timeline inside of a function. I also tried to manipulate a scalar parameter via blueprint (had to create a dynamic material instance for this) but the parameter just keeps it’s default value instead.

Found out the problem here:

UE4 doesn’t CONVERT the material to a dynamic it just creates a new one which has to be set to the decal afterwards like this:


But there is a new problem: The reference to the last decal gets overwritten each time the graph’s event gets fired. So only the LAST created footstep will fade out.

So it would make sense to extract the fade out process into a function with a call-by-value parameter for the decal reference. But that’s not possible because UE4 doesn’t allow to use a timeline inside a function…

Do you found a way by now to fade out your decals? I’m having the same problem here.

Yes, but it’s insanely difficult:

  • Create a scalar parameter in your decal’s material and connect it to the alpha node of the material
  • Create a material instance based on this material and set it for the decal (replace the old one)
  • Create a dynamic material instance from your decal’s material and assign it to a variable in the constructor script

  • Now you can create a timeline in the blueprint with a float track and connect this to the input pin of “set scalar parameter value”


All this would be MUCH easier if UE4 just would create a dynamic material instance automatically in the background if you set a material’s parameter the first time. It not very intuitive at the moment.

Thanks. But you still have to make that for each footprint otherwise they would all fade out at once.
So each footprint needs to be in a BP, in each BP it needs to create that own material instance and then it needs to change it every tick for each.
Lots happening then for something relatively simple. Maybe when it just transfers the current game time over to the material instance instead of updating it each tick, the material could handle the fade out by subtracting the game time parameter with the material time node. Would be hard to animate any curve though but at least the every tick update wouldn’t be needed anymore.

What should I say? You’re right. :wink: Simply fading things in and out seems to be very much work in UE4 for some reason. Sames goes for outlines. Seems like rocket science to me.

In my case I made the footprint a own BP, spawned an instance for every step but kept a reference to it. When the next footstep is spawned, I call the fade-out-and-destroy-method in the former instance before overwriting the reference.

You could bypass the need for timelines altogether by doing “Time - TimeOfStep” inside of the material.

That way all you need to do is set “Time of Step” on the initial creation and then the fade can be calculated from the material itself. You would multiply/clamp to get that into a 0-1 range. In this way you can cheaply time fade a bunch of materials without paying the cost of ticking them all.

To get time matching the time in the material editor you need to use “get real time in in seconds”.

Thank you , this is a interesting option.

Unfortunately all these methods don’t really work for me because I had to alter every single material in every element slot for every mesh, every decal etc. which is just pure overkill.

And even then for some reason many materials looks completely different when I set them to translucent with opacity 1.0 and don’t change anything else (see also Why is this translucent material not opaque, if opacity = 1? - Rendering - Epic Developer Community Forums).

It would be really, really great if there was a simple fade-out/fade-in node for actors. It’s just a common operation and it’s really way, way to clunky in the the current version of UE4.

Same goes for simple outlines which are pure rocket science ATM.

I’m having this exact problem now lol. Apparently epic takes an extremely long time to fix things. It doesn’t make any sense that you need to modify materials individually to get basic effects such as transparency.

has anyone tried lerp?

1 Like