In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to implement UGUI mask streamer effects in unity. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Here is the core shader:
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 ("FlowlightColor", 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 ("StencilWriteMask", Float) = 255StencilReadMask ("StencilReadMask", 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 = mul (UNITY_MATRIX_MVP, 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}} thank you for your reading! This is the end of this article on "how to achieve UGUI Mask streamer effects in unity". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.