Skip to content

Commit

Permalink
feat: render-to-texture
Browse files Browse the repository at this point in the history
  • Loading branch information
philpax committed Oct 2, 2022
1 parent f12215e commit 1902edc
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 56 deletions.
27 changes: 27 additions & 0 deletions src/blit.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
struct BlitVertexInput {
@location(0) position: vec3<f32>,
@location(1) uv_coords: vec2<f32>,
}

struct BlitVertexOutput {
@builtin(position) position: vec4<f32>,
@location(0) uv_coords: vec2<f32>,
}

@group(0) @binding(0)
var blit_texture: texture_2d<f32>;
@group(0)@binding(1)
var blit_sampler: sampler;

@vertex
fn blit_vs_main(model: BlitVertexInput) -> BlitVertexOutput {
var out: BlitVertexOutput;
out.position = vec4<f32>(model.position, 1.0);
out.uv_coords = model.uv_coords;
return out;
}

@fragment
fn blit_fs_main(in: BlitVertexOutput) -> @location(0) vec4<f32> {
return textureSample(blit_texture, blit_sampler, in.uv_coords);
}
Loading

0 comments on commit 1902edc

Please sign in to comment.