gfx: Text: add ability to change font color
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
f79351ed59
commit
031164d9b5
2 changed files with 6 additions and 5 deletions
|
|
@ -274,7 +274,7 @@ fn updatePipeline(
|
|||
.size = size.divScalar(px_density),
|
||||
.text_index = num_texts,
|
||||
.uv_pos = vec2(@floatFromInt(r.x), @floatFromInt(r.y)),
|
||||
.font_color = font_color,
|
||||
.color = font_color,
|
||||
});
|
||||
origin_x += glyph.advance.x();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ struct VertexOutput {
|
|||
// Vertex position
|
||||
@builtin(position) Position : vec4<f32>,
|
||||
|
||||
// UV coordinate
|
||||
// UV coordinate into the glyph atlas
|
||||
@location(0) fragUV : vec2<f32>,
|
||||
|
||||
// Color of the glyph
|
||||
|
|
@ -90,6 +90,7 @@ fn vertMain(
|
|||
var output : VertexOutput;
|
||||
output.Position = pos;
|
||||
output.fragUV = uv;
|
||||
output.color = glyph.color;
|
||||
return output;
|
||||
}
|
||||
|
||||
|
|
@ -101,12 +102,12 @@ fn vertMain(
|
|||
|
||||
@fragment
|
||||
fn fragMain(
|
||||
@location(0) fragUV: vec2<f32>
|
||||
@location(0) fragUV: vec2<f32>,
|
||||
@location(1) color: vec4<f32>
|
||||
) -> @location(0) vec4<f32> {
|
||||
var c = textureSample(glyphTexture, glyphSampler, fragUV);
|
||||
if (c.a <= 0.0) {
|
||||
discard;
|
||||
}
|
||||
return c * color;
|
||||
return vec4<f32>(color.rgb * c.a, color.a);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue