Download

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:
0ff364b5b88855664f7313133d460b03a8299a22.jpeg

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: http://beesbuzz.biz/code/hsv_color_transforms.php

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