Improve clarity of tutorial11 in terms of updates, files

pull/271/head
Neil Blakey-Milner 3 years ago
parent 41d8286645
commit 6f388ff8eb

@ -16,7 +16,7 @@ We'll need to modify our `Material` struct in `model.rs` to include a `normal_te
pub struct Material {
pub name: String,
pub diffuse_texture: texture::Texture,
pub normal_texture: texture::Texture,
pub normal_texture: texture::Texture, // UPDATED!
pub bind_group: wgpu::BindGroup,
}
```
@ -228,20 +228,19 @@ impl Model {
let mut vertices = Vec::new();
for i in 0..m.mesh.positions.len() / 3 {
vertices.push(ModelVertex {
// Add .into() to convert arrays to cgmath::VectorN
position: [
// ...
].into(),
],
tex_coords: [
// ...
].into(),
],
normal: [
// ...
].into(),
],
// ...
// We'll calculate these later
tangent: [0.0; 3].into(),
bitangent: [0.0; 3].into(),
tangent: [0.0; 3],
bitangent: [0.0; 3],
});
}
@ -587,20 +586,25 @@ where
I found a cobblestone texture with matching normal map, and created a `debug_material` for that.
```rust
// new()
let debug_material = {
let diffuse_bytes = include_bytes!("../res/cobble-diffuse.png");
let normal_bytes = include_bytes!("../res/cobble-normal.png");
let diffuse_texture = texture::Texture::from_bytes(&device, &queue, diffuse_bytes, "res/alt-diffuse.png", false).unwrap();
let normal_texture = texture::Texture::from_bytes(&device, &queue, normal_bytes, "res/alt-normal.png", true).unwrap();
model::Material::new(&device, "alt-material", diffuse_texture, normal_texture, &texture_bind_group_layout)
};
Self {
// ...
#[allow(dead_code)]
debug_material,
// main.rs
impl State {
async fn new(window: &Window) -> Result<Self> {
// ...
let debug_material = {
let diffuse_bytes = include_bytes!("../res/cobble-diffuse.png");
let normal_bytes = include_bytes!("../res/cobble-normal.png");
let diffuse_texture = texture::Texture::from_bytes(&device, &queue, diffuse_bytes, "res/alt-diffuse.png", false).unwrap();
let normal_texture = texture::Texture::from_bytes(&device, &queue, normal_bytes, "res/alt-normal.png", true).unwrap();
model::Material::new(&device, "alt-material", diffuse_texture, normal_texture, &texture_bind_group_layout)
};
Self {
// ...
#[allow(dead_code)]
debug_material,
}
}
}
```

Loading…
Cancel
Save