Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: xiaoniaojjj on May 12, 2014, 08:07:08 AM

Title: Issue about NGUI GrayScale!
Post by: xiaoniaojjj on May 12, 2014, 08:07:08 AM
I try to do the GrayScaleEffect in NGUI,I change the Shader(Transparent Colored),
Old Code:
fixed4 frag (v2f i) : COLOR 

    fixed4 col = tex2D(_MainTex, i.texcoord) * i.color; 
    return col; 
}
New Code;
fixed4 frag (v2f i) : COLOR 

    fixed4 col;   
    if (i.color.r < 0.001)   
    { 
        col = tex2D(_MainTex, i.texcoord);   
        float grey = dot(col.rgb, float3(0.299, 0.587, 0.114));   
        col.rgb = float3(grey, grey, grey);   
    } 
    else   
    {   
        col = tex2D(_MainTex, i.texcoord) * i.color;   
    }   
    return col;   


It work fine from 0.jpg to 1.jpg , see the picture
But it woule be some error 3.jpg when the gameobjct is child of UIScrollView also use soft clip of UIpanel.
Could you help me to do the Gray Effect i want?
Title: Re: Issue about NGUI GrayScale!
Post by: ArenMook on May 12, 2014, 04:53:50 PM
Built-in shaders are just that -- shaders. There isn't just one shader. There are several.

Unlit - Transparent Colored
Unlit - Transparent Colored 1
Unlit - Transparent Colored 2
Unlit - Transparent Colored 3