[enhancement] Disable Culling (#58)

* less intrusif possible way to disable culling

* forget cloud and star

* some change and add gFarFrustrum

* reduce range of gFarFrustrum

* minor rename of a CVar

---------

Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
This commit is contained in:
coco875
2024-09-11 00:20:55 +02:00
committed by GitHub
parent 47e95c0e18
commit b36b9e3180
29 changed files with 174 additions and 6 deletions
+12
View File
@@ -114,4 +114,16 @@
**/
#define GET_PACKED_END(dl) (((u8*) dl) + sizeof(dl) - sizeof(dl[0]) - 0x07000000)
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef CLAMP
#define CLAMP(var, min, max) ((var) < (min) ? min : (var) > (max) ? max : var)
#endif
#endif
+3
View File
@@ -17,6 +17,9 @@ void render_actor_banana(Camera* camera, UNUSED Mat4 arg1, struct BananaActor* b
f32 temp = is_within_render_distance(camera->pos, banana->pos, camera->rot[1], 0, gCameraZoom[camera - camera1],
490000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp = MAX(temp, 0.0f);
}
if (temp < 0.0f) {
actor_not_rendered(camera, (struct Actor*) banana);
return;
+3
View File
@@ -18,6 +18,9 @@ void render_actor_box_truck(Camera* arg0, struct Actor* arg1) {
UNUSED s32 pad2[32];
f32 temp_f0 =
is_within_render_distance(arg0->pos, arg1->pos, arg0->rot[1], 2500.0f, gCameraZoom[arg0 - camera1], 9000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
+3
View File
@@ -17,6 +17,9 @@ void render_actor_car(Camera* arg0, struct Actor* arg1) {
UNUSED s32 pad2[32];
f32 temp_f0 =
is_within_render_distance(arg0->pos, arg1->pos, arg0->rot[1], 2500.0f, gCameraZoom[arg0 - camera1], 9000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (!(temp_f0 < 0.0f)) {
if (CVarGetInteger("gDisableLod", 0) == 1) {
+2 -1
View File
@@ -14,7 +14,8 @@
*/
void render_actor_cow(Camera* camera, Mat4 arg1, struct Actor* arg2) {
if (is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1],
4000000.0f) < 0) {
4000000.0f) < 0 &&
CVarGetInteger("gNoCulling", 0) == 0) {
return;
}
+2 -1
View File
@@ -25,7 +25,8 @@ void render_actor_fake_item_box(Camera* camera, struct FakeItemBox* fakeItemBox)
f32 someMultiplier;
if (is_within_render_distance(camera->pos, fakeItemBox->pos, camera->rot[1], 2500.0f, gCameraZoom[camera - camera1],
1000000.0f) < 0) {
1000000.0f) < 0 &&
CVarGetInteger("gNoCulling", 0) == 0) {
actor_not_rendered(camera, (struct Actor*) fakeItemBox);
return;
}
+4
View File
@@ -23,6 +23,10 @@ void render_actor_falling_rock(Camera* camera, struct FallingRock* rock) {
height = is_within_render_distance(camera->pos, rock->pos, camera->rot[1], 400.0f, gCameraZoom[camera - camera1],
4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
height = CLAMP(height, 0.0f, 250000.0f);
}
if (height < 0.0f) {
return;
}
+3
View File
@@ -28,6 +28,9 @@ void render_actor_item_box(Camera* camera, struct ItemBox* item_box) {
temp_f0 = is_within_render_distance(camera->pos, item_box->pos, camera->rot[1], 0.0f, gCameraZoom[camera - camera1],
4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = CLAMP(temp_f0, 0.0f, 600000.0f);
}
if (!(temp_f0 < 0.0f) && !(600000.0f < temp_f0)) {
if ((item_box->state == 2) && (temp_f0 < 100000.0f)) {
someRot[0] = 0;
+3
View File
@@ -20,6 +20,9 @@ void render_actor_mario_sign(Camera* arg0, UNUSED Mat4 arg1, struct Actor* arg2)
}
unk = is_within_render_distance(arg0->pos, arg2->pos, arg0->rot[1], 0, gCameraZoom[arg0 - camera1], 16000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
unk = MAX(unk, 0.0f);
}
if (!(unk < 0.0f)) {
gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
+4
View File
@@ -32,6 +32,10 @@ void render_actor_paddle_boat(Camera* arg0, struct PaddleWheelBoat* boat, UNUSED
temp = is_within_render_distance(arg0->pos, boat->pos, arg0->rot[1], 90000.0f, gCameraZoom[arg0 - camera1],
9000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp = MAX(temp, 0.0f);
}
if (temp < 0.0f) {
return;
}
+4
View File
@@ -23,6 +23,10 @@ void render_actor_palm_tree(Camera* arg0, UNUSED Mat4 arg1, struct PalmTree* arg
temp_f0 =
is_within_render_distance(arg0->pos, arg2->pos, arg0->rot[1], 0.0f, gCameraZoom[arg0 - camera1], 4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (!(temp_f0 < 0.0f)) {
if (((temp_v0 & 0x400) == 0) && (temp_f0 < 250000.0f)) {
func_8029794C(arg2->pos, arg2->rot, 2.0f);
+4
View File
@@ -27,6 +27,10 @@ void render_actor_piranha_plant(Camera* arg0, Mat4 arg1, struct PiranhaPlant* ar
temp_f0 = is_within_render_distance(arg0->pos, arg2->pos, arg0->rot[1], 0, gCameraZoom[arg0 - camera1], 1000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
switch (temp_lo) {
@@ -16,6 +16,10 @@ void render_actor_railroad_crossing(Camera* arg0, struct RailroadCrossing* rr_cr
f32 unk = is_within_render_distance(arg0->pos, rr_crossing->pos, arg0->rot[1], 0.0f, gCameraZoom[arg0 - camera1],
4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
unk = MAX(unk, 0.0f);
}
if (!(unk < 0.0f)) {
mtxf_pos_rotation_xyz(sp40, rr_crossing->pos, rr_crossing->rot);
+5
View File
@@ -19,6 +19,11 @@ void render_actor_school_bus(Camera* arg0, struct Actor* arg1) {
temp_f0 =
is_within_render_distance(arg0->pos, arg1->pos, arg0->rot[1], 2500.0f, gCameraZoom[arg0 - camera1], 9000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
+4
View File
@@ -17,6 +17,10 @@ void render_actor_tanker_truck(Camera* camera, struct Actor* arg1) {
f32 temp_f0 = is_within_render_distance(camera->pos, arg1->pos, camera->rot[1], 2500.0f,
gCameraZoom[camera - camera1], 9000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (!(temp_f0 < 0.0f)) {
if (CVarGetInteger("gDisableLod", 0) == 1) {
+12
View File
@@ -22,6 +22,10 @@ void render_actor_train_engine(Camera* camera, struct TrainCar* actor) {
f32 distance = is_within_render_distance(camera->pos, actor->pos, camera->rot[1], 2500.0f,
gCameraZoom[camera - camera1], 9000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
distance = MAX(distance, 0.0f);
}
if (distance < 0.0f) {
return;
}
@@ -173,6 +177,10 @@ void render_actor_train_tender(Camera* camera, struct TrainCar* actor) {
f32 temp_f0 = is_within_render_distance(camera->pos, actor->pos, camera->rot[1], 625.0f,
gCameraZoom[camera - camera1], 9000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -262,6 +270,10 @@ void render_actor_train_passenger_car(Camera* camera, struct TrainCar* actor) {
f32 temp_f0 = is_within_render_distance(camera->pos, actor->pos, camera->rot[1], 2025.0f,
gCameraZoom[camera - camera1], 9000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
+44
View File
@@ -24,6 +24,10 @@ void render_actor_tree_mario_raceway(Camera* camera, Mat4 arg1, struct Actor* ar
temp_f0 = is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1],
16000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -59,6 +63,10 @@ void render_actor_tree_yoshi_valley(Camera* camera, Mat4 arg1, struct Actor* arg
temp_f0 =
is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -94,6 +102,10 @@ void render_actor_tree_royal_raceway(Camera* camera, Mat4 arg1, struct Actor* ar
temp_f0 =
is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -129,6 +141,10 @@ void render_actor_tree_moo_moo_farm(Camera* camera, Mat4 arg1, struct Actor* arg
temp_f0 =
is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 6250000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -158,6 +174,10 @@ void func_80299864(Camera* camera, Mat4 arg1, struct Actor* arg2) {
temp_f0 =
is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -212,6 +232,10 @@ void render_actor_tree_bowser_castle(Camera* camera, Mat4 arg1, struct Actor* ar
temp_f0 =
is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -247,6 +271,10 @@ void render_actor_bush_bowser_castle(Camera* camera, Mat4 arg1, struct Actor* ar
temp_f0 =
is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 640000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -282,6 +310,10 @@ void render_actor_tree_frappe_snowland(Camera* camera, Mat4 arg1, struct Actor*
temp_f0 =
is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -316,6 +348,10 @@ void render_actor_tree_cactus1_kalimari_desert(Camera* camera, Mat4 arg1, struct
temp_f0 =
is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -350,6 +386,10 @@ void render_actor_tree_cactus2_kalimari_desert(Camera* camera, Mat4 arg1, struct
temp_f0 =
is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
@@ -384,6 +424,10 @@ void render_actor_tree_cactus3_kalimari_desert(Camera* camera, Mat4 arg1, struct
temp_f0 =
is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
+4
View File
@@ -15,6 +15,10 @@ void render_actor_wario_sign(Camera* arg0, struct Actor* arg1) {
f32 unk =
is_within_render_distance(arg0->pos, arg1->pos, arg0->rot[1], 0, gCameraZoom[arg0 - camera1], 16000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
unk = MAX(unk, 0.0f);
}
if (!(unk < 0.0f)) {
gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
+5
View File
@@ -21,6 +21,11 @@ void render_actor_yoshi_egg(Camera* arg0, Mat4 arg1, struct YoshiValleyEgg* egg,
if (gGamestate != CREDITS_SEQUENCE) {
temp_f0 = is_within_render_distance(arg0->pos, egg->pos, arg0->rot[1], 200.0f, gCameraZoom[arg0 - camera1],
16000000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = MAX(temp_f0, 0.0f);
}
if (temp_f0 < 0.0f) {
return;
}
+4
View File
@@ -667,6 +667,10 @@ s32 set_vehicle_render_distance_flags(Vec3f vehiclePos, f32 renderDistance, s32
}
}
}
if (CVarGetInteger("gNoCulling", 0) == 1) {
flag |= (RENDER_VEHICLE << PLAYER_ONE) | (RENDER_VEHICLE << PLAYER_TWO) | (RENDER_VEHICLE << PLAYER_THREE) |
(RENDER_VEHICLE << PLAYER_FOUR);
}
return flag;
}
+10
View File
@@ -1306,6 +1306,10 @@ bool is_object_visible_on_camera(s32 objectIndex, Camera* camera, u16 angle) {
u16 temp_t2;
s32 var_t0;
if (CVarGetInteger("gNoCulling", 0) == 1) {
return true;
}
var_t0 = false;
temp_t2 = (get_angle_between_xy(camera->pos[0], gObjectList[objectIndex].pos[0], camera->pos[2],
gObjectList[objectIndex].pos[2]) +
@@ -1325,6 +1329,9 @@ void func_8008A1D0(s32 objectIndex, s32 cameraId, s32 arg2, s32 arg3) {
camera = &camera1[cameraId];
set_object_flag_status_false(objectIndex, 0x00100000 | VISIBLE);
temp_v0 = get_horizontal_distance_to_camera(objectIndex, camera);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_v0 = MIN(temp_v0, arg3 * arg3);
}
if (temp_v0 < 0x2711U) {
var_a2 = 0x5555;
} else if (temp_v0 < 0x9C41U) {
@@ -1368,6 +1375,9 @@ s32 func_8008A364(s32 objectIndex, s32 cameraId, u16 arg2, s32 arg3) {
camera = &camera1[cameraId];
set_object_flag_status_false(objectIndex, 0x00020000 | VISIBLE);
dist = get_horizontal_distance_to_camera(objectIndex, camera);
if (CVarGetInteger("gNoCulling", 0) == 1) {
dist = MIN(dist, (arg3 * arg3) - 1);
}
if (dist < (arg3 * arg3)) {
set_object_flag_status_true(objectIndex, 0x00020000);
if (dist < 0x2711U) {
+1 -1
View File
@@ -11,7 +11,7 @@
#define MESG_START_GFX_SPTASK 103
#define MESG_NMI_REQUEST 104
#define MTX_HUD_POOL_SIZE 800
#define MTX_HUD_POOL_SIZE 1600
#ifdef AVOID_UB
#define MTX_HUD_POOL_SIZE_MAX MTX_HUD_POOL_SIZE
+4
View File
@@ -456,6 +456,10 @@ bool is_particle_on_screen(Vec3f arg0, Camera* arg1, u16 arg2) {
u16 temp_t9;
s32 ret;
if (CVarGetInteger("gNoCulling", 0) == 1) {
return true;
}
ret = false;
temp_t9 = (get_angle_between_xy(arg1->pos[0], arg0[0], arg1->pos[2], arg0[2]) + (arg2 / 2)) - arg1->rot[1];
if ((temp_t9 >= 0) && (arg2 >= temp_t9)) {
+3
View File
@@ -4,6 +4,9 @@ void guPerspectiveF(float mf[4][4], u16* perspNorm, float fovy, float aspect, fl
float yscale;
int row;
int col;
if (CVarGetInteger("gNoCulling", 0)) {
far = CVarGetFloat("gFarFrustrum", 10000.0f);
}
guMtxIdentF(mf);
fovy *= GU_PI / 180.0;
yscale = cosf(fovy / 2) / sinf(fovy / 2);
+4
View File
@@ -463,6 +463,10 @@ void DrawEnhancementsMenu() {
{ .tooltip = "Renders game objects regardless of camera distance" });
UIWidgets::CVarCheckbox("Select any star from menu", "gCompletedGame",
{ .tooltip = "Unlocks extra mode and sets all gold cups." });
UIWidgets::CVarCheckbox("Disable Culling", "gNoCulling", { .tooltip = "Disable original culling of mk64" });
UIWidgets::CVarSliderFloat(
"Far Frustrum", "gFarFrustrum", 0.0f, 10000.0f, 10000.0f,
{ .tooltip = "Say how Far the Frustrum are when 'Disable Culling' are enable", .step = 10.0f });
ImGui::EndMenu();
}
+7 -2
View File
@@ -630,7 +630,8 @@ void render_palm_trees(Camera* camera, Mat4 arg1, UNUSED struct Actor* actor) {
spD4[2] = var_s1->pos[2];
if (is_within_render_distance(camera->pos, spD4, camera->rot[1], 0.0f, gCameraZoom[camera - camera1], var_f22) <
0.0f) {
0.0f &&
CVarGetInteger("gNoCulling", 0) == 0) {
var_s1++;
continue;
}
@@ -691,6 +692,9 @@ void render_actor_shell(Camera* camera, Mat4 matrix, struct ShellActor* shell) {
f32 temp_f0 =
is_within_render_distance(camera->pos, shell->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 490000.0f);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_f0 = CLAMP(temp_f0, 0.0f, 40000.0f);
}
s32 maxObjectsReached;
if (temp_f0 < 0.0f) {
actor_not_rendered(camera, (struct Actor*) shell);
@@ -754,7 +758,8 @@ UNUSED void func_8029ABD4(f32* pos, s16 state) {
void func_8029AC18(Camera* camera, Mat4 arg1, struct Actor* arg2) {
if (is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1],
4000000.0f) < 0) {
4000000.0f) < 0 &&
CVarGetInteger("gNoCulling", 0) == 0) {
return;
}
+7 -1
View File
@@ -3359,6 +3359,9 @@ void render_object_boos(s32 arg0) {
objectIndex = indexObjectList3[someIndex];
if (gObjectList[objectIndex].state >= 2) {
temp_s2 = func_8008A364(objectIndex, arg0, 0x4000U, 0x00000320);
if (CVarGetInteger("gNoCulling", 0) == 1) {
temp_s2 = MIN(temp_s2, 0x15F91U);
}
if (is_obj_flag_status_active(objectIndex, VISIBLE) != 0) {
func_800523B8(objectIndex, arg0, temp_s2);
}
@@ -4171,7 +4174,7 @@ void render_object_seagulls(s32 arg0) {
for (i = 0; i < NUM_SEAGULLS; i++) {
var_s1 = indexObjectList2[i];
if (func_8008A364(var_s1, arg0, 0x5555U, 0x000005DC) < 0x9C401) {
if (func_8008A364(var_s1, arg0, 0x5555U, 0x000005DC) < 0x9C401 && CVarGetInteger("gNoCulling", 0) == 0) {
D_80165908 = 1;
func_800722A4(var_s1, 2);
}
@@ -4232,6 +4235,9 @@ void render_object_hedgehogs(s32 arg0) {
for (someIndex = 0; someIndex < NUM_HEDGEHOGS; someIndex++) {
test = indexObjectList2[someIndex];
something = func_8008A364(test, arg0, 0x4000U, 0x000003E8);
if (CVarGetInteger("gNoCulling", 0) == 1) {
something = MIN(something, 0x52211U - 1);
}
if (is_obj_flag_status_active(test, VISIBLE) != 0) {
set_object_flag_status_true(test, 0x00200000);
if (something < 0x2711U) {
+4
View File
@@ -110,6 +110,10 @@ u16 check_player_camera_collision(Player* player, Camera* camera, f32 arg2, f32
s16 var_v0;
u16 ret;
if (CVarGetInteger("gNoCulling", 0) == 1) {
return true;
}
ret = false;
switch (gActiveScreenMode) { /* irregular */
case SCREEN_MODE_1P:
+5
View File
@@ -2788,6 +2788,11 @@ void func_800788F8(s32 objectIndex, u16 rot, Camera* camera) {
set_object_flag_status_true(objectIndex, 0x00000010);
return;
}
if (CVarGetInteger("gNoCulling", 0) == 1) {
gObjectList[objectIndex].unk_09C = (D_8018D218 + (D_8018D1E8 * temp_v0));
set_object_flag_status_true(objectIndex, 0x00000010);
return;
}
set_object_flag_status_false(objectIndex, 0x00000010);
}