Finally found a practical effect, let's take it out for you to share.
1Shader "Custom/logoblink" {2 Properties {3_maintex ("Base (RGB)", 2D) = "White" {}4 5_blinkcolor ("Blink color", color) = (1,1,1,1)6_blinkwidth ("Blink Width", range (0, 1)) = 0.27_looptime ("Looping Time", Range (0,10)) = 18_interval ("Time Interval", Range (0,10)) = 29 }Ten Subshader { OneTags {"Rendertype" = "Opaque" } ALOD 200 - - Cgprogram the #pragma surface surf Lambert - - sampler2d _maintex; - float4 _blinkcolor; + float_blinkwidth; - float_looptime; + float_interval; A at - struct Input { - float2 Uv_maintex; - }; - - floatBlink (float2 UV) in { - to floatCurtime = _time.y;//Current Time + floatTotalTime = _looptime +_interval; - floatCurinittime = (int) (_time.y/totaltime) * totaltime;//Current Start time the * floatPassedtime = _time.y-curinittime-_interval; $ Panax Notoginseng if(Passedtime <= 0.0) - return0.0; the Else + { A floatPassedtimepercent = (passedtime)/_looptime; the + - floatBottomPoint1 = passedtimepercent* (_blinkwidth + 1);//Base point 1 $ floatBottomPoint2 = BottomPoint1-_blinkwidth;//Base point 2 $ //The default is a 45-degree angle, so you don't need to compute too much - - floatTemp1 = BottomPoint1-uv.y; the floatTemp2 = Temp1-(_blinkwidth*0.5); - Wuyi the if(uv.x > Temp1 | | uv.x < temp1-_blinkwidth) - return0.0; Wu Else - { About return1.0-abs ((TEMP1-UV.X-TEMP2)/temp2); $ } - } - } - A + voidSurf (Input in, InOut surfaceoutput o) { theHalf4 C =tex2d (_maintex, In.uv_maintex); - floatBrightness =Blink (In.uv_maintex); $ theO.albedo = C.rgb + (Brightness *_blinkcolor.rgb); theO.alpha =C.A; the } the ENDCG - in } theFallBack "Diffuse" the}
View Code
There is not much difficulty, there is a creative part, is the division of the implementation of the count. (Is this a trick to be forced out?) >_<)
Precautions:
The 1.UV coordinate origin is the lower-left corner.
2. Unlike the C language, where a branch has a return, it must be explicitly written in the Else section.
****************
Unity Shader--logo Flashing