Skip to content

Commit

Permalink
fix a dumb text color issue
Browse files Browse the repository at this point in the history
  • Loading branch information
msparkles committed Jul 3, 2024
1 parent 5844a6b commit a37a6c9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions crates/yakui-vulkan/shaders/main.frag
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ void main() {

if (workflow == WORKFLOW_TEXT) {
vec4 coverage = texture(textures[texture_id], in_uv);
float alpha = max(max(coverage.r, coverage.g), coverage.b) * in_color.a;
float has_color = step(0.05, max(max(in_color.r, in_color.g), in_color.b));

float alpha = max(max(coverage.r, coverage.g), coverage.b) * in_color.a * coverage.a;
float has_color = step(0.05, max(max(in_color.r, in_color.g), max(in_color.b, in_color.a)));
vec3 color = in_color.rgb * has_color * alpha + coverage.rgb * (1.0 - has_color);

out_color = vec4(color, alpha);
} else {
vec4 user_texture = texture(textures[texture_id], in_uv);
out_color = in_color * user_texture;
}
}
}
Binary file modified crates/yakui-vulkan/shaders/main.frag.spv
Binary file not shown.
4 changes: 2 additions & 2 deletions crates/yakui-wgpu/shaders/text.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ fn vs_main(
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
let coverage = textureSample(coverage_texture, coverage_sampler, in.texcoord);

let alpha = max(max(coverage.r, coverage.g), coverage.b) * in.color.a;
let has_color = step(0.05, max(max(in.color.r, in.color.g), in.color.b));
let alpha = max(max(coverage.r, coverage.g), coverage.b) * in.color.a * coverage.a;
let has_color = step(0.05, max(max(in.color.r, in.color.g), max(in.color.b, in.color.a)));

let color = in.color.rgb * has_color * alpha + coverage.rgb * (1.0 - has_color);

Expand Down
2 changes: 1 addition & 1 deletion crates/yakui-widgets/src/widgets/render_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fn paint_text(
if render.kind == Kind::Mask {
rect.color = color;
} else {
rect.color = Color::rgba(0, 0, 0, 255);
rect.color = Color::CLEAR;
}
rect.texture = Some((TextureId::Managed(render.texture), render.tex_rect));
rect.pipeline = Pipeline::Text;
Expand Down

0 comments on commit a37a6c9

Please sign in to comment.