summaryrefslogtreecommitdiff
path: root/src/shader.wgsl
diff options
context:
space:
mode:
authorTengu712 <genreihoutengu@gmail.com>2026-09-26 21:36:43 +0900
committerTengu712 <genreihoutengu@gmail.com>2026-09-26 21:36:43 +0900
commitf6d058be6639c8e052c5a38dea4f33d6b26ae20c (patch)
treef101cc3ff0a9c620274360672973943d710e9a9d /src/shader.wgsl
parentb27234e27bbaf4d7f7f3467de64bd95ff2145c0e (diff)
add texture
Diffstat (limited to 'src/shader.wgsl')
-rw-r--r--src/shader.wgsl21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/shader.wgsl b/src/shader.wgsl
index 9f158f1..c154cc4 100644
--- a/src/shader.wgsl
+++ b/src/shader.wgsl
@@ -1,10 +1,23 @@
+@group(0) @binding(0) var tex_sampler: sampler;
+@group(0) @binding(1) var font_tex: texture_2d<f32>;
+
+struct VertexOutput {
+ @builtin(position) position: vec4<f32>,
+ @location(0) uv: vec2<f32>,
+}
+
@vertex
-fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4<f32> {
+fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> VertexOutput {
let uv = vec2<f32>(f32((in_vertex_index << 1) & 2), f32(in_vertex_index & 2)) / 2.0;
- return vec4<f32>(uv.x - 0.5, uv.y - 0.5, 0.0, 1.0);
+
+ var out: VertexOutput;
+ out.position = vec4<f32>(uv.x - 0.5, uv.y - 0.5, 0.0, 1.0);
+ out.uv = uv;
+
+ return out;
}
@fragment
-fn fs_main() -> @location(0) vec4<f32> {
- return vec4<f32>(1.0, 1.0, 1.0, 1.0);
+fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
+ return vec4<f32>(1.0, 1.0, 1.0, textureSample(font_tex, tex_sampler, in.uv).r);
}