Awkward, but a cheaper option instead of hue shift shader


“Color Tint” is an usual setting appeared in shaders, which normally doing the multiply effect to textures. Multiply makes everything darker, you cannot keep a part of texture to remain white, unless the shader lets you to have the alpha channel specifying which area would be affected.


If you want to have the Ctrl+U Hue/Saturation Setting in photoshop, you might look at

All you have to do it to convert the current pixel RGB to HSV, shifting the Hue / Saturation / Brightness values with your input parameter, and then convert the HSV back to RGB for output. Notice that the shader might warn you and you have to add a line “#pragma target 3.0” which declares it is expensive!


For the project I am currently working on in my company, I tried to use a stupid approach to achieve this.

fixed4 frag (v2f i) : SV_Target
fixed4 tex = tex2D(_MainTex, i.texcoord);
return fixed4(

What I’ve done in the shader code is to calculate the delta value of R,G and B, and then use the delta value as a factor to control how the pixel is being affected by the input color. I.e., pixels with low saturation would be less affected, that’s why you see the white, grey and black area remains. The amount of calculation effort is greatly reduced.


This shader is used for creating different hair/eye color options in the project! xD

20150203_05<-original texture (I remade it for this post)



The drawback is, you might not be able to tune the exact color you want, also, maybe this shader is still quite expensive. I don’t know, at least it looks good so far.

One thought on “Awkward, but a cheaper option instead of hue shift shader

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s