MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fill_outline.hpp
Go to the documentation of this file.
1 // Generated code, do not modify this file!
2 // Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js
3 
4 #pragma once
6 
7 namespace mbgl {
8 namespace shaders {
9 
11  static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos;
12 
13 uniform mat4 u_matrix;
14 uniform vec2 u_world;
15 
16 out vec2 v_pos;
17 
18 #ifndef HAS_UNIFORM_u_outline_color
19 uniform lowp float u_outline_color_t;
20 layout (location = 1) in highp vec4 a_outline_color;
21 out highp vec4 outline_color;
22 #else
23 uniform highp vec4 u_outline_color;
24 #endif
25 #ifndef HAS_UNIFORM_u_opacity
26 uniform lowp float u_opacity_t;
27 layout (location = 2) in lowp vec2 a_opacity;
28 out lowp float opacity;
29 #else
30 uniform lowp float u_opacity;
31 #endif
32 
33 void main() {
34  #ifndef HAS_UNIFORM_u_outline_color
35 outline_color = unpack_mix_color(a_outline_color, u_outline_color_t);
36 #else
37 highp vec4 outline_color = u_outline_color;
38 #endif
39  #ifndef HAS_UNIFORM_u_opacity
40 opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
41 #else
42 lowp float opacity = u_opacity;
43 #endif
44 
45  gl_Position = u_matrix * vec4(a_pos, 0, 1);
46  v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;
47 }
48 )";
49  static constexpr const char* fragment = R"(in vec2 v_pos;
50 
51 #ifndef HAS_UNIFORM_u_outline_color
52 in highp vec4 outline_color;
53 #else
54 uniform highp vec4 u_outline_color;
55 #endif
56 #ifndef HAS_UNIFORM_u_opacity
57 in lowp float opacity;
58 #else
59 uniform lowp float u_opacity;
60 #endif
61 
62 void main() {
63  #ifdef HAS_UNIFORM_u_outline_color
64 highp vec4 outline_color = u_outline_color;
65 #endif
66  #ifdef HAS_UNIFORM_u_opacity
67 lowp float opacity = u_opacity;
68 #endif
69 
70  float dist = length(v_pos - gl_FragCoord.xy);
71  float alpha = 1.0 - smoothstep(0.0, 1.0, dist);
72  fragColor = outline_color * (alpha * opacity);
73 
74 #ifdef OVERDRAW_INSPECTOR
75  fragColor = vec4(1.0);
76 #endif
77 }
78 )";
79 };
80 
81 } // namespace shaders
82 } // namespace mbgl
@ OpenGL
The OpenGL API backend.
BuiltIn
This enum is used with the ShaderSource template to select source code for the desired program and gr...
Definition: actor.hpp:15
Select shader source based on a program type and a desired graphics API.