i got a texture with RGB params, and my boss want me to transform this texture with HSV params. I’ve found a RGB->HSV function, that i’ve transposed in HLSL. The main problem is that doesn’t transform a RGB texture into a HSV one, but take rgb params and output corresponding HSV params. I think I must use the Transform 2d node, but I don’t know how to specifiy my transformation.
Hope i’ve been clear :)
min_ = min( min(r, g), b );
max_ = max( max(r, g), b );
v = max_; // v
delta_ = max_ - min_;
if( max_ != 0 )
s = delta_ / max_; // s
else {
// r = g = b = 0 // s = 0, v is undefined
s = 0;
h = -1;
return;
}
if( r == max_ )
h = ( g - b ) / delta_; // between yellow & magenta
else if( g == max_ )
h = 2 + ( b - r ) / delta_; // between cyan & yellow
else
h = 4 + ( r - g ) / delta_; // between magenta & cyan
h *= 60; // degrees
if( h < 0 )
h += 360;
the HSL (Transform) node creates a matrix which can manipulate parameters like hue, saturation and lightness on any shader which multiplies rgb values with this matrix.