这篇文章主要为大家展示了“OpenGL Shader如何实现等待标识效果”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“OpenGL Shader如何实现等待标识效果”这篇文章吧。
公司主营业务:网站制作、成都网站设计、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出殷都免费做网站回馈大家。结果如下:
代码:
Shader "stalendp/waitIcons" { CGINCLUDE #include "UnityCG.cginc" #pragma target 3.0 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 = v.texcoord.xy; return o; } fixed calcDot(fixed a, fixed ca, fixed2 uv) { a /= 57.295779513; ca /= 57.295779513; fixed tt = 180/57.295779513; uv = (fixed2(cos(a), sin(a)) * 0.2+ uv)*10; fixed adit = tt*2*step(tt, a-ca); fixed r = 1-step(ca + adit, a); r *= lerp(0.2, -1, saturate((ca-a+adit)/25))*2; return smoothstep(r-0.2, r, length(uv.xy)); } fixed4 frag(v2f input) : COLOR0 { float2 uv = input.uv.xy - float2(0.5); float rx = fmod(uv.x, 0.4); float ry = fmod(uv.y, 0.4); float mx = step(0.4, abs(uv.x)); float my = step(0.4, abs(uv.y)); float alpha = 1- mx*my*step(0.1, length(half2(rx,ry))); alpha*=0.9; fixed4 foreColor = fixed4(1); fixed4 bgColor = fixed4(fixed3(0.4),alpha); fixed4 result = bgColor; fixed ca = fmod(_Time.y, 2)*180; bgColor = lerp(foreColor, bgColor, calcDot(0, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(30, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(60, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(90, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(120, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(150, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(180, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(210, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(240, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(270, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(300, ca, uv)); bgColor = lerp(foreColor, bgColor, calcDot(330, ca, uv)); return bgColor; } ENDCG SubShader { LOD 200 Tags {"Queue" = "Transparent"} ZWrite Off Blend SrcAlpha OneMinusSrcAlpha Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma fragmentoption ARB_precision_hint_fastest ENDCG } } FallBack Off }
以上是“OpenGL Shader如何实现等待标识效果”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!