Compare commits

..

2 commits

Author SHA1 Message Date
griffi-gh 1ac6861610 minor changes, wip shader 2023-07-17 12:58:17 +02:00
griffi-gh 6064fe0b76 make naga shut up 2023-07-17 12:44:00 +02:00
4 changed files with 32 additions and 10 deletions

View file

@ -9,7 +9,7 @@ pub fn init() {
use env_logger::{fmt::Color, Builder, Env};
let env = Env::default()
.filter_or("RUST_LOG", "trace,gilrs=warn,rusty_xinput=warn,wgpu=warn,wgpu_core=warn,wgpu_hal=error");
.filter_or("RUST_LOG", "trace,gilrs=warn,rusty_xinput=warn,wgpu=warn,wgpu_core=warn,wgpu_hal=warn,naga=warn");
Builder::from_env(env)
.format(|buf, record| {
let mut level_style = buf.style();

View file

@ -1,19 +1,34 @@
//TODO migrate, this is just some filler code to make the game compile
struct Uniform {
position_offset: vec3<f32>,
view_proj: mat4x4<f32>,
};
@group(1) @binding(0)
var<uniform> world: Uniform;
struct VertexInput {
@location(0) position: vec3<f32>,
@location(1) normal: vec3<f32>,
@location(2) uv: vec2<f32>,
@location(3) tex_index: vec2<u8>,
}
struct VertexOutput {
@builtin(position) position: vec4<f32>,
};
@builtin(position) clip_position: vec4<f32>,
@location(0) tex_coords: vec2<f32>,
}
@vertex
fn vs_main(
@builtin(vertex_index) in_vertex_index: u32,
model: VertexInput,
) -> VertexOutput {
var out: VertexOutput;
out.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
out.tex_coords = model.tex_coords;
out.clip_position = camera.view_proj * vec4<f32>(model.position, 1.0); // 2.
return out;
}
@fragment
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
return vec4<f32>(0.3, 0.2, 0.1, 1.0);
return vec4(1.0, 0.0, 0.0, 0.0);
}

View file

@ -4,7 +4,7 @@ use winit::{
window::{Window, WindowBuilder, Fullscreen},
dpi::PhysicalSize,
};
use glam::Vec3;
use glam::{Vec3, Mat4};
use pollster::FutureExt as _;
use crate::{events::WindowResizedEvent, settings::{GameSettings, FullscreenMode}};
@ -17,6 +17,14 @@ pub mod world;
pub mod selection_box;
pub mod entities;
pub const OPENGL_TO_WGPU_MATRIX: Mat4 = Mat4::from_cols_array(&[
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.5, 0.0,
0.0, 0.0, 0.5, 1.0,
]);
#[derive(Unique)]
pub struct RenderTarget {
pub output: wgpu::SurfaceTexture,

View file

@ -27,8 +27,7 @@ pub struct ChunkVertex {
#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
struct WorldUniform {
position_offset: [f32; 3],
view: [[f32; 4]; 4],
perspective: [[f32; 4]; 4],
view_proj: [[f32; 4]; 4],
}
pub fn draw_world(