Depth + basic sample-to-coverage
This commit is contained in:
parent
03e91fac28
commit
f00f5f2f77
|
|
@ -215,22 +215,41 @@ impl<'a> State<'a> {
|
|||
let cam_loc = camctl::CameraLocation::new();
|
||||
let t1 = Instant::now();
|
||||
|
||||
let depth = None;
|
||||
let msaa = wgpu::MultisampleState {
|
||||
count: viewport.sample_count(),
|
||||
mask: !0,
|
||||
alpha_to_coverage_enabled: false,
|
||||
};
|
||||
|
||||
let cam_obj = camera::Camera::new(&device);
|
||||
let line_rend = lines::LineRenderer::new(
|
||||
&device,
|
||||
cam_obj.bind_group_layout(),
|
||||
viewport.format(),
|
||||
depth.clone(),
|
||||
msaa,
|
||||
Some(wgpu::DepthStencilState {
|
||||
format: wgpu::TextureFormat::Depth24Plus,
|
||||
depth_write_enabled: false,
|
||||
depth_compare: wgpu::CompareFunction::LessEqual,
|
||||
stencil: wgpu::StencilState::default(),
|
||||
bias: wgpu::DepthBiasState::default(),
|
||||
}),
|
||||
wgpu::MultisampleState {
|
||||
count: viewport.sample_count(),
|
||||
mask: !0,
|
||||
alpha_to_coverage_enabled: false,
|
||||
},
|
||||
);
|
||||
let mesh_rend = meshes::Renderer::new(
|
||||
&device,
|
||||
cam_obj.bind_group_layout(),
|
||||
viewport.format(),
|
||||
Some(wgpu::DepthStencilState {
|
||||
format: wgpu::TextureFormat::Depth24Plus,
|
||||
depth_write_enabled: true,
|
||||
depth_compare: wgpu::CompareFunction::LessEqual,
|
||||
stencil: wgpu::StencilState::default(),
|
||||
bias: wgpu::DepthBiasState::default(),
|
||||
}),
|
||||
wgpu::MultisampleState {
|
||||
count: viewport.sample_count(),
|
||||
mask: !0,
|
||||
alpha_to_coverage_enabled: true,
|
||||
},
|
||||
);
|
||||
let mesh_rend = meshes::Renderer::new(&device, cam_obj.bind_group_layout(), viewport.format(), depth, msaa);
|
||||
|
||||
let (meshes, lines) = prepare_scene(&device);
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ pub fn build() -> (Vec<FancyMesh>, Vec<FancyLine>) {
|
|||
|
||||
let mut gc = vec![];
|
||||
gc.push(FancyMesh {
|
||||
color: vec4(0.3, 0.5, 1.0, 1.0) * 0.2,
|
||||
color: vec4(0.10, 0.12, 0.15, 0.8),
|
||||
tris: tube.render(),
|
||||
});
|
||||
let meshes = gc;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ impl<'a> Viewport<'a> {
|
|||
let render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("RenderPass"),
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view: &self.multisample.view,
|
||||
view: &self.multisample.color,
|
||||
resolve_target: Some(&view),
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear(wgpu::Color {
|
||||
|
|
@ -87,7 +87,14 @@ impl<'a> Viewport<'a> {
|
|||
store: wgpu::StoreOp::Store,
|
||||
},
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||
view: &self.multisample.depth,
|
||||
depth_ops: Some(wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear(1.),
|
||||
store: wgpu::StoreOp::Discard,
|
||||
}),
|
||||
stencil_ops: None,
|
||||
}),
|
||||
occlusion_query_set: None,
|
||||
timestamp_writes: None,
|
||||
});
|
||||
|
|
@ -99,13 +106,14 @@ impl<'a> Viewport<'a> {
|
|||
}
|
||||
|
||||
struct Multisample {
|
||||
view: wgpu::TextureView,
|
||||
color: wgpu::TextureView,
|
||||
depth: wgpu::TextureView,
|
||||
}
|
||||
|
||||
impl Multisample {
|
||||
fn new(device: &wgpu::Device, format: wgpu::TextureFormat, size: UVec2, sample_count: u32) -> Multisample {
|
||||
let tex = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("Multisample texture"),
|
||||
let color = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("Multisample color texture"),
|
||||
size: wgpu::Extent3d {
|
||||
width: size.x,
|
||||
height: size.y,
|
||||
|
|
@ -118,7 +126,22 @@ impl Multisample {
|
|||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||
view_formats: &[],
|
||||
});
|
||||
let view = tex.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
Multisample { view }
|
||||
let color = color.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
let depth = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("Multisample depth texture"),
|
||||
size: wgpu::Extent3d {
|
||||
width: size.x,
|
||||
height: size.y,
|
||||
depth_or_array_layers: 1,
|
||||
},
|
||||
mip_level_count: 1,
|
||||
sample_count,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: wgpu::TextureFormat::Depth24Plus,
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
||||
view_formats: &[],
|
||||
});
|
||||
let depth = depth.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
Multisample { color, depth }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user