Fix depth texture saving
This commit is contained in:
parent
010e4dedeb
commit
7830d735b8
6 changed files with 131 additions and 82 deletions
|
@ -143,30 +143,26 @@ pub trait DrawModel<'a> {
|
|||
&mut self,
|
||||
mesh: &'a Mesh,
|
||||
material: &'a Material,
|
||||
camera_bind_group: &'a wgpu::BindGroup,
|
||||
light_bind_group: &'a wgpu::BindGroup,
|
||||
bind_groups: Vec<&'a wgpu::BindGroup>,
|
||||
);
|
||||
fn draw_mesh_instanced(
|
||||
&mut self,
|
||||
mesh: &'a Mesh,
|
||||
material: &'a Material,
|
||||
instances: Range<u32>,
|
||||
camera_bind_group: &'a wgpu::BindGroup,
|
||||
light_bind_group: &'a wgpu::BindGroup,
|
||||
bind_groups: Vec<&'a wgpu::BindGroup>,
|
||||
);
|
||||
|
||||
fn draw_model(
|
||||
&mut self,
|
||||
model: &'a Model,
|
||||
camera_bind_group: &'a wgpu::BindGroup,
|
||||
light_bind_group: &'a wgpu::BindGroup,
|
||||
bind_groups: Vec<&'a wgpu::BindGroup>,
|
||||
);
|
||||
fn draw_model_instanced(
|
||||
&mut self,
|
||||
model: &'a Model,
|
||||
instances: Range<u32>,
|
||||
camera_bind_group: &'a wgpu::BindGroup,
|
||||
light_bind_group: &'a wgpu::BindGroup,
|
||||
bind_groups: Vec<&'a wgpu::BindGroup>,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -178,10 +174,9 @@ where
|
|||
&mut self,
|
||||
mesh: &'b Mesh,
|
||||
material: &'b Material,
|
||||
camera_bind_group: &'b wgpu::BindGroup,
|
||||
light_bind_group: &'b wgpu::BindGroup,
|
||||
bind_groups: Vec<&'a wgpu::BindGroup>,
|
||||
) {
|
||||
self.draw_mesh_instanced(mesh, material, 0..1, camera_bind_group, light_bind_group);
|
||||
self.draw_mesh_instanced(mesh, material, 0..1, bind_groups);
|
||||
}
|
||||
|
||||
fn draw_mesh_instanced(
|
||||
|
@ -189,32 +184,30 @@ where
|
|||
mesh: &'b Mesh,
|
||||
material: &'b Material,
|
||||
instances: Range<u32>,
|
||||
camera_bind_group: &'b wgpu::BindGroup,
|
||||
light_bind_group: &'b wgpu::BindGroup,
|
||||
bind_groups: Vec<&'a wgpu::BindGroup>,
|
||||
) {
|
||||
self.set_vertex_buffer(0, mesh.vertex_buffer.slice(..));
|
||||
self.set_index_buffer(mesh.index_buffer.slice(..), wgpu::IndexFormat::Uint32);
|
||||
self.set_bind_group(0, camera_bind_group, &[]);
|
||||
self.set_bind_group(1, light_bind_group, &[]);
|
||||
self.set_bind_group(2, &material.bind_group, &[]);
|
||||
for i in 0..bind_groups.len() {
|
||||
self.set_bind_group(i as u32, bind_groups[i], &[]);
|
||||
}
|
||||
self.set_bind_group(bind_groups.len() as u32, &material.bind_group, &[]);
|
||||
self.draw_indexed(0..mesh.num_elements, 0, instances);
|
||||
}
|
||||
|
||||
fn draw_model(
|
||||
&mut self,
|
||||
model: &'b Model,
|
||||
camera_bind_group: &'b wgpu::BindGroup,
|
||||
light_bind_group: &'b wgpu::BindGroup,
|
||||
bind_groups: Vec<&'a wgpu::BindGroup>,
|
||||
) {
|
||||
self.draw_model_instanced(model, 0..1, camera_bind_group, light_bind_group);
|
||||
self.draw_model_instanced(model, 0..1, bind_groups);
|
||||
}
|
||||
|
||||
fn draw_model_instanced(
|
||||
&mut self,
|
||||
model: &'b Model,
|
||||
instances: Range<u32>,
|
||||
camera_bind_group: &'b wgpu::BindGroup,
|
||||
light_bind_group: &'b wgpu::BindGroup,
|
||||
bind_groups: Vec<&'a wgpu::BindGroup>,
|
||||
) {
|
||||
for mesh in &model.meshes {
|
||||
let material = &model.materials[mesh.material];
|
||||
|
@ -222,8 +215,7 @@ where
|
|||
mesh,
|
||||
material,
|
||||
instances.clone(),
|
||||
camera_bind_group,
|
||||
light_bind_group,
|
||||
bind_groups.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue