render: use depth buffer
This commit is contained in:
parent
fa6511bff1
commit
418765d595
|
@ -15,9 +15,7 @@ use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
render::{
|
render::{
|
||||||
graph::{Node, NodeDesc, NodeType, SlotAttribute},
|
graph::{Node, NodeDesc, NodeType, SlotAttribute}, resource::{FragmentState, RenderPipeline, RenderPipelineDescriptor, VertexState}, texture::RenderTexture, vertex::Vertex2D
|
||||||
resource::{FragmentState, RenderPipeline, RenderPipelineDescriptor, VertexState},
|
|
||||||
vertex::Vertex2D,
|
|
||||||
},
|
},
|
||||||
sprite::{AtlasSprite, Sprite},
|
sprite::{AtlasSprite, Sprite},
|
||||||
};
|
};
|
||||||
|
@ -294,7 +292,13 @@ impl Node for SpritePass {
|
||||||
write_mask: wgpu::ColorWrites::ALL,
|
write_mask: wgpu::ColorWrites::ALL,
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
depth_stencil: None,
|
depth_stencil: Some(wgpu::DepthStencilState {
|
||||||
|
format: RenderTexture::DEPTH_FORMAT,
|
||||||
|
depth_write_enabled: true,
|
||||||
|
depth_compare: wgpu::CompareFunction::Less,
|
||||||
|
stencil: wgpu::StencilState::default(), // TODO: stencil buffer
|
||||||
|
bias: wgpu::DepthBiasState::default(),
|
||||||
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
cull_mode: Some(wgpu::Face::Back),
|
cull_mode: Some(wgpu::Face::Back),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -421,6 +425,12 @@ impl Node for SpritePass {
|
||||||
let vt = graph.view_target();
|
let vt = graph.view_target();
|
||||||
let view = vt.render_view();
|
let view = vt.render_view();
|
||||||
|
|
||||||
|
let depth_view = graph
|
||||||
|
.slot_value(BasePassSlots::DepthTextureView)
|
||||||
|
.unwrap()
|
||||||
|
.as_texture_view()
|
||||||
|
.expect("BasePassSlots::DepthTextureView was not a TextureView slot");
|
||||||
|
|
||||||
let camera_bg = graph.bind_group(BasePassSlots::Camera);
|
let camera_bg = graph.bind_group(BasePassSlots::Camera);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -440,7 +450,14 @@ impl Node for SpritePass {
|
||||||
store: wgpu::StoreOp::Store,
|
store: wgpu::StoreOp::Store,
|
||||||
},
|
},
|
||||||
})],
|
})],
|
||||||
depth_stencil_attachment: None,
|
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||||
|
view: depth_view,
|
||||||
|
depth_ops: Some(wgpu::Operations {
|
||||||
|
load: wgpu::LoadOp::Clear(1.0),
|
||||||
|
store: wgpu::StoreOp::Store,
|
||||||
|
}),
|
||||||
|
stencil_ops: None,
|
||||||
|
}),
|
||||||
timestamp_writes: None,
|
timestamp_writes: None,
|
||||||
occlusion_query_set: None,
|
occlusion_query_set: None,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue