Author Topic: Issue about NGUI GrayScale!  (Read 2466 times)

xiaoniaojjj

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Issue about NGUI GrayScale!
« 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Issue about NGUI GrayScale!
« Reply #1 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