Hi,

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 :)

Thanks

{CODE(ln=>1)}void RGBtoHSV(float r: In,float g: In,float b: In,float h: Out,float s: Out,float v: Out)

{

float min_, max_, delta_;

```
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;
```

}

^