|
|
|
@ -183,6 +183,7 @@ fn create_render_pipeline(
|
|
|
|
|
mask: !0,
|
|
|
|
|
alpha_to_coverage_enabled: false,
|
|
|
|
|
},
|
|
|
|
|
multiview: None,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
@ -533,8 +534,8 @@ We're going to need to pull in the normal vector into our `shader.wgsl`.
|
|
|
|
|
```wgsl
|
|
|
|
|
struct VertexInput {
|
|
|
|
|
@location(0) position: vec3<f32>,
|
|
|
|
|
@location(1) tex_coords: vec2<f32>;
|
|
|
|
|
@location(2) normal: vec3<f32>; // NEW!
|
|
|
|
|
@location(1) tex_coords: vec2<f32>,
|
|
|
|
|
@location(2) normal: vec3<f32>, // NEW!
|
|
|
|
|
};
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -542,10 +543,10 @@ We're also going to want to pass that value, as well as the vertex's position to
|
|
|
|
|
|
|
|
|
|
```wgsl
|
|
|
|
|
struct VertexOutput {
|
|
|
|
|
@builtin(position) clip_position: vec4<f32>;
|
|
|
|
|
@location(0) tex_coords: vec2<f32>;
|
|
|
|
|
@location(1) world_normal: vec3<f32>;
|
|
|
|
|
@location(2) world_position: vec3<f32>;
|
|
|
|
|
@builtin(position) clip_position: vec4<f32>,
|
|
|
|
|
@location(0) tex_coords: vec2<f32>,
|
|
|
|
|
@location(1) world_normal: vec3<f32>,
|
|
|
|
|
@location(2) world_position: vec3<f32>,
|
|
|
|
|
};
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
@ -719,21 +720,21 @@ Now we need to reconstruct the normal matrix in the vertex shader.
|
|
|
|
|
|
|
|
|
|
```wgsl
|
|
|
|
|
struct InstanceInput {
|
|
|
|
|
@location(5) model_matrix_0: vec4<f32>;
|
|
|
|
|
@location(6) model_matrix_1: vec4<f32>;
|
|
|
|
|
@location(7) model_matrix_2: vec4<f32>;
|
|
|
|
|
@location(8) model_matrix_3: vec4<f32>;
|
|
|
|
|
@location(5) model_matrix_0: vec4<f32>,
|
|
|
|
|
@location(6) model_matrix_1: vec4<f32>,
|
|
|
|
|
@location(7) model_matrix_2: vec4<f32>,
|
|
|
|
|
@location(8) model_matrix_3: vec4<f32>,
|
|
|
|
|
// NEW!
|
|
|
|
|
@location(9) normal_matrix_0: vec3<f32>;
|
|
|
|
|
@location(10) normal_matrix_1: vec3<f32>;
|
|
|
|
|
@location(11) normal_matrix_2: vec3<f32>;
|
|
|
|
|
@location(9) normal_matrix_0: vec3<f32>,
|
|
|
|
|
@location(10) normal_matrix_1: vec3<f32>,
|
|
|
|
|
@location(11) normal_matrix_2: vec3<f32>,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct VertexOutput {
|
|
|
|
|
@builtin(position) clip_position: vec4<f32>;
|
|
|
|
|
@location(0) tex_coords: vec2<f32>;
|
|
|
|
|
@location(1) world_normal: vec3<f32>;
|
|
|
|
|
@location(2) world_position: vec3<f32>;
|
|
|
|
|
@builtin(position) clip_position: vec4<f32>,
|
|
|
|
|
@location(0) tex_coords: vec2<f32>,
|
|
|
|
|
@location(1) world_normal: vec3<f32>,
|
|
|
|
|
@location(2) world_position: vec3<f32>,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@vertex
|
|
|
|
|