FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Unity3D-CG-programming/blur.shader at master · ParsGameLab/Unity3D-CG-programming · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ParsGameLab
/
Unity3D-CG-programming
Public
forked from
przemyslawzaworski/Unity3D-CG-programming
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Unity3D-CG-programming
/
blur.shader
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (58 loc) · 1.41 KB
Breadcrumbs
Unity3D-CG-programming
/
blur.shader
Copy path
File metadata and controls
64 lines (58 loc) · 1.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Shade
r
"Blur
"
{
Properties
{
_MainTex (
"Texture"
,
2D
) =
"black"
{}
_radius (
"Blur radius"
,
Range
(
0.01
,
2.0
)) =
0.5
}
SubShader
{
Pass
{
CGPROGRAM
#pragma
vertex vertex_shader
#pragma
fragment pixel_shader
#pragma
target
5.0
float
_radius;
sampler2D
_MainTex;
float4
_MainTex_TexelSize;
struct
structure
{
float4
vertex:
SV_POSITION
;
float2
uv :
TEXCOORD0
;
};
void
vertex_shader
(
float4
vertex:
POSITION
,
float2
uv:
TEXCOORD0
,
out
structure vs)
{
vs.vertex =
UnityObjectToClipPos
(vertex);
vs.uv = uv;
}
float4
surface
(
sampler2D
input,
float2
uv)
{
return
tex2D
(input,uv);
}
float3
blur
(
float2
uv,
float
radius)
{
float2x2
m =
float2x2
(-
0.736717
,
0.6762
,-
0.6762
,-
0.736717
);
float3
total =
float3
(
0.0
,
0.0
,
0.0
);
float2
s = _MainTex_TexelSize.zw;
float2
texel =
float2
(
0.002
*s.x/s.y,
0.002
);
float2
angle =
float2
(
0.0
,radius);
radius =
1.0
;
for
(
int
j=
0
;j<
80
;j++)
{
radius +=
rcp
(radius);
//sm 5.0 fast reciprocal function
angle =
mul
(angle,m);
float3
color =
surface
(_MainTex,uv+texel*(radius-
1.0
)*angle).rgb;
total += color;
}
return
total/
80.0
;
}
void
pixel_shader
(
in
structure ps,
out
float4
fragColor:
SV_Target0
)
{
float2
uv = ps.uv.xy;
fragColor =
float4
(
blur
(uv,_radius),
1.0
);
}
ENDCG
}
}
}
Back
|
FazBrowse Home
|
New Git URL