From 2876a669f18b6a9c917881a00cdfcda3a4a2ba1e Mon Sep 17 00:00:00 2001 From: erwanvivien <44021072+erwanvivien@users.noreply.github.com> Date: Sun, 1 Jan 2023 21:28:54 +0100 Subject: [PATCH 1/2] feat: added more information on obj_model setup --- docs/beginner/tutorial9-models/README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/beginner/tutorial9-models/README.md b/docs/beginner/tutorial9-models/README.md index f5e15202..e00dc0df 100644 --- a/docs/beginner/tutorial9-models/README.md +++ b/docs/beginner/tutorial9-models/README.md @@ -62,6 +62,8 @@ impl Vertex for ModelVertex { This is basically the same as the original `VertexBufferLayout`, but we added a `VertexAttribute` for the `normal`. Remove the `Vertex` struct in `lib.rs` as we won't need it anymore, and use our new `Vertex` from `model` for the `RenderPipeline`. +We will also remove our homemade `vertex_buffer`, `index_buffer` and `num_indicdes`. + ```rust let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { // ... @@ -417,6 +419,8 @@ where We could have put these methods in an `impl Model`, but I felt it made more sense to have the `RenderPass` do all the rendering, as that's kind of its job. This does mean we have to import `DrawModel` when we go to render though. +When we removed `vertex_buffer`, etc. we also removed their render_pass setup. + ```rust // lib.rs render_pass.set_vertex_buffer(1, self.instance_buffer.slice(..)); @@ -431,12 +435,10 @@ render_pass.draw_mesh_instanced(&self.obj_model.meshes[0], 0..self.instances.len Before that though we need to actually load the model and save it to `State`. Put the following in `State::new()`. ```rust -let obj_model = resources::load_model( - "cube.obj", - &device, - &queue, - &texture_bind_group_layout, -).await.unwrap(); +let obj_model = + resources::load_model("cube.obj", &device, &queue, &texture_bind_group_layout) + .await + .unwrap(); ``` Our new model is a bit bigger than our previous one so we're gonna need to adjust the spacing on our instances a bit. From ad1776684b9e863f902bdd75aa7afe3d6287ca30 Mon Sep 17 00:00:00 2001 From: erwanvivien <44021072+erwanvivien@users.noreply.github.com> Date: Sat, 14 Jan 2023 19:49:41 +0100 Subject: [PATCH 2/2] fix: typo indicdes -> indices --- docs/beginner/tutorial9-models/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/beginner/tutorial9-models/README.md b/docs/beginner/tutorial9-models/README.md index e00dc0df..061bdc83 100644 --- a/docs/beginner/tutorial9-models/README.md +++ b/docs/beginner/tutorial9-models/README.md @@ -62,7 +62,7 @@ impl Vertex for ModelVertex { This is basically the same as the original `VertexBufferLayout`, but we added a `VertexAttribute` for the `normal`. Remove the `Vertex` struct in `lib.rs` as we won't need it anymore, and use our new `Vertex` from `model` for the `RenderPipeline`. -We will also remove our homemade `vertex_buffer`, `index_buffer` and `num_indicdes`. +We will also remove our homemade `vertex_buffer`, `index_buffer` and `num_indices`. ```rust let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {