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
    }
    }
}

效果:
這裏寫圖片描述
ref:
https://dexint.wordpress.com/2015/02/03/awkward-but-a-cheaper-option-instead-of-hue-shift-shader/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章