# The best way to fade between Vector Colors?

**URL:** <https://forums.unrealengine.com/t/the-best-way-to-fade-between-vector-colors/436829>\
**Category:** Rendering\
**Tags:** Lights, Color-Grading, unreal-engine, Lighting, question\
**Created:** [November 1, 2018, 1:34pm UTC](https://forums.unrealengine.com/t/the-best-way-to-fade-between-vector-colors/436829 "2018-11-01T13:34:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dark\_Jubei](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dark\_Jubei](https://forums.unrealengine.com/u/Dark_Jubei)\
**Post date:** [November 1, 2018, 1:34pm UTC](https://forums.unrealengine.com/t/the-best-way-to-fade-between-vector-colors/436829/1 "2018-11-01T13:34:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![SavvyIndoorsman](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SavvyIndoorsman](https://forums.unrealengine.com/u/SavvyIndoorsman)\
**Post date:** [November 1, 2018, 3:19pm UTC](https://forums.unrealengine.com/t/the-best-way-to-fade-between-vector-colors/436829/2 "2018-11-01T15:19:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dark\_Jubei](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dark\_Jubei](https://forums.unrealengine.com/u/Dark_Jubei)\
**Post date:** [November 2, 2018, 9:58am UTC](https://forums.unrealengine.com/t/the-best-way-to-fade-between-vector-colors/436829/3 "2018-11-02T09:58:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![SavvyIndoorsman](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SavvyIndoorsman](https://forums.unrealengine.com/u/SavvyIndoorsman)\
**Post date:** [November 2, 2018, 7:41pm UTC](https://forums.unrealengine.com/t/the-best-way-to-fade-between-vector-colors/436829/4 "2018-11-02T19:41:18Z")

</div>

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:

 ![258350-timelineinterpolation.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/a/3/7a3b1e40db685ca2d9f4ca530ea9b3cfa7636b79.png)

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:

 ![258371-timelinegraph.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/0/650fcbe050b050051cbf0376532cf13d4136c17b.png)

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:

 ![258372-playerzaxisinterpolation.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/a/13a88555a851a1750db38d44847ea25ad4adebac.png)

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:

 ![258373-playerzaxissmoothinterpolation.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/6/b/16b9e1bdaebd6acd4bb2c2f5b618f0dee4e9d3bb.png)

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!
