diff options
Diffstat (limited to 'shaders')
| -rw-r--r-- | shaders/decor.frag.glsl | 22 | ||||
| -rw-r--r-- | shaders/prebuilt/decor.frag.spv | bin | 3772 -> 2176 bytes | |||
| -rw-r--r-- | shaders/prebuilt/ui.frag.spv | bin | 6188 -> 3184 bytes | |||
| -rw-r--r-- | shaders/prebuilt/ui.vert.spv | bin | 4072 -> 3848 bytes | |||
| -rw-r--r-- | shaders/ui.frag.glsl | 48 | ||||
| -rw-r--r-- | shaders/ui.vert.glsl | 16 |
6 files changed, 12 insertions, 74 deletions
diff --git a/shaders/decor.frag.glsl b/shaders/decor.frag.glsl index 5a6ac458..71bb12e3 100644 --- a/shaders/decor.frag.glsl +++ b/shaders/decor.frag.glsl @@ -4,21 +4,16 @@ // pipeline blends (backgroundLayerBlend). Ink (a cursor) is drawn with the // opacity uniform at 1. // -// Flat: a hard-edged fill (a rule, a rail, a grip mark, a bar cursor). Its -// colour rides in the cell's ground (a_bg), its coverage in a_fg.r, so the -// result is the overlay pipeline's exactly. -// -// Checker (flag 0x08000000): two colours in squares, or in stripes, see main. +// A hard-edged fill (a rule, a rail, a grip mark, a bar cursor): its colour +// rides in the cell's ground (a_bg), its coverage in a_fg.r, so the result +// is the overlay pipeline's exactly. layout(std140, set = 3, binding = 0) uniform UiUniforms { float background_opacity; } 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 uvec2 v_effect; layout(location = 5) flat in vec4 v_clip; layout(location = 0) out vec4 o_col; @@ -27,16 +22,5 @@ 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 opacity = clamp(u_ui.background_opacity, 0.0, 1.0); - // Checker (flag 0x08000000): squares of v_uv.x pixels from the quad's - // own corner, so it moves with its rail, in the ground's colour and the - // ink's (lapis's scroll track). - vec2 in_quad = v_cell_uv / max(vec2(dFdx(v_cell_uv.x), dFdy(v_cell_uv.y)), vec2(1e-6)); - if ((v_effect.x & 0x08000000u) != 0u) { - ivec2 q = ivec2(floor(in_quad / max(v_uv.x, 1.0))); - // v_uv.y set: stripes across the quad (lapis's title bar), not squares. - int k = v_uv.y > 0.5 ? q.y : q.x + q.y; - o_col = vec4(((k & 1) == 0 ? v_bg : v_fg) * opacity, 1.0); - return; - } o_col = vec4(v_bg * opacity, v_fg.r); } diff --git a/shaders/prebuilt/decor.frag.spv b/shaders/prebuilt/decor.frag.spv Binary files differindex 6ec3fe61..0d5af9d2 100644 --- a/shaders/prebuilt/decor.frag.spv +++ b/shaders/prebuilt/decor.frag.spv diff --git a/shaders/prebuilt/ui.frag.spv b/shaders/prebuilt/ui.frag.spv Binary files differindex aa788c0b..91022fe2 100644 --- a/shaders/prebuilt/ui.frag.spv +++ b/shaders/prebuilt/ui.frag.spv diff --git a/shaders/prebuilt/ui.vert.spv b/shaders/prebuilt/ui.vert.spv Binary files differindex 4e90e521..ad132bf9 100644 --- a/shaders/prebuilt/ui.vert.spv +++ b/shaders/prebuilt/ui.vert.spv diff --git a/shaders/ui.frag.glsl b/shaders/ui.frag.glsl index 68bfe70b..7f70629a 100644 --- a/shaders/ui.frag.glsl +++ b/shaders/ui.frag.glsl @@ -3,26 +3,16 @@ // 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 uvec2 v_effect; +layout(location = 4) flat in uint v_effect; layout(location = 5) flat in vec4 v_clip; layout(location = 0) out vec4 o_col; @@ -32,41 +22,15 @@ void main() { gl_FragCoord.y < v_clip.y || gl_FragCoord.y >= v_clip.w)) discard; float a = texture(u_atlas, v_uv).r; // 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 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); + // cell background: keep it visible at WindowOpacity 0. Otherwise the + // ground's coverage is the setting's. The flag is shared with + // ui.vert.glsl and src/gui/gui.zig. + float bgA = (v_effect & 0x20000000u) != 0u ? 1.0 : clamp(u_ui.background_opacity, 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.y: 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.y)); - 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 under = vec4(v_bg * bgA, bgA); vec4 cell = vec4(mix(under.rgb, v_fg, a), mix(under.a, 1.0, a)); // FreeType's hinted grayscale bitmap is already the intended coverage. diff --git a/shaders/ui.vert.glsl b/shaders/ui.vert.glsl index 313070c6..e3532e68 100644 --- a/shaders/ui.vert.glsl +++ b/shaders/ui.vert.glsl @@ -9,11 +9,8 @@ layout(location = 0) in vec4 a_rect; // x0, y0, x1, y1 layout(location = 1) in vec4 a_uv_rect; // u0, v0, u1, v1 layout(location = 2) in vec3 a_fg; layout(location = 3) in vec3 a_bg; -// Flags, and the theme's dots' offset (G13's parallax) as a float's bits. -// The flags are the high bits of x: a see-through cell background, an -// opaque block-cursor fill, a dotted page ground (ui.frag.glsl) and a -// checker (decor) or a file name's shadow (ui). -layout(location = 4) in uvec2 a_effect; +// Flags, the high bits: an opaque block-cursor fill (ui.frag.glsl). +layout(location = 4) in uint a_effect; // A clip rectangle in target pixels (x0, y0, x1, y1): the fragment shader // drops what lies outside it. x1 < x0 is none. layout(location = 5) in vec4 a_clip; @@ -21,8 +18,7 @@ layout(location = 5) in vec4 a_clip; layout(location = 0) out vec2 v_uv; layout(location = 1) out vec3 v_fg; layout(location = 2) out vec3 v_bg; -layout(location = 3) out vec2 v_cell_uv; -layout(location = 4) flat out uvec2 v_effect; +layout(location = 4) flat out uint v_effect; layout(location = 5) flat out vec4 v_clip; void main() { @@ -32,27 +28,21 @@ void main() { if (corner == 0) { pos = vec2(a_rect.x, a_rect.y); uv = vec2(a_uv_rect.x, a_uv_rect.y); - v_cell_uv = vec2(0.0, 0.0); } else if (corner == 1) { pos = vec2(a_rect.z, a_rect.y); uv = vec2(a_uv_rect.z, a_uv_rect.y); - v_cell_uv = vec2(1.0, 0.0); } else if (corner == 2) { pos = vec2(a_rect.z, a_rect.w); uv = vec2(a_uv_rect.z, a_uv_rect.w); - v_cell_uv = vec2(1.0, 1.0); } else if (corner == 3) { pos = vec2(a_rect.x, a_rect.y); uv = vec2(a_uv_rect.x, a_uv_rect.y); - v_cell_uv = vec2(0.0, 0.0); } else if (corner == 4) { pos = vec2(a_rect.z, a_rect.w); uv = vec2(a_uv_rect.z, a_uv_rect.w); - v_cell_uv = vec2(1.0, 1.0); } else { pos = vec2(a_rect.x, a_rect.w); uv = vec2(a_uv_rect.x, a_uv_rect.w); - v_cell_uv = vec2(0.0, 1.0); } v_uv = uv; v_fg = a_fg; |
