Unity Shader--logo Flashing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.