原创文章如需转载请注明:转载自 脱莫柔Unity3D学习之旅 QQ群:119706192 本文链接地址: 灰度shader

废话不多说,直接图解流程:

1.原图

Unity3D 灰度shader(改编自NGUI)

2.改动shader

打开NGUI自带的shader:(Unlit - Transparent Colored)

将代码A:

fixed4 frag (v2f i) : COLOR
{
	fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
	return col;
}
改为代码B:

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); 
		col.a = i.color.a;
	}
	else  
	{  
		col = tex2D(_MainTex, i.texcoord) * i.color;  
	}  
	return col; 
}


參考自:http://blog.csdn.net/onerain88/article/details/12197277

3.用法和效果。

Unity3D 灰度shader(改编自NGUI)

Unity3D 灰度shader(改编自NGUI)


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-11-20
  • 2021-09-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案