Home>
Normal picture:
shader code:
shader "custom/gaosimohu"
{
properties
{
_maintex ("texture", 2d)="white" {}
_blursize ("blur size", float)=1.0
}
subshader
{
ztest always
cull off
zwrite off
cginclude //This can make other pass blocks available,Instead of writing in both passes, reducing the number of writes
sampler2d _maintex;
half4 _maintex_texelsize;
float _blursize;
struct v2f {
float4 pos:sv_position;
half2 uv [5]:texcoord0;
};
fixed4 fragblur (v2f i):sv_target {
float weight [3]={
0.4026, 0.2442, 0.0545
};
fixed3 sum=tex2d (_maintex, i.uv [0]). rgb * weight [0];
for (int it=1;it<3;it ++) {
sum +=tex2d (_maintex, i.uv [it]). rgb * weight [it];
sum +=tex2d (_maintex, i.uv [2 * it]). rgb * weight [it];
}
return fixed4 (sum, 1.0);
}
endcg
pass {
name "gaussian_blur_vertical" //The unique name of this pass,Can be called elsewhere,usepass + name
cgprogram
#pragma vertex vertlurvertical
#pragma fragment fragblur
#include "unitycg.cginc"
v2f vertlurvertical (appdata_img v) {
v2f o;
o.pos=unityobjecttoclippos (v.vertex);
half2 uv=v.texcoord;
o.uv [0]=uv;
o.uv [1]=uv + float2 (0.0, _maintex_texelsize.y * 1.0) * _blursize;
o.uv [2]=uv-float2 (0.0, _maintex_texelsize.y * 1.0) * _blursize;
o.uv [3]=uv + float2 (0.0, _maintex_texelsize.y * 2.0) * _blursize;
o.uv [4]=uv-float2 (0.0, _maintex_texelsize.y * 2.0) * _blursize;
return o;
}
endcg
}
pass {
name "gaussian_blur_horizontal"
cgprogram
#pragma vertex vertlurhorizontal
#pragma fragment fragblur
#include "unitycg.cginc"
v2f vertlurhorizontal (appdata_img v) {
v2f o;
o.pos=unityobjecttoclippos (v.vertex);
half2 uv=v.texcoord;
o.uv [0]=uv;
o.uv [1]=uv + float2 (0.0, _maintex_texelsize.x * 1.0) * _blursize;
o.uv [2]=uv-float2 (0.0, _maintex_texelsize.x * 1.0) * _blursize;
o.uv [3]=uv + float2 (0.0, _maintex_texelsize.x * 2.0) * _blursize;
o.uv [4]=uv-float2 (0.0, _maintex_texelsize.x * 2.0) * _blursize;
return o;
}
endcg
}
}
}
Adjust the _blursize to see the effect
Trends
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs