转发请保持地址:http://blog.csdn.net/stalendp/article/details/22720295
在游戏中,当战斗结束后,对一些获取的宝贝需要进行闪光处理。这篇文章介绍一个进行闪光处理的shader,运行效果如下:
代码如下:
Shader "stalendp/imageShine" {
Properties{
_image("image", 2D) = "white" {}
_percent("_percent", Range(-5, 5)) = 1
_angle("angle", Range(0, 1)) = 0
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _image;
float _percent;
float _angle;
struct v2f {
float4 pos:SV_POSITION;
float2 uv : TEXCOORD0;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord.xy;
return o;
}
fixed4 frag(v2f i) : COLOR0{
// 计算圆角
float2 uv = i.uv.xy - float2(0.5,0.5);
float rx = fmod(uv.x, 0.4);
float ry = fmod(uv.y, 0.4);
float mx = step(0.4, ab