From dd386acea10e9b2a9d1b27ded25c358c47e8d822 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Mon, 6 May 2024 15:48:36 +0200 Subject: [PATCH] owo --- kubi/shaders/world.wgsl | 7 ++++--- kubi/src/prefabs.rs | 6 +++++- kubi/src/rendering/world.rs | 15 +++++++++------ kubi/src/rendering/world/pipeline.rs | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/kubi/shaders/world.wgsl b/kubi/shaders/world.wgsl index cfe54ae..7cf22b5 100644 --- a/kubi/shaders/world.wgsl +++ b/kubi/shaders/world.wgsl @@ -9,15 +9,14 @@ struct VertexInput { @location(0) position: vec3, @location(1) normal: vec3, @location(2) uv: vec2, - @location(3) @interpolate(flat) tex_index: u32, + @location(3) tex_index: u32, } struct VertexOutput { @builtin(position) clip_position: vec4, @location(0) uv: vec2, @location(1) normal: vec3, - @location(2) color: vec4, - @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(in.position, 1.0); return out; } diff --git a/kubi/src/prefabs.rs b/kubi/src/prefabs.rs index d4060e4..08bd3e9 100644 --- a/kubi/src/prefabs.rs +++ b/kubi/src/prefabs.rs @@ -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, diff --git a/kubi/src/rendering/world.rs b/kubi/src/rendering/world.rs index b2a78d7..829705c 100644 --- a/kubi/src/rendering/world.rs +++ b/kubi/src/rendering/world.rs @@ -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, textures: UniqueView, + camera: View, chunks: UniqueView, meshes: NonSendSync>, camera_ubo: UniqueView, settings: UniqueView, ) { + 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 { diff --git a/kubi/src/rendering/world/pipeline.rs b/kubi/src/rendering/world/pipeline.rs index f6b1a80..80fe6b1 100644 --- a/kubi/src/rendering/world/pipeline.rs +++ b/kubi/src/rendering/world/pipeline.rs @@ -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,