mirror of
https://github.com/izzy2lost/Ghostship.git
synced 2026-06-19 01:17:03 -07:00
Implemented skybox interpolation
This commit is contained in:
@@ -13,6 +13,8 @@ void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near,
|
||||
float far, float scale);
|
||||
void guOrtho(Mtx *m, float left, float right, float bottom, float top,
|
||||
float near, float far, float scale);
|
||||
void guOrthoInterp(Mtx *m, float left, float right, float bottom, float top,
|
||||
float near, float far, float scale);
|
||||
void guTranslate(Mtx *m, float x, float y, float z);
|
||||
void guRotate(Mtx *m, float a, float x, float y, float z);
|
||||
void guScale(Mtx *m, float x, float y, float z);
|
||||
|
||||
@@ -26,3 +26,13 @@ void guOrtho(Mtx *m, float left, float right, float bottom, float top, float nea
|
||||
guOrthoF(sp28, left, right, bottom, top, near, far, scale);
|
||||
guMtxF2L(sp28, m);
|
||||
}
|
||||
|
||||
|
||||
void guOrthoInterp(Mtx *m, float left, float right, float bottom, float top, float near, float far,
|
||||
float scale) {
|
||||
FrameInterpolation_RecordOrtho(m, left, right, bottom, top, near, far, scale);
|
||||
|
||||
float sp28[4][4];
|
||||
guOrthoF(sp28, left, right, bottom, top, near, far, scale);
|
||||
guMtxF2L(sp28, m);
|
||||
}
|
||||
@@ -232,7 +232,7 @@ static void geo_process_ortho_projection(struct GraphNodeOrthoProjection *node)
|
||||
f32 bottom = (gCurGraphNodeRoot->y + gCurGraphNodeRoot->height) / 2.0f * node->scale;
|
||||
|
||||
FrameInterpolation_RecordOpenChild("geo_process_ortho_projection", (uintptr_t)node);
|
||||
guOrtho(mtx, left, right, bottom, top, -2.0f, 2.0f, 1.0f);
|
||||
guOrthoInterp(mtx, left, right, bottom, top, -2.0f, 2.0f, 1.0f);
|
||||
gSPPerspNormalize(gDisplayListHead++, 0xFFFF);
|
||||
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx), G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
|
||||
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@
|
||||
#include "segment2.h"
|
||||
#include "sm64.h"
|
||||
#include "skybox_table.h"
|
||||
#include "port/interpolation/FrameInterpolation.h"
|
||||
|
||||
/**
|
||||
* @file skybox.c
|
||||
@@ -291,7 +292,7 @@ void *create_skybox_ortho_matrix(s8 player) {
|
||||
}
|
||||
|
||||
if (mtx != NULL) {
|
||||
guOrtho(mtx, left, right, bottom, top, 0.0f, 3.0f, 1.0f);
|
||||
guOrthoInterp(mtx, left, right, bottom, top, 0.0f, 3.0f, 1.0f);
|
||||
} else {
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
extern "C" {
|
||||
extern Mat4* gInterpolationMatrix;
|
||||
void guOrtho(Mtx* dest, float left, float right, float bottom, float top, float near, float far, float scale);
|
||||
}
|
||||
/*
|
||||
Frame interpolation.
|
||||
@@ -61,6 +62,7 @@ enum class Op {
|
||||
MatrixPut,
|
||||
MatrixMult,
|
||||
MatrixTranslate,
|
||||
Ortho,
|
||||
MatrixScale,
|
||||
MatrixRotate1Coord,
|
||||
MatrixRotateXYCoords,
|
||||
@@ -114,6 +116,17 @@ union Data {
|
||||
Vec3fInterp b;
|
||||
} matrix_translate;
|
||||
|
||||
struct {
|
||||
Mtx* m;
|
||||
float left;
|
||||
float right;
|
||||
float bottom;
|
||||
float top;
|
||||
float near;
|
||||
float far;
|
||||
float scale;
|
||||
} ortho;
|
||||
|
||||
struct {
|
||||
Mat4* matrix;
|
||||
f32 scale;
|
||||
@@ -444,6 +457,28 @@ struct InterpolateCtx {
|
||||
|
||||
translate_mtxf(*gInterpolationMatrix, temp);
|
||||
break;
|
||||
case Op::Ortho: {
|
||||
// Only interpolate if the difference is significant to avoid jitter
|
||||
constexpr float THRESHOLD = 2.0f;
|
||||
if (fabsf(old_op.ortho.left - new_op.ortho.left) < THRESHOLD &&
|
||||
fabsf(old_op.ortho.right - new_op.ortho.right) < THRESHOLD &&
|
||||
fabsf(old_op.ortho.bottom - new_op.ortho.bottom) < THRESHOLD &&
|
||||
fabsf(old_op.ortho.top - new_op.ortho.top) < THRESHOLD &&
|
||||
fabsf(old_op.ortho.near - new_op.ortho.near) < THRESHOLD &&
|
||||
fabsf(old_op.ortho.far - new_op.ortho.far) < THRESHOLD &&
|
||||
fabsf(old_op.ortho.scale - new_op.ortho.scale) < THRESHOLD) {
|
||||
break;
|
||||
}
|
||||
float left = lerp(old_op.ortho.left, new_op.ortho.left);
|
||||
float right = lerp(old_op.ortho.right, new_op.ortho.right);
|
||||
float bottom = lerp(old_op.ortho.bottom, new_op.ortho.bottom);
|
||||
float top = lerp(old_op.ortho.top, new_op.ortho.top);
|
||||
float near = lerp(old_op.ortho.near, new_op.ortho.near);
|
||||
float far = lerp(old_op.ortho.far, new_op.ortho.far);
|
||||
float scale = lerp(old_op.ortho.scale, new_op.ortho.scale);
|
||||
guOrtho(new_replacement(new_op.ortho.m), left, right, bottom, top, near, far, scale);
|
||||
break;
|
||||
}
|
||||
case Op::MatrixPosRotXYZ: {
|
||||
Vec3f tempF;
|
||||
Vec3s tempS;
|
||||
@@ -758,6 +793,14 @@ void FrameInterpolation_RecordMatrixTranslate(Mat4* matrix, Vec3f b) {
|
||||
append(Op::MatrixTranslate).matrix_translate = { matrix, *((Vec3fInterp*)b) };
|
||||
}
|
||||
|
||||
void FrameInterpolation_RecordOrtho(Mtx* m, f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far,
|
||||
f32 scale) {
|
||||
if (!check_if_recording()) {
|
||||
return;
|
||||
}
|
||||
append(Op::Ortho).ortho = { m, left, right, bottom, top, near, far, scale };
|
||||
}
|
||||
|
||||
void FrameInterpolation_RecordMatrixScale(Mat4* matrix, f32 scale) {
|
||||
if (!check_if_recording()) {
|
||||
return;
|
||||
|
||||
@@ -88,6 +88,8 @@ void FrameInterpolation_RecordCalculateOrientationMatrix(Mat3*, f32, f32, f32, s
|
||||
|
||||
void FrameInterpolation_RecordTranslateRotate(Mat4* dest, Vec3f pos, Vec3s rotation);
|
||||
|
||||
void FrameInterpolation_RecordOrtho(Mtx* m, f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far, f32 scale);
|
||||
|
||||
//void FrameInterpolation_func_80062B18(f32* arg0, f32* arg1, f32* arg2, arg3, arg4, arg5, arg6, arg7);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user