Split view matrix from viewport size

This commit is contained in:
numzero 2024-12-30 16:51:29 +03:00
parent b26800c070
commit 44ce47612a
2 changed files with 10 additions and 8 deletions

View File

@ -35,9 +35,9 @@ struct ParamsData {
#[repr(C)]
struct CameraData {
u: Vec3,
pad1: f32,
width: f32,
v: Vec3,
pad2: f32,
height: f32,
w: Vec3,
pad3: f32,
eye: Vec3,
@ -47,12 +47,12 @@ struct CameraData {
impl From<(Viewport, CameraLocation)> for CameraData {
fn from(value: (Viewport, CameraLocation)) -> Self {
CameraData {
u: value.0.corner.x * value.1.view.x_axis,
v: value.0.corner.y * value.1.view.y_axis,
w: value.0.corner.z * value.1.view.z_axis,
u: value.1.view.x_axis,
v: value.1.view.y_axis,
w: value.1.view.z_axis,
eye: value.1.eye,
pad1: 0.,
pad2: 0.,
width: value.0.corner.x / value.0.corner.z,
height: value.0.corner.y / value.0.corner.z,
pad3: 0.,
pad4: 0.,
}

View File

@ -5,7 +5,9 @@ struct Params {
seed: u32,
right: vec3f,
width: f32,
up: vec3f,
height: f32,
forward: vec3f,
eye: vec3f,
}
@ -34,7 +36,7 @@ var<push_constant> params: Params;
@vertex
fn on_vertex(in: Vertex) -> Varying {
let m = mat3x3(params.right, params.up, params.forward);
let m = mat3x3(params.width * params.right, params.height * params.up, params.forward);
return Varying(m * vec3(in.screen, 1.0), vec4(in.screen, 0.0, 1.0));
}