Hello Guys,

I tried to convert a hue color in a other hue color, but dont know the math solution for it and the convert rgb to hsv vector only returns values 0 - 1 and the default node in ue4 only accepts values -1 - +1. Can please anyone help me?

Greets

Hey there!

If I understand the question correctly, you’re just looking for a way to convert a value that falls in the range [0,1] to an “equivalent” value in the range [-1,1].

If that’s the case, it’s not too bad! Simply double your initial value (putting it into the range [0,2]), and then subtract 1.

This is a bit of a simplification of the general way to do this, which involves normalizing the value and then converting it to the new range. That looks something like this:

Where “a” is the original range (bounded by aMax and aMin and containing your original value, vA) and “b” is the target range (bounded by bMax and bMin and containing the value you’re trying to get, vB).

The first part of the equation basically figures out how far along you are in the original range. It does this by subtracting the first range’s offset from zero, then dividing by the size of that range. This basically gives you a “percent” to work with. That value gets multiplied by how big the target range is, and offset by the new range’s offset.

Hope that helps!

Oh, and to clarify - the “simple” answer and the more in-depth answer are actually doing the same thing. The simple answer just relies on your value already being normalized, since it came from the range [0,1]. That gets multiplied by 2 (which is bMax - bMin) and then added to -1 (bMin).

It’s up to you which way you want to actually implement it, of course. If this is only ever going to go from the range [0,1] to the range [-1,1], then just doubling and subtracting one might be the easiest solution. But it also might be nice to have the more general function in your back pocket in case you need to convert between other ranges!

Hey,

I tried both solution with no luck

The simple I did hue mult 2 - 1 and the second (hue - 0) / (1 - 0) mult (1 - -1) + -1.

But i think i first did a wrong description of my problem. I edited this.

Sorry to hear that it didn’t help.

Have you tried these nodes?

Basically, if its alright for the color to be stored as a LinearColor struct, I think you can convert it back to HSV on-demand. If you specifically need it as an array, you could build the array from the output pins of the “RGB to HSV” node.

I’m a little wary of the “RGB to HSV (vector)” because it produces a LinearColor as its output, which has RGBA pins. While those pins could easily contain the HSVA values (I’d have to read up more to know for sure), it seems like an accident waiting to happen.

Good luck, hope that helps!