git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

scenefx/render/fx_renderer/shaders/quad.frag (907B)

 1 #define EFFECTS %d
 2 
 3 #if !defined(EFFECTS)
 4 #error "Missing shader preamble"
 5 #endif
 6 
 7 #ifdef GL_FRAGMENT_PRECISION_HIGH
 8 precision highp float;
 9 #else
10 precision mediump float;
11 #endif
12 
13 varying vec4 v_color;
14 varying vec2 v_texcoord;
15 
16 #if EFFECTS
17 uniform vec2 clip_size;
18 uniform vec2 clip_position;
19 uniform float clip_radius_top_left;
20 uniform float clip_radius_top_right;
21 uniform float clip_radius_bottom_left;
22 uniform float clip_radius_bottom_right;
23 #endif
24 
25 float corner_alpha(vec2 size, vec2 position, bool is_cutout,
26 		float radius_tl, float radius_tr, float radius_bl, float radius_br);
27 
28 void main() {
29 #if EFFECTS
30 	// Clipping
31 	float clip_corner_alpha = corner_alpha(
32 		clip_size - 1.0,
33 		clip_position + 0.5,
34 		true,
35 		clip_radius_top_left,
36 		clip_radius_top_right,
37 		clip_radius_bottom_left,
38 		clip_radius_bottom_right
39 	);
40 
41 	gl_FragColor = v_color * clip_corner_alpha;
42 #else
43 	gl_FragColor = v_color;
44 #endif
45 }