2022-09-21 00:44:56 +00:00
|
|
|
/// Shader used for drawing bitmap fills.
|
|
|
|
|
2023-01-06 22:17:42 +00:00
|
|
|
#import common
|
|
|
|
|
2022-09-21 00:44:56 +00:00
|
|
|
struct VertexOutput {
|
|
|
|
@builtin(position) position: vec4<f32>,
|
|
|
|
@location(0) uv: vec2<f32>,
|
|
|
|
};
|
|
|
|
|
2024-01-23 20:28:12 +00:00
|
|
|
@group(1) @binding(0) var<uniform> transforms: common::Transforms;
|
|
|
|
@group(2) @binding(0) var<uniform> textureTransforms: common::TextureTransforms;
|
|
|
|
@group(2) @binding(1) var texture: texture_2d<f32>;
|
|
|
|
@group(2) @binding(2) var texture_sampler: sampler;
|
2023-01-06 22:17:42 +00:00
|
|
|
|
2022-09-21 00:44:56 +00:00
|
|
|
@vertex
|
2023-01-06 22:17:42 +00:00
|
|
|
fn main_vertex(in: common::VertexInput) -> VertexOutput {
|
2023-01-19 03:17:54 +00:00
|
|
|
let matrix_ = textureTransforms.texture_matrix;
|
2022-09-21 00:44:56 +00:00
|
|
|
let uv = (mat3x3<f32>(matrix_[0].xyz, matrix_[1].xyz, matrix_[2].xyz) * vec3<f32>(in.position, 1.0)).xy;
|
2023-01-06 22:17:42 +00:00
|
|
|
let pos = common::globals.view_matrix * transforms.world_matrix * vec4<f32>(in.position.x, in.position.y, 0.0, 1.0);
|
2022-09-21 00:44:56 +00:00
|
|
|
return VertexOutput(pos, uv);
|
|
|
|
}
|
|
|
|
|
|
|
|
@fragment
|
|
|
|
fn main_fragment(in: VertexOutput) -> @location(0) vec4<f32> {
|
|
|
|
return textureSample(texture, texture_sampler, in.uv);
|
|
|
|
}
|