started fragment shader terrain version

pull/379/head
Ben Hansen 2 years ago
parent 844a1d1287
commit 0fa9eb1e6f

@ -119,7 +119,7 @@ impl TerrainPipeline {
label: Some("TerrainPipeline::ComputePipeline"),
layout: Some(&pipeline_layout),
module: &shader,
entry_point: "gen_terrain",
entry_point: "gen_terrain_compute",
});
let render_pipeline_layout =

@ -97,7 +97,7 @@ fn terrain_vertex(p: vec2<f32>) -> Vertex {
}
[[stage(compute), workgroup_size(64)]]
fn gen_terrain(
fn gen_terrain_compute(
[[builtin(global_invocation_id)]] gid: vec3<u32>
) {
// Create vertex
@ -128,6 +128,36 @@ fn gen_terrain(
indices.data[start_index + 5u] = v10;
}
struct VertexOutput {
[[location(0)]] uv: vec2<f32>;
[[builtin(position)]] position: vec4<f32>;
};
// Draws a fullscreen quad
[[stage(vertex)]]
fn gen_terrain_vertex(
[[builtin(vertex_index)]] index: u32,
) {
let u = f32(((index + 2u) / 3u) % 2u);
let v = f32(((index + 1u) / 3u) % 2u);
let uv = vec2<f32>(u, v);
let position = vec4<f32>(-1.0 + uv * 2.0, 0.0, 1.0);
return VertexOutput(vec2<f32>(uv.x, 1.0-uv.y), position);
}
struct FragmentOutput {
[[location(0)]] output: u32;
};
[[stage(fragment)]]
fn fs_main(in: VertexOutput) -> FragmentOutput {
var output = 0u;
return FragmentOutput(output);
}
// ============================
// Terrain Rendering
// ============================

@ -207,7 +207,7 @@ If you want learn more about workgroups [check out the docs](https://www.w3.org/
</div>
<!-- Talking about gen_terrain -->
TODO:
- Note changes to `create_render_pipeline`

Loading…
Cancel
Save