[vulkan] Use simpler projection and z_up matrices

While both matrices had positive determinants in the first place, I find
the projection matrix easier to understand without all the negatives,
and having quake-x/vulkan-z positively parallel in the z-up matrix makes
that a lot easier to think about.
This commit is contained in:
Bill Currie 2022-02-18 13:40:24 +09:00
parent cd26073b6a
commit e67ec84db9
2 changed files with 8 additions and 6 deletions

View file

@ -77,8 +77,8 @@ QFV_PerspectiveTan (mat4f_t proj, float fov, float aspect)
fard = r_farclip->value;
proj[0] = (vec4f_t) { f / aspect, 0, 0, 0 };
proj[1] = (vec4f_t) { 0, -f, 0, 0 };
proj[2] = (vec4f_t) { 0, 0, fard / (neard - fard), -1 };
proj[1] = (vec4f_t) { 0, f, 0, 0 };
proj[2] = (vec4f_t) { 0, 0, fard / (fard - neard), 1 };
proj[3] = (vec4f_t) { 0, 0, (neard * fard) / (neard - fard), 0 };
}

View file

@ -64,11 +64,13 @@ static void
setup_view (vulkan_ctx_t *ctx)
{
mat4f_t view;
// Quake's world is z-up, x-forward, y-left, but Vulkan's world is
// z-forward, x-right, y-down.
static mat4f_t z_up = {
{ 0, 0, -1, 0},
{-1, 0, 0, 0},
{ 0, 1, 0, 0},
{ 0, 0, 0, 1},
{ 0, 0, 1, 0},
{-1, 0, 0, 0},
{ 0,-1, 0, 0},
{ 0, 0, 0, 1},
};
vec4f_t offset = { 0, 0, 0, 1 };