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"

RGB to Hue in material

How could I convert a RGB input to a Hue value inside the material editor?

I found this formula but I have no clue how and if it is even possible in the material editor of UE4: http://stackoverflow.com/questions/23090019/fastest-formula-to-get-hue-from-rgb The required max and min are especially hard to wrap my head around.

It would be great if a full conversion from RGB to HSB would work but Hue alone would be already great.

Product Version: Not Selected
Tags:
more ▼

asked Apr 08 '15 at 02:49 PM in Using UE4

avatar image

Davision
960 105 152 203

avatar image CoryG Apr 08 '15 at 04:32 PM

It would be great to be able to get HSL off a color or texture the same way you can RGB (at least for colors since those should be low-overhead, I'd imagine textures might be a bit more costly.

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

2 answers: sort voted first

Probably not what you're looking for but I had a similar question a moment ago and this process might help with what you are trying to achieve.

The formula doesn't seem possible in the material editor - the max/min stuff is easy (there's a function for that in the editor) but the issue arises from the logical statements allowed in the material editor (the if statement specifically). You could build it with the logic in the editor but you'd end up with dozens of statements and the way it's set up gives me the distinct impresion it's meant to be compiled to a graphics processor so you would be killing performance doing HSL calculations per-pixel.

more ▼

answered Apr 08 '15 at 06:16 PM

avatar image

CoryG
123 13 20 30

avatar image Davision Apr 08 '15 at 07:28 PM

After lots of try and error I made it now work by using 7 If nodes to get the min and max values. After that replicating the formula was easy. Have not seen those max and min nodes before, not sure it using them will make it less costly. I still need the If nodes anyway I guess.

I'm using it for a post process material with the Base Color rendering pass to basically get color ids. The colors then use ramp lighting based on their id through a ramp texture which has the gradients in X and the colors in Y. With Light Vector not working with deferred rendering that is pretty much the only way to get ramp texture lighting. Hopefully the performance it uses is not too bad, still have to test that. One problem already is that Base Color nor Diffuse Color work with the Skybox and any other illuminated materials.

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

For others looking for a solution aswell I ended up having to dothe same thing and here is the network:

alt text

more ▼

answered Aug 09 '16 at 02:21 PM

avatar image

R Biesheuvel
1

avatar image Davision Aug 09 '16 at 04:20 PM

In 4.12 there is now a HSV to RGB material node, so you could just use the H part by putting a Mask R after it. I also made a working RGB to HSV node now by using the bugged parts someone of Epic left there, it anyone needs that just let me know.

avatar image soundyogi Feb 26 '17 at 04:45 PM

need it! :D

(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