diff options
Diffstat (limited to 'shaders/prebuilt/ui.frag.glsl')
| -rw-r--r-- | shaders/prebuilt/ui.frag.glsl | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/shaders/prebuilt/ui.frag.glsl b/shaders/prebuilt/ui.frag.glsl deleted file mode 100644 index 51ec5b8c..00000000 --- a/shaders/prebuilt/ui.frag.glsl +++ /dev/null @@ -1,93 +0,0 @@ -#version 450 - -// Sample the glyph atlas (R = coverage 0..1) and mix the cell's bg up to its fg -// by that coverage. Output is PREMULTIPLIED: an opaque cell is unchanged. -// WindowOpacity changes only the ground's coverage, never the glyph's ink. -// A cell whose background is the see-through ground (config.gui_transparent, -// a theme with no bg of its own) still contributes only its ink, at the ink's -// own coverage, so the compositor keeps the rest. - -layout(set = 2, binding = 0) uniform sampler2D u_atlas; -layout(std140, set = 3, binding = 0) uniform UiUniforms { - float background_opacity; - // A theme's ornament (colors.Decor): the page's dots (rgb, strength), - // their geometry (period, solid radius, faded radius, in pixels), and a - // file name's shadow (rgb, offset in pixels). - vec4 decor_dots; - vec4 decor_dot_geom; - vec4 decor_shadow; -} u_ui; - -layout(location = 0) in vec2 v_uv; -layout(location = 1) in vec3 v_fg; -layout(location = 2) in vec3 v_bg; -layout(location = 3) in vec2 v_cell_uv; -layout(location = 4) flat in uvec4 v_effect; -layout(location = 5) flat in vec4 v_clip; - -layout(location = 0) out vec4 o_col; - -void main() { - if (v_clip.z >= v_clip.x && (gl_FragCoord.x < v_clip.x || gl_FragCoord.x >= v_clip.z || - gl_FragCoord.y < v_clip.y || gl_FragCoord.y >= v_clip.w)) discard; - float a = texture(u_atlas, v_uv).r; - bool oldLayer = (v_effect.x & 0x80000000u) != 0u; - // A block cursor is foreground chrome even though its fill occupies the - // cell background: keep it visible at WindowOpacity 0. Otherwise a clear - // theme ground has no coverage and ordinary backgrounds use the setting. - // The three high flags are shared with ui.vert.glsl and src/gui/gui.zig. - float bgA = (v_effect.x & 0x20000000u) != 0u ? 1.0 - : (v_effect.x & 0x40000000u) != 0u ? 0.0 - : clamp(u_ui.background_opacity, 0.0, 1.0); - uint effect = v_effect.x & 0x07ffffffu; - float progress = clamp(uintBitsToFloat(v_effect.y), 0.0, 1.0); - - // Ink over ground, both premultiplied: v_fg*a + (v_bg*bgA)*(1-a), which is - // mix() with the ground already premultiplied. At bgA = 1 that is exactly - // the mix(v_bg, v_fg, a) at alpha 1 this shader always wrote. - vec3 ground = v_bg; - // 0x10000000: the page's ground under a pane body, dotted (lapis): a - // dot every period pixels, fixed to the window, under the text. - if ((v_effect.x & 0x10000000u) != 0u) { - float period = u_ui.decor_dot_geom.x; - // v_effect.z: how far its pane's text has moved the dots (G13's - // parallax), in pixels, as a float's bits (0 without). - vec2 at = gl_FragCoord.xy - vec2(0.0, uintBitsToFloat(v_effect.z)); - vec2 d = mod(at, period) - 0.5 * period; - float dot_a = 1.0 - smoothstep(u_ui.decor_dot_geom.y, u_ui.decor_dot_geom.z, length(d)); - ground = mix(ground, u_ui.decor_dots.rgb, u_ui.decor_dots.a * dot_a); - } - vec4 under = vec4(ground * bgA, bgA); - // Derivatives outside any branch: a pixel's step in the atlas and in - // the cell, for the shadow's offset. - vec2 step_uv = vec2(dFdx(v_uv.x), dFdy(v_uv.y)) * u_ui.decor_shadow.a; - vec2 step_cell = vec2(dFdx(v_cell_uv.x), dFdy(v_cell_uv.y)) * u_ui.decor_shadow.a; - // 0x08000000: a file name's letters cast a shadow down and right onto - // their own cell's ground (lapis), under the ink; what would fall past - // the cell's edge is not drawn. - if ((v_effect.x & 0x08000000u) != 0u) { - vec2 from = v_cell_uv - step_cell; - float s = all(greaterThanEqual(from, vec2(0.0))) ? texture(u_atlas, v_uv - step_uv).r : 0.0; - under = mix(under, vec4(u_ui.decor_shadow.rgb, 1.0), s); - } - vec4 cell = vec4(mix(under.rgb, v_fg, a), mix(under.a, 1.0, a)); - - // 3 = dissolve, a crossfade (G7): a changed cell's new form is drawn - // first, whole, and its frozen old one over it at 1 - progress, - // premultiplied (the frame's cells blend over, pipeline_over), so the - // old fades out as the new comes in; at the ends, exactly one of them. - // The tty keeps its per-cell swap (panel_animation.dissolveRevealed). - if (effect == 3u) { - if (!oldLayer) { - o_col = cell; - return; - } - if (progress >= 1.0) discard; - o_col = cell * (1.0 - progress); - return; - } - - // FreeType's hinted grayscale bitmap is already the intended coverage. - // Preserve it exactly; weight-changing gamma hacks blur small stems. - o_col = cell; -} |
