RGB to HSV shader

Hi,
I am trying to do a RGB to HSV color conversion for “hue shift” and other effects.

Here is my shader code:

For some reason the output is blocky (lower resolution) and the hue does not seem to be linear.
Has someone done this successfully? Any ideas whats wrong?

Here is a link to the algorithm.

Thanks for any help

Since you are working with textures this kind of code won’t work. Operations like If, frac and similar will break the texture filtering and mipmapping and therefore introduce various artifacts. Instead you should look for color conversions / hue rotations using a transform matrix and some trigonometry: Code: Affine HSV color manipulation

That being said, UE4 already comes with a material function called HueShift.