mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Avoid depth z-fighting
This commit is contained in:
parent
9bbf3deee7
commit
319694cf27
@ -64,7 +64,7 @@ pub fn create_map_render_pipeline_description<'a>(
|
||||
depth_stencil: Some(wgpu::DepthStencilState {
|
||||
format: DEPTH_TEXTURE_FORMAT,
|
||||
depth_write_enabled: !update_stencil,
|
||||
depth_compare: wgpu::CompareFunction::Less, // FIXME
|
||||
depth_compare: wgpu::CompareFunction::Greater, // FIXME
|
||||
stencil: wgpu::StencilState {
|
||||
front: stencil_state,
|
||||
back: stencil_state,
|
||||
|
||||
@ -452,7 +452,7 @@ impl RenderState {
|
||||
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||
view: &self.depth_texture.view,
|
||||
depth_ops: Some(wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear(1.0),
|
||||
load: wgpu::LoadOp::Clear(0.0),
|
||||
store: true,
|
||||
}),
|
||||
stencil_ops: Some(wgpu::Operations {
|
||||
|
||||
@ -25,9 +25,16 @@ fn main(
|
||||
let z = 0.0;
|
||||
let width = 3.0;
|
||||
|
||||
// The following code moves all "invisible" vertices to (0, 0, 0)
|
||||
//if (color.w == 0.0) {
|
||||
// return VertexOutput(color, vec4<f32>(0.0, 0.0, 0.0, 1.0));
|
||||
//}
|
||||
|
||||
let world_pos = vec3<f32>(position + normal * width, z) + translate;
|
||||
|
||||
let position = globals.camera.view_proj * vec4<f32>(world_pos, 1.0);
|
||||
var position = globals.camera.view_proj * vec4<f32>(world_pos, 1.0);
|
||||
|
||||
position.z = 1.0;
|
||||
|
||||
return VertexOutput(color, position);
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ fn main(
|
||||
|
||||
let world_pos = scaling * a_position + vec3<f32>(mask_offset, z);
|
||||
|
||||
let position = globals.camera.view_proj * vec4<f32>(world_pos, 1.0);
|
||||
|
||||
var position = globals.camera.view_proj * vec4<f32>(world_pos, 1.0);
|
||||
position.z = 1.0;
|
||||
return VertexOutput(debug_color, position);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user