WhiteEngine-专注图形渲染与游戏引擎技术的网站

新浪微薄腾讯微薄

最新碎语:暂无碎语

您的位置:WhiteEngine-专注图形渲染与游戏引擎技术的网站 >Shader and Graph> 优化NGUI图集使用的Shader

优化NGUI图集使用的Shader

Shader "Unlit/Transparent Colored"
{
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {}
_AlphaTex ("Aphla (RGB), Alpha (A)", 2D) = "black" {}
}

SubShader
{
LOD 200

Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}

Pass
{
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Offset -1, -1
Blend SrcAlpha OneMinusSrcAlpha

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _AlphaTex;

struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};

struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};

v2f o;

v2f vert (appdata_t v)
{
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = v.texcoord;
o.color = v.color;
return o;
}

fixed4 frag (v2f IN) : COLOR
{
float4 col;  
   col.rgb = tex2D(_MainTex, IN.texcoord).rgb;  
   col.a = tex2D(_AlphaTex, IN.texcoord).a; 
   return col * IN.color;
// return tex2D(_MainTex, IN.texcoord) * IN.color;
}
ENDCG
}
}

SubShader
{
LOD 100

Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}

Pass
{
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Offset -1, -1
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
ColorMaterial AmbientAndDiffuse

SetTexture [_MainTex]
{
Combine Texture * Primary
}
}
}
}

---

转载请注明本文标题和链接:《优化NGUI图集使用的Shader

分享到:

发表评论

路人甲 表情
看不清楚?点图切换 Ctrl+Enter快速提交