hue shift shader,a simple way簡単で効率的な方法


hue shift effect in Photoshop: http://forum.unity3d.com/threads/hue-saturation-brightness-contrast-shader.260649/
Shader "Craft/Simple Hue"
{
    Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB)", 2D) = "white" {}
    }

    SubShader {
    Tags {  "RenderType"="Opaque" }
    LOD 100

    Pass {
        CGPROGRAM
        #pragma vertex vert  
        #pragma fragment frag
        #pragma target 3.0
            #include "UnityCG.cginc"

        sampler2D _MainTex;
        float4  _Color;

        struct appdata {
        float4 vertex : POSITION;
        float3 texcoord : TEXCOORD0;
        };
        struct v2f {
        float4 pos : SV_POSITION;
        float2 uv : TEXCOORD0;
            };

        v2f vert(appdata v) 
        {
        v2f o;
        o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
        o.uv = v.texcoord;
        return o;
        }

        fixed4 frag(v2f i) : COLOR
        {
            float4 tex = tex2D(_MainTex, i.uv);
            return fixed4(
            tex.r-_Color.r*(2*tex.r-tex.g-tex.b),
            tex.g-_Color.g*(2*tex.g-tex.r-tex.b),
            tex.b-_Color.b*(2*tex.b-tex.r-tex.g),
            tex.a
                );
        }

        ENDCG
    }
    }
}

効果:hue shift shader, a simple way 简单高效方法_第1张图片 ref:https://dexint.wordpress.com/2015/02/03/awkward-but-a-cheaper-option-instead-of-hue-shift-shader/