FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
tdesktop/Telegram/shaders/group_frame.frag at dev · feiyunwill/tdesktop · GitHub
feiyunwill
/
tdesktop
Public
forked from
telegramdesktop/tdesktop
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
tdesktop
/
Telegram
/
shaders
/
group_frame.frag
Copy path
More file actions
More file actions
Latest commit
History
History
History
85 lines (71 loc) · 2.71 KB
Breadcrumbs
tdesktop
/
Telegram
/
shaders
/
group_frame.frag
Copy path
File metadata and controls
85 lines (71 loc) · 2.71 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#version
450
layout
(location
=
0
)
in
vec2
v_texcoord;
layout
(location
=
1
)
in
vec2
b_texcoord;
layout
(location
=
2
)
in
vec2
v_position;
layout
(location
=
0
)
out
vec4
fragColor;
layout
(binding
=
1
)
uniform
sampler2D
s_texture;
layout
(binding
=
2
)
uniform
sampler2D
b_texture;
layout
(binding
=
3
)
uniform
sampler2D
n_texture;
layout
(std140, binding
=
0
)
uniform
Params {
vec2
viewport;
vec4
frameBg;
vec4
shadow;
float
paused;
vec4
roundRect;
vec2
radiusOutline;
vec4
roundBg;
vec4
outlineFg;
};
const
float
noiseGrain
=
0.002
;
vec2
roundedCorner(
vec2
fc) {
vec2
rectHalf
=
roundRect.zw
/
2.0
;
vec2
rectCenter
=
roundRect.xy
+
rectHalf;
vec2
fromRectCenter
=
abs
(fc
-
rectCenter);
vec2
vectorRadius
=
radiusOutline.xx
+
vec2
(
0.5
);
vec2
fromCenterWithRadius
=
fromRectCenter
+
vectorRadius;
vec2
fromRoundingCenter
=
max
(fromCenterWithRadius, rectHalf)
-
rectHalf;
float
rounded
=
length
(fromRoundingCenter)
-
radiusOutline.x;
float
outline
=
rounded
+
radiusOutline.y;
return
vec2
(
1.0
-
smoothstep
(
0.0
,
1.0
, rounded),
1.0
-
(
smoothstep
(
0.0
,
1.0
, outline)
*
outlineFg.a));
}
float
insideTexture() {
vec2
textureHalf
=
vec2
(
0.5
,
0.5
);
vec2
fromTextureCenter
=
abs
(v_texcoord
-
textureHalf);
vec2
fromTextureEdge
=
max
(fromTextureCenter, textureHalf)
-
textureHalf;
float
outsideCheck
=
dot
(fromTextureEdge, fromTextureEdge);
return
step
(outsideCheck,
0.0
);
}
//
Dithering the blurred background against the banding it shows.
vec4
background() {
//
Plain blurred color, main() mixes it with frameBg by shadow.w.
vec4
result
=
texture(b_texture, b_texcoord);
float
noiseClamped
=
texture(n_texture, v_position
/
256.0
).r;
float
noiseIntensity
=
(noiseClamped
*
4.0
)
-
2.0
;
vec3
lumcoeff
=
vec3
(
0.299
,
0.587
,
0.114
);
float
luminance
=
dot
(result.rgb, lumcoeff);
float
lum
=
smoothstep
(
0.2
,
0.0
, luminance)
+
luminance;
vec3
noiseColor
=
mix
(
vec3
(noiseIntensity),
vec3
(
0.0
),
pow
(lum,
4.0
));
result.rgb
=
result.rgb
+
noiseColor
*
noiseGrain;
return
result;
}
void
main() {
vec2
fc
=
v_position;
float
inside
=
insideTexture()
*
(
1.0
-
paused);
vec4
result;
float
backgroundOpacity
=
shadow.w;
vec4
mainColor
=
texture(s_texture, v_texcoord);
result
=
mainColor
*
inside
+
(
1.0
-
inside)
*
(backgroundOpacity
*
background()
+
(
1.0
-
backgroundOpacity)
*
frameBg);
float
shadowCoord
=
fc.y
-
roundRect.y;
float
shadowValue
=
max
(
1.0
-
(shadowCoord
/
shadow.x),
0.0
);
float
shadowShown
=
max
(shadowValue
*
shadow.y, paused)
*
shadow.z;
result
=
vec4
(result.rgb
*
(
1.0
-
shadowShown), result.a);
vec2
roundOutline
=
roundedCorner(fc);
result
=
result
*
roundOutline.y
+
vec4
(outlineFg.rgb,
1.0
)
*
(
1.0
-
roundOutline.y);
result
=
result
*
roundOutline.x
+
roundBg
*
(
1.0
-
roundOutline.x);
fragColor
=
result;
}
Back
|
FazBrowse Home
|
New Git URL