mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 03:48:21 -06:00
owo
This commit is contained in:
parent
d14b5e1b40
commit
dd386acea1
|
@ -9,15 +9,14 @@ struct VertexInput {
|
|||
@location(0) position: vec3<f32>,
|
||||
@location(1) normal: vec3<f32>,
|
||||
@location(2) uv: vec2<f32>,
|
||||
@location(3) @interpolate(flat) tex_index: u32,
|
||||
@location(3) tex_index: u32,
|
||||
}
|
||||
|
||||
struct VertexOutput {
|
||||
@builtin(position) clip_position: vec4<f32>,
|
||||
@location(0) uv: vec2<f32>,
|
||||
@location(1) normal: vec3<f32>,
|
||||
@location(2) color: vec4<f32>,
|
||||
@location(3) @interpolate(flat) tex_index: u32,
|
||||
@location(2) @interpolate(flat) tex_index: u32,
|
||||
};
|
||||
|
||||
@vertex
|
||||
|
@ -26,6 +25,8 @@ fn vs_main(
|
|||
) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
out.uv = in.uv;
|
||||
out.normal = in.normal;
|
||||
out.tex_index = in.tex_index;
|
||||
out.clip_position = camera.view_proj * vec4<f32>(in.position, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -60,8 +60,12 @@ pub fn load_prefabs(
|
|||
);
|
||||
|
||||
log::info!("Creating bing groups");
|
||||
let block_diffuse_view = block_diffuse_texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
let block_diffuse_view = block_diffuse_texture.create_view(&wgpu::TextureViewDescriptor {
|
||||
label: Some("block_texture_view"),
|
||||
..Default::default()
|
||||
});
|
||||
let block_diffuse_sampler = renderer.device().create_sampler(&wgpu::SamplerDescriptor {
|
||||
label: Some("block_diffuse_sampler"),
|
||||
address_mode_u: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_v: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
settings::GameSettings,
|
||||
world::{ChunkMeshStorage, ChunkStorage},
|
||||
};
|
||||
use super::{camera::CameraUniformBuffer, RenderCtx};
|
||||
use super::{camera::{self, CameraUniformBuffer}, RenderCtx};
|
||||
|
||||
mod pipeline;
|
||||
mod vertex;
|
||||
|
@ -30,11 +30,14 @@ pub fn draw_world(
|
|||
ctx: &mut RenderCtx,
|
||||
mut state: UniqueViewMut<WorldRenderState>,
|
||||
textures: UniqueView<TexturePrefabs>,
|
||||
camera: View<Camera>,
|
||||
chunks: UniqueView<ChunkStorage>,
|
||||
meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
|
||||
camera_ubo: UniqueView<CameraUniformBuffer>,
|
||||
settings: UniqueView<GameSettings>,
|
||||
) {
|
||||
let camera = camera.iter().next().expect("No cameras in the scene");
|
||||
|
||||
let mut render_pass = ctx.encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("draw_world"),
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
|
@ -63,11 +66,11 @@ pub fn draw_world(
|
|||
}
|
||||
|
||||
//Frustum culling
|
||||
// let minp = world_position;
|
||||
// let maxp = world_position + Vec3::splat(CHUNK_SIZE as f32);
|
||||
// if !camera.frustum.is_box_visible(minp, maxp) {
|
||||
// continue
|
||||
// }
|
||||
let minp = world_position;
|
||||
let maxp = world_position + Vec3::splat(CHUNK_SIZE as f32);
|
||||
if !camera.frustum.is_box_visible(minp, maxp) {
|
||||
continue
|
||||
}
|
||||
|
||||
//Draw chunk mesh
|
||||
if mesh.main.index.size() > 0 {
|
||||
|
|
|
@ -47,7 +47,7 @@ pub fn init_world_pipeline(
|
|||
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
strip_index_format: None,
|
||||
cull_mode: Some(wgpu::Face::Back),
|
||||
front_face: wgpu::FrontFace::Cw,
|
||||
front_face: wgpu::FrontFace::Ccw,
|
||||
unclipped_depth: false,
|
||||
polygon_mode: wgpu::PolygonMode::Fill,
|
||||
conservative: false,
|
||||
|
|
Loading…
Reference in a new issue