Unity3D Ui利用shader添加效果
来源:本站原创|时间:2020-01-10|栏目:C#教程|点击: 次
本文实例为大家分享了Unity3D Ui利用shader添加效果的具体代码,供大家参考,具体内容如下
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' Shader "UI/Unlit/Flowlight" { Properties { [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {} _Color("Tint", Color) = (1, 1, 1, 1) [MaterialToggle] _OffSet("OffSet", float) = 0 [MaterialToggle] PixelSnap("Pixel snap", float) = 0 /* Flowlight */ _FlowlightMaskTex("Mask Texture", 2D) = "white" {} _FlowlightTex("Add Move Texture", 2D) = "white" {} _FlowlightColor("Flowlight Color", Color) = (0, 0, 0, 1) _Power("Power", float) = 1 _SpeedX("SpeedX", float) = 1 _SpeedY("SpeedY", float) = 0 /* --------- */ /* UI */ _StencilComp("Stencil Comparison", Float) = 8 _Stencil("Stencil ID", Float) = 0 _StencilOp("Stencil Operation", Float) = 0 _StencilWriteMask("Stencil Write Mask", Float) = 255 _StencilReadMask("Stencil Read Mask", Float) = 255 /* -- */ } SubShader { Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" "CanUseSpriteAtlas" = "True" } Cull Off Lighting Off ZWrite Off Blend One OneMinusSrcAlpha /* UI */ Stencil { Ref[_Stencil] Comp[_StencilComp] Pass[_StencilOp] ReadMask[_StencilReadMask] WriteMask[_StencilWriteMask] } /* -- */ Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma multi_compile _ PIXELSNAP_ON #include "UnityCG.cginc" struct appdata_t { float4 vertex : POSITION; float4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f { float4 vertex : SV_POSITION; fixed4 color : COLOR; half2 texcoord : TEXCOORD0; /* Flowlight */ half2 texflowlight : TEXCOORD1; /* --------- */ }; fixed4 _Color; /* Flowlight */ fixed4 _FlowlightColor; float _Power; sampler2D _FlowlightTex; fixed4 _FlowlightTex_ST; sampler2D _FlowlightMaskTex; fixed4 _FlowlightMaskTex_ST; fixed _SpeedX; fixed _SpeedY; fixed x = 0; float _OffSet; /* --------- */ v2f vert(appdata_t IN) { v2f OUT; OUT.vertex = UnityObjectToClipPos(IN.vertex); OUT.texcoord = IN.texcoord; /* Flowlight */ OUT.texflowlight = TRANSFORM_TEX(IN.texcoord, _FlowlightTex); OUT.texflowlight.x += _Time * _SpeedX; OUT.texflowlight.y += _Time * _SpeedY; OUT.color = IN.color * _Color; #ifdef PIXELSNAP_ON OUT.vertex = UnityPixelSnap(OUT.vertex); #endif return OUT; } sampler2D _MainTex; fixed4 frag(v2f IN) : SV_Target { fixed4 c = tex2D(_MainTex, IN.texcoord)*IN.color; fixed4 cmask = tex2D(_FlowlightMaskTex, IN.texcoord); if (cmask.a != 0) { /* Flowlight */ fixed4 cadd = tex2D(_FlowlightTex, IN.texflowlight) * _Power; cadd.rgb *= c.rgb; c.rgb += cadd.rgb; } c.rgb *= c.a; /* --------- */ return c; } ENDCG } } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。
栏 目:C#教程
本文地址:https://www.xiuzhanwang.com/a1/C_jiaocheng/4872.html
您可能感兴趣的文章
- 01-10C#利用反射技术实现去掉按钮选中时的边框效果
- 01-10C#图片处理3种高级应用
- 01-10Unity3d获取系统时间
- 01-10Unity3D获取当前键盘按键及Unity3D鼠标、键盘的基本操作
- 01-10C#异步下载文件
- 01-10C# Console利用mspaint打开图像并保存的方法
- 01-10C#利用delegate实现Javascript的each方法
- 01-10C#利用GDI绘制常见图形和文字
- 01-10利用C#实现网络爬虫
- 01-10C# 利用ICSharpCode.SharpZipLib实现在线压缩和解压缩
阅读排行
本栏相关
- 01-10C#通过反射获取当前工程中所有窗体并
- 01-10关于ASP网页无法打开的解决方案
- 01-10WinForm限制窗体不能移到屏幕外的方法
- 01-10WinForm绘制圆角的方法
- 01-10C#实现txt定位指定行完整实例
- 01-10WinForm实现仿视频 器左下角滚动新
- 01-10C#停止线程的方法
- 01-10C#实现清空回收站的方法
- 01-10C#通过重写Panel改变边框颜色与宽度的
- 01-10C#实现读取注册表监控当前操作系统已
随机阅读
- 01-10C#中split用法实例总结
- 01-10SublimeText编译C开发环境设置
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文
- 01-11ajax实现页面的局部加载
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 01-10delphi制作wav文件的方法
- 08-05DEDE织梦data目录下的sessions文件夹有什
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 04-02jquery与jsp,用jquery