+1
COMPLETADO

RGB to HSV color conversion and back?

rbanninga hace 11 años actualizado hace 9 años 10

There are some operations that work very nicely in different color spaces. Would this be a possible addition.

Respuesta

Respuesta
COMPLETADO
HSV to RGB and RGB to HSV has now been implemented in 1.18
+1
En revisión

Possibly yes! There are two possible issues though. One is that it might be abused, because there will most likely be a lot of instructions involved, especially when going from RGB->HSV. The second is that Colors are conventionally between 0 and 1 (Well, 0 and 255, etc) in most programs, but in shader code, it can go beyond that. I suppose the hue would remain the same, saturation might need to overbright as well, and value will definitely need to be.


Anyhow, if people want this, I'll implement it post-release :)

Ha indeed making more intense Hue and Saturation would give some crazy effects if it went past 0-1 range. Then again for vertex colors which are stored in more precise float values it does allow for very large color range manipulation.

I definitely want this too, I think HSV manipulation will give some nice effects. Maybe make the H value repeat, as if it was rotation (so if it's 1.1 or 5.1, it'll be same as 0.1) when converting back to RGB. Maybe allow saturation to go over 1.0 during calculations and then just clamp01 it when converting back?
I posted code node examples for this on the wiki if people need it now..
AH nice I will have to give this a spin. Thanks! This software has proven itself so many times already for me. I love it
Nice, looks like a fast algorithm!

I wonder though - how does it handle saturation? Since saturation is doing a one-minus operator, it presumes that you aren't in any HDR range in this case. Does the algorithm handle it some way?
http://en.wikipedia.org/wiki/File:HSV-RGB-comparis...
No, it's assuming LDR. Back when I was writing lots of shader nodes, I did a pretty comprehensive comparison of RGB->HSV->RGB conversions, and this was the fastest I could find. There's an alternate version on ShaderToy which IQuillez came up with that's worth considering as well; the main difference being that it produces a more continuous hue spectrum than the official math does.

https://www.shadertoy.com/view/MsS3Wc
 
A partial update - as of 1.17, there's a node called Hue, where you input a value between 0 and 1, which will output a fully saturated color in the spectrum :)
Respuesta
COMPLETADO
HSV to RGB and RGB to HSV has now been implemented in 1.18