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