# HEX to RGB/vector3

**URL:** <https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359>\
**Category:** Blueprint\
**Tags:** Blueprints-Programming, unreal-engine, UE5-0, question\
**Created:** [September 3, 2022, 7:44am UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359 "2022-09-03T07:44:34Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![PatMag68](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PatMag68](https://forums.unrealengine.com/u/PatMag68)\
**Post date:** [September 3, 2022, 7:44am UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/1 "2022-09-03T07:44:34Z")

</div>

Is it possible to convert a string with hex color value to RGB/vector3 in Blueprint?  
I need to read hex color values from a data table and set them to dynamic material instances at runtime.

---

<div class="post-metadata">

**Author:** ![Bojann](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bojann/32/906560_2.png) [@Bojann](https://forums.unrealengine.com/u/Bojann)\
**Post date:** [September 3, 2022, 10:00am UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/2 "2022-09-03T10:00:57Z")

</div>

You can use [String to Color](https://docs.unrealengine.com/4.26/en-US/BlueprintAPI/Utilities/String/StringtoColor/), and then you can do with it what you want 🙂  
C++: `UKismetStringLibrary::Conv_StringToColor`

---

<div class="post-metadata">

**Author:** ![PatMag68](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PatMag68](https://forums.unrealengine.com/u/PatMag68)\
**Post date:** [September 3, 2022, 3:22pm UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/3 "2022-09-03T15:22:46Z")

</div>

Ok, thanks Bojann, will try. 🙂 But, there is no way without using C++?

---

<div class="post-metadata">

**Author:** ![Bojann](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bojann/32/906560_2.png) [@Bojann](https://forums.unrealengine.com/u/Bojann)\
**Post date:** [September 3, 2022, 3:47pm UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/4 "2022-09-03T15:47:33Z")

</div>

There is. Use node StringToColor in blueprints.

---

<div class="post-metadata">

**Author:** ![Madeira3d](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/madeira3d/32/902998_2.png) [@Madeira3d](https://forums.unrealengine.com/u/Madeira3d)\
**Post date:** [November 14, 2023, 11:19pm UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/5 "2023-11-14T23:19:14Z")

</div>

Hi @PatMag68 this is probably old but I was looking for the same today. A way to convert HEX (#EF9600) for example into linear color in unreal. I think the bellow solution doesn’t work because it’s not the right format, as you can see in several youtube videos about stringtocolor. If you have any other solution please share. Thanks

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [November 16, 2023, 6:37pm UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/6 "2023-11-16T18:37:00Z")

</div>

Blueprints version:

 ![HEX_PairToInt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/a/2/da264bd32e5f2fae1c433034bdffe1c641d327a4.png)

 ![HEX_Use](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/4/7/b47ca07dd375b37608e316a11ff319c5df5af79b.png)

Use this function to make color variables:  
There are TWO make color nodes:

- make color that uses FLOAT which is wrong for us
- and “make color” that is under STRUCT which uses byte YOU must add space in “make color” in search context menu!

 ![HEX_MakeColor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/b/65bb2f06cddc1df30354688a4c51ff0d904b5f6f.png)

Edit:  
forget C++ it needs yet another function inside. 😃

---

<div class="post-metadata">

**Author:** ![Madeira3d](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/madeira3d/32/902998_2.png) [@Madeira3d](https://forums.unrealengine.com/u/Madeira3d)\
**Post date:** [November 18, 2023, 12:48am UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/7 "2023-11-18T00:48:31Z")

</div>

Thank you @Nawrot

I’m currently working on my BP and delving into the RGB to Color (HEX will go after) conversion in Unreal (you know, the blue dot thing, I believe it’s linear color). However, I’ve run into a bit of a snag.

I got a tip that if you’re trying to match perceptual values from Photoshop to Unreal, a specific conversion is necessary. Without it, your sRGB values might go through a Linear to sRGB conversion, resulting in pixel complications.

Now, here’s where I could use your expertise: there’s a “Linear to Color RGBE” node, and while it seems decent, the alpha is acting up. I’m not entirely sure if this node is the solution or if there’s a better one.

Would you mind helping me figure out the math behind this? Your help would be highly appreciated.

Thanks

> **[RGB to Color Wip1 posted by Madeira3d | blueprintUE | PasteBin For Unreal Engine](https://blueprintue.com/blueprint/gvsn0ib1/#comment-2622)**
>
> No description provided

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [November 18, 2023, 1:24am UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/8 "2023-11-18T01:24:48Z")

</div>

I searched this forum and found similar problem:

> [@How to set the proper color in Color Picker?](https://forums.unrealengine.com/t/how-to-set-the-proper-color-in-color-picker/304386/14):
>
> Hi guys, I’ve coded a little function in googlescript (I think it’s javascript). It takes a string formated like this #FFFFFF, performs the appropriate conversion then outputs the corrected color in the same format. So you can feed it with a direct copy from the Photoshop color picker, then it outputs a string you can paste in the Unreal colorpicker. Here you go : function sRGBConvert(val) { val = val.toUpperCase(); var r = 0; if(val.charCodeAt(1) \> 60) r += (10 + val.charCodeAt(1)…

And last part of last post:

> [@How to set the proper color in Color Picker?](https://forums.unrealengine.com/t/how-to-set-the-proper-color-in-color-picker/304386/14):
>
> ```auto
> function FixValue(val)
> {
> if(val >= 0.04045)
> val = Math.pow((val + 0.055) / 1.055, 2.4);
> else
> val = val / 12.92;
>   
> return val;
> 
> ```

If this is correct calculation for matching photoshop colors. Cod this as pure function in BP, and multiply RGB color values by result from it.

That power function has 2.4 so that may be usual gamma correction.

However if conversion is not linear you need to find formula or get somebody who can spot color differences (some pro artist).

ps.  
I think this formula is accurate, there is post on stackoverflow explaining it with this same formula.

> <https://stackoverflow.com/questions/12524623/what-are-the-practical-differences-when-working-with-colors-in-a-linear-vs-a-no/12894053#12894053>

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [November 18, 2023, 1:42am UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/9 "2023-11-18T01:42:40Z")

</div>

here are two functions to convert sRGB to linear and back:

```auto
UFUNCTION(BlueprintPure, Category = "Color Conversion")
static float sRGBToLinear(float Value)
{
    if (Value >= 0.04045f)
    {
        return FMath::Pow((Value + 0.055f) / 1.055f, 2.4f);
    }
    else
    {
        return Value / 12.92f;
    }
}

```

and opposite:

```auto
UFUNCTION(BlueprintPure, Category = "Color Conversion")
static float LinearToSRGB(float LinearValue)
{
    const float Gamma = 2.2f;
    return FMath::Clamp(FMath::Pow(LinearValue, 1.0f / Gamma), 0.0f, 1.0f);
}

```

Those are static so should be placed in C++ blueprint function library. Or just make them in BPs.

---

<div class="post-metadata">

**Author:** ![Madeira3d](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/madeira3d/32/902998_2.png) [@Madeira3d](https://forums.unrealengine.com/u/Madeira3d)\
**Post date:** [November 19, 2023, 1:02pm UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/10 "2023-11-19T13:02:15Z")

</div>

Thanks, C++ is out of my skills but I will try to ask for help.

It’s confusing because the advice I got was to convert from srgb to linear in unreal and that I could use some of the existing functions for that.

Thanks

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [November 19, 2023, 4:48pm UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/11 "2023-11-19T16:48:33Z")

</div>

C++ has both formulas right there, just make same calculations in blueprints.

---

<div class="post-metadata">

**Author:** ![Madeira3d](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/madeira3d/32/902998_2.png) [@Madeira3d](https://forums.unrealengine.com/u/Madeira3d)\
**Post date:** [November 19, 2023, 5:09pm UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/12 "2023-11-19T17:09:05Z")

</div>

Will try thanks.

---

<div class="post-metadata">

**Author:** ![MrSchpfmut](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrSchpfmut](https://forums.unrealengine.com/u/MrSchpfmut)\
**Post date:** [March 5, 2024, 2:15am UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/13 "2024-03-05T02:15:36Z")

</div>

Thank you for sharing this! It was driving me crazy until I realized that Make Color input pins are not RGB, but BGR

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/d/d/ddd0e9461ce57612dbce43beb9cbe342203fffa5.png)

---

<div class="post-metadata">

**Author:** ![Madeira3d](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/madeira3d/32/902998_2.png) [@Madeira3d](https://forums.unrealengine.com/u/Madeira3d)\
**Post date:** [March 13, 2024, 11:14am UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/14 "2024-03-13T11:14:12Z")

</div>

@MrSchpfmut , this is how I made mine.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/3/6/b36068f224a872345e5371cda5fb2ab280470ff0.png)

---

<div class="post-metadata">

**Author:** ![QubaXR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/qubaxr/32/471864_2.png) [@QubaXR](https://forums.unrealengine.com/u/QubaXR)\
**Post date:** [September 26, 2024, 10:17pm UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/15 "2024-09-26T22:17:18Z")

</div>

Such a great, in depth response and solution. Thank you very much! Using it in my project now to convert .json palettes from Lospec into Unreal-usable format.

---

<div class="post-metadata">

**Author:** ![Suundumused](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/suundumused/32/599389_2.png) [@Suundumused](https://forums.unrealengine.com/u/Suundumused)\
**Post date:** [April 12, 2025, 10:04pm UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/16 "2025-04-12T22:04:28Z")

</div>

Not working

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [April 13, 2025, 8:39am UTC](https://forums.unrealengine.com/t/hex-to-rgb-vector3/640359/17 "2025-04-13T08:39:11Z")

</div>

If i remember correctly its because hex to int counts in reverse ie from last pair to first or something like that, which flips order. So wires in bluewprint would cross somewhere else anyway.
