diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-05 19:09:10 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-05 19:09:10 -0500 |
| commit | a9fb380f9d0b53cde554b265d9c6b66d26183c38 (patch) | |
| tree | 8ea3648c497d4a3ac8ce2f6dafa2beca324e7249 /assets | |
| parent | 61e179f9580c985cb5ca80ea732fc7572d31c489 (diff) | |
pke: mtsdf displays, bypass fg/bg not working
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/shaders/glyph.frag | 9 | ||||
| -rw-r--r-- | assets/shaders/glyph.vert | 20 |
2 files changed, 14 insertions, 15 deletions
diff --git a/assets/shaders/glyph.frag b/assets/shaders/glyph.frag index ad9a6d1..5387f4e 100644 --- a/assets/shaders/glyph.frag +++ b/assets/shaders/glyph.frag @@ -2,9 +2,8 @@ layout(location = 0) in vec4 in_fg_color; layout(location = 1) in vec4 in_bg_color; -layout(location = 2) in vec4 in_sprite_region; -layout(location = 3) in vec2 in_uv; -layout(location = 4) in float in_width; +layout(location = 2) in vec2 in_uv; +layout(location = 3) in float in_width; layout(location = 0) out vec4 out_color; @@ -15,10 +14,10 @@ float median(float r, float g, float b) { } void main() { - vec2 atlas_coord = (in_uv - in_sprite_region.xy) / in_sprite_region.zw; - vec4 msd = texture(mtsdf_sampler, atlas_coord); + vec4 msd = texture(mtsdf_sampler, in_uv); float sd = median(msd.r, msd.g, msd.b); float screenPxDistance = in_width * (sd - 0.5); float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0); out_color = mix(in_bg_color, in_fg_color, opacity); + out_color = msd; } diff --git a/assets/shaders/glyph.vert b/assets/shaders/glyph.vert index f48056d..9907ce1 100644 --- a/assets/shaders/glyph.vert +++ b/assets/shaders/glyph.vert @@ -3,18 +3,19 @@ // vertex layout(location = 0) in vec2 in_position; layout(location = 1) in vec2 in_uv; +layout(location = 2) in vec2 in_atlas_size; // instance -layout(location = 2) in vec4 in_fg_color; -layout(location = 3) in vec4 in_bg_color; -layout(location = 4) in ivec4 in_sprite_region; -layout(location = 5) in float in_width; +layout(location = 3) in vec4 in_fg_color; +layout(location = 4) in vec4 in_bg_color; +layout(location = 5) in vec2 in_sprite_region_min; +layout(location = 6) in vec2 in_sprite_region_max; +layout(location = 7) in float in_width; layout(location = 0) out vec4 out_fg_color; layout(location = 1) out vec4 out_bg_color; -layout(location = 2) out vec4 out_sprite_region; -layout(location = 3) out vec2 out_uv; -layout(location = 4) out float out_width; +layout(location = 2) out vec2 out_uv; +layout(location = 3) out float out_width; out gl_PerVertex { @@ -23,10 +24,9 @@ out gl_PerVertex void main() { - gl_Position = vec4(in_position, 0.0, 1.0); + gl_Position = vec4(in_position / 4.0, 0.0, 1.0); out_fg_color = in_fg_color; out_bg_color = in_bg_color; - out_sprite_region = in_sprite_region; - out_uv = in_uv; + out_uv = mix(in_sprite_region_min, in_sprite_region_max, in_uv) / in_atlas_size; out_width = in_width; } |
