11 static constexpr
const char* vertex = R
"(uniform mat4 u_matrix;
12 uniform vec2 u_tl_parent;
13 uniform float u_scale_parent;
14 uniform float u_buffer_scale;
16 layout (location = 0) in vec2 a_pos;
17 layout (location = 1) in vec2 a_texture_pos;
23 gl_Position = u_matrix * vec4(a_pos, 0, 1);
24 // We are using Int16 for texture position coordinates to give us enough precision for
25 // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer
26 // as an arbitrarily high number to preserve adequate precision when rendering.
27 // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates,
28 // so math for modifying either is consistent.
29 v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5;
30 v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent;
33 static constexpr
const char* fragment = R
"(uniform float u_fade_t;
34 uniform float u_opacity;
35 uniform sampler2D u_image0;
36 uniform sampler2D u_image1;
40 uniform float u_brightness_low;
41 uniform float u_brightness_high;
43 uniform float u_saturation_factor;
44 uniform float u_contrast_factor;
45 uniform vec3 u_spin_weights;
49 // read and cross-fade colors from the main and parent tiles
50 vec4 color0 = texture(u_image0, v_pos0);
51 vec4 color1 = texture(u_image1, v_pos1);
53 color0.rgb = color0.rgb / color0.a;
56 color1.rgb = color1.rgb / color1.a;
58 vec4 color = mix(color0, color1, u_fade_t);
64 dot(rgb, u_spin_weights.xyz),
65 dot(rgb, u_spin_weights.zxy),
66 dot(rgb, u_spin_weights.yzx));
69 float average = (color.r + color.g + color.b) / 3.0;
70 rgb += (average - rgb) * u_saturation_factor;
73 rgb = (rgb - 0.5) * u_contrast_factor + 0.5;
76 vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);
77 vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);
79 fragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a);
81 #ifdef OVERDRAW_INSPECTOR
82 fragColor = vec4(1.0);
@ OpenGL
The OpenGL API backend.
BuiltIn
This enum is used with the ShaderSource template to select source code for the desired program and gr...
Select shader source based on a program type and a desired graphics API.