Shader "Sprites/Default"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
} SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
} Cull Off //关闭背面剔除
Lighting Off //关闭灯光
ZWrite Off //关闭Z缓冲
Blend One OneMinusSrcAlpha //混合源系数one(1) 目标系数OneMinusSrcAlpha(1-one=0) Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile _ PIXELSNAP_ON //告诉Unity编译不同版本的Shader,这里和后面vert中的PIXELSNAP_ON对应
#pragma shader_feature ETC1_EXTERNAL_ALPHA
#include "UnityCG.cginc" struct appdata_t //vert输入
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
}; struct v2f //vert输出数据结构
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
}; fixed4 _Color; v2f vert(appdata_t IN)
{
v2f OUT;
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color * _Color;
#ifdef PIXELSNAP_ON
OUT.vertex = UnityPixelSnap (OUT.vertex);
#endif return OUT;
} sampler2D _MainTex;
sampler2D _AlphaTex; fixed4 SampleSpriteTexture (float2 uv)
{
fixed4 color = tex2D (_MainTex, uv); #if ETC1_EXTERNAL_ALPHA //etc1没有透明通道,从另一图中取a值
// get the color from an external texture (usecase: Alpha support for ETC1 on android)
color.a = tex2D (_AlphaTex, uv).r;
#endif //ETC1_EXTERNAL_ALPHA return color;
} fixed4 frag(v2f IN) : SV_Target
{
fixed4 c = SampleSpriteTexture (IN.texcoord) * IN.color;
c.rgb *= c.a;
return c;
}
ENDCG
}
}
}

最新文章

  1. 重构edit 和 new页面
  2. 【toplink】 位居第一的Java对象关系可持续性体系结构
  3. Oracle LOB
  4. QT高级运用之粒子模拟(Particle Simulations)
  5. C++ 空类默认产生的类成员函数
  6. javaCV开发详解之2:推流器实现,推本地摄像头视频到流媒体服务器以及摄像头录制视频功能实现(基于javaCV-FFMPEG、javaCV-openCV)
  7. Redis客户端管理工具,状态监控工具
  8. UNIX 技巧: UNIX 高手的另外 10 个习惯
  9. sed 命令多行到多行的定位方式
  10. C#ComboBox控件“设置 DataSource 属性后无法修改项集合”的解决方法
  11. button的后台点击事件
  12. P4843 清理雪道
  13. __autolaod
  14. Restful API的设计规范
  15. 运行quectel EC20 module example data
  16. CSS3 响应式web设计,CSS3 Media Queries
  17. pycharm如何回到过去某个时间
  18. window,centos双系统坏了
  19. 《Apologize》歌曲
  20. Unable to locate JAR/zip in file system as specified by the driver definition: ojdbc14.jar

热门文章

  1. 搭建mysql主从集群的步骤
  2. JQGrid总记录数和查询消耗时间不显示
  3. 相机标定过程(opencv) + matlab参数导入opencv + matlab标定和矫正
  4. POJ2478 Farey Sequence —— 欧拉函数
  5. Codeforces Round #376 (Div. 2) A. Night at the Museum —— 循环轴
  6. 如何把wecenter的推荐的问题模块单独调取出来?
  7. c++变量定义
  8. codeforces 460C. Present 解题报告
  9. ubuntu nginx 安装 certbot(letsencrypt)
  10. get_extension_funcs 返回某个模块下的所有函数