• shader


    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
    		}
    	}
    }
  • 相关阅读:
    树链剖分( 洛谷P3384 )
    ZJOI 2015 诸神眷顾的幻想乡
    BZOJ 1002 [FJOI2007]轮状病毒
    洛谷 P1485 火枪打怪
    Luogu2860 [USACO06JAN]冗余路径Redundant Paths
    CF962F Simple Cycles Edges
    Luogu3605 [USACO17JAN]Promotion Counting晋升者计数
    Luogu2295 MICE
    CF341D Iahub and Xors
    CF617E XOR and Favorite Number
  • 原文地址:https://www.cnblogs.com/U-tansuo/p/2807735.html
Copyright © 2020-2023  润新知