[oden] Color and position for text
This commit is contained in:
parent
079006acdc
commit
a08bc07cbb
6 changed files with 29 additions and 17 deletions
|
|
@ -12,16 +12,19 @@ struct InstanceInput {
|
|||
@location(6) src_dims: vec2<f32>,
|
||||
@location(7) dest_top_left: vec2<f32>,
|
||||
@location(8) dest_dims: vec2<f32>,
|
||||
@location(9) color: vec4<f32>,
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
@builtin(position) clip_position : vec4<f32>,
|
||||
@location(0) tex_coords : vec2<f32>,
|
||||
@location(1) color: vec4<f32>,
|
||||
};
|
||||
|
||||
@vertex fn vs_main(vertex : VertexInput, instance : InstanceInput)->VertexOutput {
|
||||
var out : VertexOutput;
|
||||
out.tex_coords = instance.src_top_left + (vertex.tex_coords * instance.src_dims);
|
||||
out.color = instance.color;
|
||||
|
||||
let in_pos = instance.dest_top_left + (vec2f(vertex.position.x, vertex.position.y) * instance.dest_dims);
|
||||
|
||||
|
|
@ -38,16 +41,22 @@ struct VertexOutput {
|
|||
@group(1) @binding(1) var s_diffuse : sampler;
|
||||
|
||||
@fragment fn fs_main(in : VertexOutput)->@location(0) vec4<f32> {
|
||||
// TODO: Should we be sampling here for the shader?
|
||||
|
||||
let tc = vec2(u32(in.tex_coords.x), u32(in.tex_coords.y));
|
||||
let c = textureLoad(t_diffuse, tc, 0);
|
||||
|
||||
// If we were going to run this through the sampler it would look like
|
||||
// this... but I don't know if that'w what we should do? Right now the
|
||||
// direct load looks better?
|
||||
//
|
||||
// let tc = in.tex_coords / vec2<f32>(textureDimensions(t_diffuse));
|
||||
// let c = textureSample(t_diffuse, s_diffuse, tc);
|
||||
|
||||
|
||||
return vec4<f32>(c.r,c.r,c.r,c.r);
|
||||
return vec4<f32>(
|
||||
c.r * in.color.x,
|
||||
c.r * in.color.y,
|
||||
c.r * in.color.z,
|
||||
c.r * in.color.a
|
||||
);
|
||||
//return vec4<f32>(1.0,1.0,1.0,1.0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue