x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Convert a hue color in a other hue color?

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

Product Version: UE 4.21
Tags:
more ▼

asked Apr 26 '19 at 06:47 PM in Blueprint Scripting

avatar image

Aquavogel
22 1 2 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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: alt text

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!

Bryant

equation.png (7.2 kB)
more ▼

answered Apr 26 '19 at 07:47 PM

avatar image

Bryant_PSC
31 1 2 9

avatar image Bryant_PSC Apr 26 '19 at 07:51 PM

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!

avatar image Aquavogel Apr 26 '19 at 09:14 PM

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.

avatar image Bryant_PSC Apr 29 '19 at 12:51 PM

Sorry to hear that it didn't help.

Have you tried these nodes?

RGB HSV Conversion 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!

colornodes.png (20.2 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question