NGUIDiscussion group: 333417608
Demand
Click on the monster portrait, portrait. (restrictions: highlight value only)
Method
Copy the Unlit - Transparent Colored.shader, modify(Finally, a complete shader)
Shader "Unlit/Transparent Colored"
Instead of
Shader "Unlit/Transparent Colored (Bright)"
2,
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {}
}
Instead of
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {}
_Bright("Brightness", Float) = 2
}
3,
sampler2D _MainTex;
float4 _MainTex_ST;
Instead of
sampler2D _MainTex;
float4 _MainTex_ST;
float _Bright;
4,
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
return col;
}
Instead of
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
col.rgb = _Bright * col.rgb;
return col;
}
5, Save the name for the Unlit - Transparent Colored (Bright).shader
Create a new Atlas
ReplicationAtlas and Material, pictured above is Wooden Atlas 1 (two is respectively Atlas and Material)
Material Atlas Wooden Atlas 1Designated asWooden Atlas 1
Revise the new Material
Increasing the brightness
Can be modified Brightness (Note: the modified window may not immediately display effect, need to refresh force corresponding to the Panel)
Application
The code which, when using the corresponding sprite atlas specified for the new atlas.
Effect
On the left is the highlighted icon. On the right is the ashing.
With complete Shader
Highlight
Shader "Unlit/Transparent Colored (Bright)"
{
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {}
_Bright("Brightness", Float) = 2
}
SubShader
{
LOD 100
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Offset -1, -1
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Bright;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.color = v.color;
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
col.rgb = _Bright * col.rgb;
return col;
}
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
AlphaTest Greater .01
Blend SrcAlpha OneMinusSrcAlpha
ColorMaterial AmbientAndDiffuse
SetTexture [_MainTex]
{
Combine Texture * Primary
}
}
}
}
Ashing
Shader "Unlit/Transparent Colored (Gray)"
{
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {}
}
SubShader
{
LOD 100
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Offset -1, -1
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.color = v.color;
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord) * i.color;
col.rgb = dot(col.rgb, fixed3(.222,.707,.071));
return col;
}
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
AlphaTest Greater .01
Blend SrcAlpha OneMinusSrcAlpha
ColorMaterial AmbientAndDiffuse
SetTexture [_MainTex]
{
Combine Texture * Primary
}
}
}
}
Posted by Louis at February 26, 2014 - 10:17 PM
출처 : http://www.programering.com/a/MzM5ATMwATY.html