博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
shader
阅读量:5876 次
发布时间:2019-06-19

本文共 2629 字,大约阅读时间需要 8 分钟。

Shader "Custom/logo" {	Properties {		_MainTex ("Texture", 2D) = "white" { }	}	SubShader	{		Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }		Tags { "LightMode" = "Vertex" }		Cull Off		Lighting On		Material { Emission [_EmisColor] }		ColorMaterial AmbientAndDiffuse		ZWrite Off		ColorMask RGB		AlphaTest Greater .001				// This 1 line of code make texture transparent 		Blend SrcAlpha OneMinusSrcAlpha				pass		{			CGPROGRAM			#pragma vertex vert			#pragma fragment frag						#include "UnityCG.cginc"									sampler2D _MainTex;			float4 _MainTex_ST;									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 =	TRANSFORM_TEX(v.texcoord,_MainTex);			    return o;			}						float inFlash(float angle,float2 uv,float xLength,int interval,int beginTime, float offX, float loopTime )			{				float brightness =0;				float angleInRad = 0.0174444 * angle;				float currentTime = _Time.y;							int currentTimeInt = _Time.y/interval;				currentTimeInt *=interval;				float currentTimeRemainder = currentTime -currentTimeInt;				if(currentTimeRemainder >beginTime)				{					float xLeftBound; 					float xRightBound;								float xProjL;					float xPointLeftBound; 					float xPointRightBound;										float x0 = currentTimeRemainder-beginTime; 					x0 /= loopTime;								xRightBound = x0;					xLeftBound = x0 - xLength;										xProjL= (uv.y)/tan(angleInRad);										xPointLeftBound = xLeftBound - xProjL;					xPointRightBound = xRightBound - xProjL;										xPointLeftBound += offX;					xPointRightBound += offX;					if(uv.x > xPointLeftBound && uv.x < xPointRightBound)					{						float midness = (xPointLeftBound + xPointRightBound)/2;						float rate= (xLength -2*abs(uv.x - midness))/ (xLength);						brightness = rate;					}				}				brightness= max(brightness,0);				float4 col = float4(1,1,1,1) *brightness;				return brightness;			}			float4 frag (v2f i) : COLOR			{				bool inRegion;				inRegion = false;								float tmpBrightness;//				tmpBrightness =inFlash(75,i.uv,0.05f,5f,2f,0,0.7f);//				if(tmpBrightness ==0)//					tmpBrightness =inFlash(75,i.uv,0.25f,5f,2f,0.15,0.7f);								tmpBrightness =inFlash(75,i.uv,0.25f,5f,2f,0.15,0.7f);								float4 texCol = tex2D(_MainTex,i.uv);			    float4 outp;						    if(texCol.w >0.5)			    {				    	outp  =texCol+float4(1,1,1,1)*tmpBrightness;			    }			    else			    	outp =float4(0,0,0,0);			    				    //int uu = _Time.y;			    //outp = float4(uu%5 * 0.1,0,0,1);			    return outp;			}			ENDCG		}	}}

转载地址:http://olzix.baihongyu.com/

你可能感兴趣的文章
Spring MVC NoClassDefFoundError 问题的解决方法。
查看>>
CentOS 6.9配置网卡IP/网关/DNS命令详细介绍及一些常用网络配置命令(转)
查看>>
python基础教程_学习笔记19:标准库:一些最爱——集合、堆和双端队列
查看>>
C# 解决窗体闪烁
查看>>
CSS魔法堂:Transition就这么好玩
查看>>
【OpenStack】network相关知识学习
查看>>
centos 7下独立的python 2.7环境安装
查看>>
[日常] 算法-单链表的创建
查看>>
前端工程化系列[01]-Bower包管理工具的使用
查看>>
使用 maven 自动将源码打包并发布
查看>>
Spark:求出分组内的TopN
查看>>
Python爬取豆瓣《复仇者联盟3》评论并生成乖萌的格鲁特
查看>>
关于跨DB增量(增、改)同步两张表的数据小技巧
查看>>
飞秋无法显示局域网好友
查看>>
学员会诊之03:你那惨不忍睹的三层架构
查看>>
vue-04-组件
查看>>
Golang协程与通道整理
查看>>
解决win7远程桌面连接时发生身份验证错误的方法
查看>>
C/C++ 多线程机制
查看>>
js - object.assign 以及浅、深拷贝
查看>>