With all that done, you should get something like this.
![cubes.png](./cubes.png)
@ -297,8 +321,53 @@ impl<'a> DrawModel for wgpu::RenderPass<'a> {
}
```
We need to change the render code to reflect this.
```rust
render_pass.set_pipeline(&self.render_pipeline);
let mesh = &self.obj_model.meshes[0];
let material = &self.obj_model.materials[mesh.material];
render_pass.draw_mesh_instanced(mesh, material, 0..self.instances.len() as u32, &self.uniform_bind_group);
```
With all that in place we should get the following.
![cubes-correct.png](./cubes-correct.png)
## Rendering the entire model
Right now we are specifying the mesh and the material directly. This is useful if we want to draw a mesh with a different material. We're also not rendering other parts of the model (if we had some). Let's create a method for `DrawModel` that will draw all the parts of the model with their respective materials.