The best way to fade between Vector Colors?

Hi,

I need to fade between two or more differently light colours, is there a way to pre-set the vectors parameters and then fade between the two. I can do this using material collections parameters and lerps when it comes to a material, but i cant figure out the best way to do that when it comes to light colours.

For example, if i have two linear color variables, is there a way to fade between those two?

Blueprint scripting provides a Lerp node that is practically identical to the Lerp node found in the material graph. When attempting to directly transition from one linear color to another, there’s no simpler way than to use a Lerp.

This will, however, produce a linear transition (that’s the L in lerp — linear interpolation) which isn’t always the desired result. (Note that the use of the adjective ‘linear’ in ‘linear color’ has nothing to do with the linear nature of Lerp.)

Anyway, if you need the color transition to be a bit smoother, i.e. non-linear, you’ll have to get a bit creative since there’s not a built-in node that does non-linear interpolation directly on color values. One solution is to first smooth the alpha (a float value) by using, for example, a FInterp Ease in Out node, which you can then feed into a Lerp (linear color) node. You can then control the smoothness by adjusting the exponent parameter.

That’s just one approach. There’s probably a dozen different ways to transition from one color to another in Blueprint using combinations of lerp, the various float interpolation functions, the CInterpTo node, etc. You’ll have to give some thought to which techniques work best for your case, because there’s no generic “best way” for every situation.

Hey! Thanks for that, its very helpful, quick question about the ease in out node. Is that automatic? or do i need a timeline or something to set the exponent?

It’s not exactly automatic, but it’s really easy. But you probably wouldn’t need to use that and a Timeline at the same time. Let me show you what I mean.

Using a Timeline node, you can achieve a nice, easy, trigger-able transition. Here’s how you might set that up:

Just create a track in the timeline that spits out a value between 0 and 1, and use that as your alpha input for the Lerp node. Bonus: if you make your timeline keys use cubic interpolation, you’ll get a nice smooth (non-linear) transition without any extra setup.

Here’s what it looks like when you use cubic-interpolation in your timeline track:

If a Timeline node doesn’t work for your situation — say you need two colors to always be blending, rather than transitioning only when triggered — there are plenty of other possibilities. You can use any imaginable technique to feed the Lerp node’s alpha parameter, as long as you’re feeding in a value between 0 and 1.

Here’s an example of using the player’s current “altitude” (Z-axis location) to blend between two colors, updated every tick:

In that example, the color look more like ColorOne when the player is closer to the ground, and more like ColorTwo when the player is closer to the value specified by the MaxTransitionAltitude variable.

Finally, here’s an example of how to use the ease-in-out node to “smooth out” the curve of the blend based on the player’s Z-axis position:

You actually might not need to ease your alpha values, depending on what you’re doing and what you think looks best. But that’s how it can be done.

Hope that helps clear things up!