Text: alpha blending of the fonts is not applied correctly in shader #1245

Open
opened 2024-08-14 20:19:06 +00:00 by hordurj · 0 comments
hordurj commented 2024-08-14 20:19:06 +00:00 (Migrated from github.com)

The glyph texture uses the alpha channel to anti-alias fonts. This information is not correctly used in the text shader.

return vec4<f32>(color.rgb * c.a, color.a);

where c.a is the font texture.

this will make the color darker which will only work on a black background. Instead, the following should be used:

return vec4<f32>(color.rgb, c.a);

This will properly blend the font with the background. If the alpha channel in the color should be used to make transparent text, then

return vec4<f32>(color.rgb, color.a * c.a);

could be used.

Example:

Before:
before

After:
after

The glyph texture uses the alpha channel to anti-alias fonts. This information is not correctly used in the text shader. ``` return vec4<f32>(color.rgb * c.a, color.a); ``` where c.a is the font texture. this will make the color darker which will only work on a black background. Instead, the following should be used: ``` return vec4<f32>(color.rgb, c.a); ``` This will properly blend the font with the background. If the alpha channel in the color should be used to make transparent text, then ``` return vec4<f32>(color.rgb, color.a * c.a); ``` could be used. Example: Before: ![before](https://github.com/user-attachments/assets/60e90aa0-a3ee-40fc-936c-82a4825da355) After: ![after](https://github.com/user-attachments/assets/62f68f73-6970-41b8-808d-93356006292b)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#1245
No description provided.