真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Unity3DUGUI特效之Image高斯模糊效果-創(chuàng)新互聯(lián)

這幾天研究了下模糊特效,看了很多文章,其原理就是拿取圖片或屏幕數(shù)據(jù),然后將周圍的元素和目標(biāo)位置的顏色值進(jìn)行一個(gè)融合計(jì)算,然后自己寫了一個(gè)小小的測(cè)試程序。

創(chuàng)新互聯(lián)公司主要業(yè)務(wù)有網(wǎng)站營(yíng)銷策劃、網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、微信公眾號(hào)開(kāi)發(fā)、成都微信小程序、H5技術(shù)、程序開(kāi)發(fā)等業(yè)務(wù)。一次合作終身朋友,是我們奉行的宗旨;我們不僅僅把客戶當(dāng)客戶,還把客戶視為我們的合作伙伴,在開(kāi)展業(yè)務(wù)的過(guò)程中,公司還積累了豐富的行業(yè)經(jīng)驗(yàn)、成都全網(wǎng)營(yíng)銷資源和合作伙伴關(guān)系資源,并逐漸建立起規(guī)范的客戶服務(wù)和保障體系。 

這個(gè)模糊也可以分成兩種,一個(gè)是自身模糊,一個(gè)是從屏幕上取值進(jìn)行模糊。第一個(gè)用于一些小的列表展示,比如未解鎖時(shí),是模糊的。第二個(gè)是凸顯彈框效果的,將背景都模糊掉,自己將這個(gè)稍微加強(qiáng)了些可以指定模糊一個(gè)位置。

針對(duì)移動(dòng)平臺(tái),使用高斯模糊,其實(shí)效率不是很高,如果要很好的效果,那么速度卡;如果要速度快,那么效果達(dá)不到要求。但是還是在這里記錄下,興許以后能用上。

先說(shuō)第一個(gè),掛在Image下的模糊特效。

Shader "Custom/FrontBlur" {
 Properties
 {
 [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
 _Color ("Tint", Color) = (1,1,1,1)
 
 [HideInInspector]_StencilComp ("Stencil Comparison", Float) = 8
 [HideInInspector]_Stencil ("Stencil ID", Float) = 0
 [HideInInspector]_StencilOp ("Stencil Operation", Float) = 0
 [HideInInspector]_StencilWriteMask ("Stencil Write Mask", Float) = 255
 [HideInInspector]_StencilReadMask ("Stencil Read Mask", Float) = 255

 [HideInInspector]_ColorMask ("Color Mask", Float) = 15

 [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
 
 _Size ("Size", Range(0, 50)) = 5
 }

 SubShader
 {
 Tags
 { 
 "Queue"="Transparent" 
 "IgnoreProjector"="True" 
 "RenderType"="Transparent" 
 "PreviewType"="Plane"
 "CanUseSpriteAtlas"="True"
 }
 
 Stencil
 {
 Ref [_Stencil]
 Comp [_StencilComp]
 Pass [_StencilOp] 
 ReadMask [_StencilReadMask]
 WriteMask [_StencilWriteMask]
 }

 Cull Off
 Lighting Off
 ZWrite Off
 ZTest [unity_GUIZTestMode]
 Blend SrcAlpha OneMinusSrcAlpha
 ColorMask [_ColorMask]

 Pass
 {
 Name "FrontBlurHor"
 CGPROGRAM
 #pragma vertex vert
 #pragma fragment frag
 #pragma target 2.0

 #include "UnityCG.cginc"
 #include "UnityUI.cginc"

 #pragma multi_compile __ UNITY_UI_ALPHACLIP
 
 struct appdata_t
 {
 float4 vertex : POSITION;
 float4 color : COLOR;
 float2 texcoord : TEXCOORD0;
 UNITY_VERTEX_INPUT_INSTANCE_ID
 };

 struct v2f
 {
 float4 vertex : SV_POSITION;
 fixed4 color : COLOR;
 float2 texcoord : TEXCOORD0;
 float4 worldPosition : TEXCOORD1;
 UNITY_VERTEX_OUTPUT_STEREO
 };
 
 fixed4 _Color;
 fixed4 _TextureSampleAdd;
 float4 _ClipRect;

 v2f vert(appdata_t IN)
 {
 v2f OUT;
 UNITY_SETUP_INSTANCE_ID(IN);
 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
 OUT.worldPosition = IN.vertex;
 OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);

 OUT.texcoord = IN.texcoord;
 
 OUT.color = IN.color * _Color;
 return OUT;
 }

 sampler2D _MainTex;
 float4 _MainTex_TexelSize;
 float _Size;

 half4 GrabPixel(v2f i, float weight, float kernelx){
 if (_Size <= 1 || weight == 0){
  return tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x*kernelx*_Size, i.texcoord.y)) * weight;
 }else{
  half4 sum = half4(0,0,0,0);
  sum += tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x*kernelx*_Size*0.2, i.texcoord.y))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x*kernelx*_Size*0.4, i.texcoord.y))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x*kernelx*_Size*0.6, i.texcoord.y))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x*kernelx*_Size*0.8, i.texcoord.y))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x*kernelx*_Size*1.0, i.texcoord.y))*0.2;
  return (sum + _TextureSampleAdd) * weight;
 }
 }

 half4 GrabPixely(v2f i, float weight, float kernely){
 if (_Size <= 1 || weight == 0){
  return tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size)) * weight;
 }else{
  half4 sum = half4(0,0,0,0);
  sum += tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size*0.2))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size*0.4))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size*0.6))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size*0.8))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size*1.0))*0.2;
  return (sum + _TextureSampleAdd) * weight;
 }
 }

 fixed4 frag(v2f IN) : SV_Target
 {
 half4 sum = half4(0,0,0,0);
 // #define GRABPIXEL(weight, kernelx) (tex2D(_MainTex, half2(IN.texcoord.x + _MainTex_TexelSize.x * kernelx*_Size, IN.texcoord.y)) + _TextureSampleAdd) * weight
 
 // sum += GrabPixel(IN, 0.05, -4.0);
 // sum += GrabPixel(IN, 0.09, -3.0);
 // sum += GrabPixel(IN, 0.12, -2.0);
 // sum += GrabPixel(IN, 0.15, -1.0);
 // sum += GrabPixel(IN, 0.18, 0.0);
 // sum += GrabPixel(IN, 0.15, +1.0);
 // sum += GrabPixel(IN, 0.12, +2.0);
 // sum += GrabPixel(IN, 0.09, +3.0);
 // sum += GrabPixel(IN, 0.05, +4.0);

 for(int i=0;i<9;i++){
  sum += GrabPixel(IN, 1.0/9, i-4.0);
 }

 // half4 sumy = half4(0,0,0,0);
 // for(int i=0;i<15;i++){
 // sumy += GrabPixely(IN, 1.0/15, i-7.0);
 // }
 // half4 sum = (sumx + sumy) * 0.5;

 // sum += GrabPixel(IN, 0.01, -9.0);
 // sum += GrabPixel(IN, 0.02, -8.0);
 // sum += GrabPixel(IN, 0.03, -7.0);
 // sum += GrabPixel(IN, 0.04, -6.0);
 // sum += GrabPixel(IN, 0.05, -5.0);
 // sum += GrabPixel(IN, 0.06, -4.0);
 // sum += GrabPixel(IN, 0.07, -3.0);
 // sum += GrabPixel(IN, 0.08, -2.0);
 // sum += GrabPixel(IN, 0.09, -1.0);
 // sum += GrabPixel(IN, 0.10, 0.0);
 // sum += GrabPixel(IN, 0.09, +1.0);
 // sum += GrabPixel(IN, 0.08, +2.0);
 // sum += GrabPixel(IN, 0.07, +3.0);
 // sum += GrabPixel(IN, 0.06, +4.0);
 // sum += GrabPixel(IN, 0.05, +5.0);
 // sum += GrabPixel(IN, 0.04, +6.0);
 // sum += GrabPixel(IN, 0.03, +7.0);
 // sum += GrabPixel(IN, 0.02, +8.0);
 // sum += GrabPixel(IN, 0.01, +9.0);

 sum = sum * IN.color;
 sum.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
 #ifdef UNITY_UI_ALPHACLIP
 clip (sum.a - 0.001);
 #endif
 return sum;

 // float distance = _Distance;

 // fixed4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;

 // color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
 // color /= 9;
 
 // color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
 
 // #ifdef UNITY_UI_ALPHACLIP
 // clip (color.a - 0.001);
 // #endif

 // return color;
 }
 ENDCG
 }
 Pass
 {
 Name "FrontBlurVer"
 CGPROGRAM
 #pragma vertex vert
 #pragma fragment frag
 #pragma target 2.0

 #include "UnityCG.cginc"
 #include "UnityUI.cginc"

 #pragma multi_compile __ UNITY_UI_ALPHACLIP
 
 struct appdata_t
 {
 float4 vertex : POSITION;
 float4 color : COLOR;
 float2 texcoord : TEXCOORD0;
 UNITY_VERTEX_INPUT_INSTANCE_ID
 };

 struct v2f
 {
 float4 vertex : SV_POSITION;
 fixed4 color : COLOR;
 float2 texcoord : TEXCOORD0;
 float4 worldPosition : TEXCOORD1;
 UNITY_VERTEX_OUTPUT_STEREO
 };
 
 fixed4 _Color;
 fixed4 _TextureSampleAdd;
 float4 _ClipRect;

 v2f vert(appdata_t IN)
 {
 v2f OUT;
 UNITY_SETUP_INSTANCE_ID(IN);
 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
 OUT.worldPosition = IN.vertex;
 OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);

 OUT.texcoord = IN.texcoord;
 
 OUT.color = IN.color * _Color;
 return OUT;
 }

 sampler2D _MainTex;
 float4 _MainTex_TexelSize;
 float _Size;

 half4 GrabPixel(v2f i, float weight, float kernely){
 if (_Size <= 1 || weight == 0){
  return tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size)) * weight;
 }else{
  half4 sum = half4(0,0,0,0);
  sum += tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size*0.2))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size*0.4))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size*0.6))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size*0.8))*0.2;
  sum += tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y*kernely*_Size*1.0))*0.2;
  return (sum + _TextureSampleAdd) * weight;
 }
 }

 fixed4 frag(v2f IN) : SV_Target
 {
 half4 sum = half4(0,0,0,0); 
 // #define GRABPIXEL(weight, kernely) (tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y + _MainTex_TexelSize.y * kernely*_Size)) + _TextureSampleAdd) * weight
 
 // sum += GrabPixel(IN, 0.05, -4.0);
 // sum += GrabPixel(IN, 0.09, -3.0);
 // sum += GrabPixel(IN, 0.12, -2.0);
 // sum += GrabPixel(IN, 0.15, -1.0);
 // sum += GrabPixel(IN, 0.18, 0.0);
 // sum += GrabPixel(IN, 0.15, +1.0);
 // sum += GrabPixel(IN, 0.12, +2.0);
 // sum += GrabPixel(IN, 0.09, +3.0);
 // sum += GrabPixel(IN, 0.05, +4.0);

 for(int i=0;i<9;i++){
  sum += GrabPixel(IN, 1.0/9, i-4.0);
 }

 // sum += GrabPixel(IN, 0.01, -9.0);
 // sum += GrabPixel(IN, 0.02, -8.0);
 // sum += GrabPixel(IN, 0.03, -7.0);
 // sum += GrabPixel(IN, 0.04, -6.0);
 // sum += GrabPixel(IN, 0.05, -5.0);
 // sum += GrabPixel(IN, 0.06, -4.0);
 // sum += GrabPixel(IN, 0.07, -3.0);
 // sum += GrabPixel(IN, 0.08, -2.0);
 // sum += GrabPixel(IN, 0.09, -1.0);
 // sum += GrabPixel(IN, 0.10, 0.0);
 // sum += GrabPixel(IN, 0.09, +1.0);
 // sum += GrabPixel(IN, 0.08, +2.0);
 // sum += GrabPixel(IN, 0.07, +3.0);
 // sum += GrabPixel(IN, 0.06, +4.0);
 // sum += GrabPixel(IN, 0.05, +5.0);
 // sum += GrabPixel(IN, 0.04, +6.0);
 // sum += GrabPixel(IN, 0.03, +7.0);
 // sum += GrabPixel(IN, 0.02, +8.0);
 // sum += GrabPixel(IN, 0.01, +9.0);

 sum = sum * IN.color;
 sum.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
 #ifdef UNITY_UI_ALPHACLIP
 clip (sum.a - 0.001);
 #endif
 return sum;

 // float distance = _Distance;

 // fixed4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;

 // color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
 // color += (tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
 // color /= 9;
 
 // color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
 
 // #ifdef UNITY_UI_ALPHACLIP
 // clip (color.a - 0.001);
 // #endif

 // return color;
 }
 ENDCG
 }
 }
}

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。


分享文章:Unity3DUGUI特效之Image高斯模糊效果-創(chuàng)新互聯(lián)
鏈接URL:http://weahome.cn/article/dpceeh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部