3d camera

This commit is contained in:
Werner
2021-11-03 19:05:49 -03:00
parent 4d734dc099
commit 19b9c8c148
3 changed files with 244 additions and 5 deletions

View File

@ -1,5 +1,13 @@
// Vertex shader
[[block]]
struct CameraUniform {
view_proj: mat4x4<f32>;
};
[[group(1), binding(0)]]
var<uniform> camera: CameraUniform;
struct VertexInput {
[[location(0)]] position: vec3<f32>;
[[location(1)]] tex_coords: vec2<f32>;
@ -16,7 +24,7 @@ fn main(
) -> VertexOutput {
var out: VertexOutput;
out.tex_coords = model.tex_coords;
out.clip_position = vec4<f32>(model.position, 1.0);
out.clip_position = camera.view_proj * vec4<f32>(model.position, 1.0); // 3.
return out;
}