mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-25 05:08:21 -06:00
enable depth texture
This commit is contained in:
parent
66afd3057e
commit
641e3c921c
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
settings::GameSettings,
|
settings::GameSettings,
|
||||||
world::{ChunkMeshStorage, ChunkStorage},
|
world::{ChunkMeshStorage, ChunkStorage},
|
||||||
};
|
};
|
||||||
use super::{camera::{self, CameraUniformBuffer}, RenderCtx};
|
use super::{camera::{self, CameraUniformBuffer}, depth::DepthTexture, RenderCtx};
|
||||||
|
|
||||||
mod pipeline;
|
mod pipeline;
|
||||||
mod vertex;
|
mod vertex;
|
||||||
|
@ -29,12 +29,13 @@ pub fn init_world_render_state(storages: AllStoragesView) {
|
||||||
pub fn draw_world(
|
pub fn draw_world(
|
||||||
ctx: &mut RenderCtx,
|
ctx: &mut RenderCtx,
|
||||||
mut state: UniqueViewMut<WorldRenderState>,
|
mut state: UniqueViewMut<WorldRenderState>,
|
||||||
|
camera_ubo: UniqueView<CameraUniformBuffer>,
|
||||||
|
depth: UniqueView<DepthTexture>,
|
||||||
textures: UniqueView<TexturePrefabs>,
|
textures: UniqueView<TexturePrefabs>,
|
||||||
camera: View<Camera>,
|
camera: View<Camera>,
|
||||||
chunks: UniqueView<ChunkStorage>,
|
chunks: UniqueView<ChunkStorage>,
|
||||||
meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||||
camera_ubo: UniqueView<CameraUniformBuffer>,
|
//settings: UniqueView<GameSettings>,
|
||||||
settings: UniqueView<GameSettings>,
|
|
||||||
) {
|
) {
|
||||||
let camera = camera.iter().next().expect("No cameras in the scene");
|
let camera = camera.iter().next().expect("No cameras in the scene");
|
||||||
|
|
||||||
|
@ -48,6 +49,14 @@ pub fn draw_world(
|
||||||
store: wgpu::StoreOp::Store,
|
store: wgpu::StoreOp::Store,
|
||||||
},
|
},
|
||||||
})],
|
})],
|
||||||
|
depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment {
|
||||||
|
view: &depth.depth_view,
|
||||||
|
depth_ops: Some(wgpu::Operations {
|
||||||
|
load: wgpu::LoadOp::Clear(1.0),
|
||||||
|
store: wgpu::StoreOp::Store,
|
||||||
|
}),
|
||||||
|
stencil_ops: None,
|
||||||
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use shipyard::{Unique, UniqueView};
|
use shipyard::UniqueView;
|
||||||
use crate::{
|
use crate::{
|
||||||
prefabs::TexturePrefabs,
|
prefabs::TexturePrefabs,
|
||||||
rendering::{camera::CameraUniformBuffer, world::ChunkVertex, Renderer}
|
rendering::{camera::CameraUniformBuffer, depth::DepthTexture, world::ChunkVertex, Renderer}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init_world_pipeline(
|
pub fn init_world_pipeline(
|
||||||
ren: UniqueView<Renderer>,
|
ren: UniqueView<Renderer>,
|
||||||
|
depth: UniqueView<DepthTexture>,
|
||||||
textures: UniqueView<TexturePrefabs>,
|
textures: UniqueView<TexturePrefabs>,
|
||||||
camera_ubo: UniqueView<CameraUniformBuffer>,
|
camera_ubo: UniqueView<CameraUniformBuffer>,
|
||||||
) -> wgpu::RenderPipeline {
|
) -> wgpu::RenderPipeline {
|
||||||
|
@ -52,7 +53,13 @@ pub fn init_world_pipeline(
|
||||||
polygon_mode: wgpu::PolygonMode::Fill,
|
polygon_mode: wgpu::PolygonMode::Fill,
|
||||||
conservative: false,
|
conservative: false,
|
||||||
},
|
},
|
||||||
depth_stencil: None,
|
depth_stencil: Some(wgpu::DepthStencilState {
|
||||||
|
format: depth.depth_texture.format(),
|
||||||
|
depth_write_enabled: true,
|
||||||
|
depth_compare: wgpu::CompareFunction::Less,
|
||||||
|
stencil: wgpu::StencilState::default(),
|
||||||
|
bias: wgpu::DepthBiasState::default(),
|
||||||
|
}),
|
||||||
multisample: wgpu::MultisampleState::default(),
|
multisample: wgpu::MultisampleState::default(),
|
||||||
multiview: None,
|
multiview: None,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue