diff --git a/include/config/config_graphics.h b/include/config/config_graphics.h index 03d8ff11..33f52a13 100644 --- a/include/config/config_graphics.h +++ b/include/config/config_graphics.h @@ -129,14 +129,16 @@ /** - * Limits the horizontal fov on emulator like on console. May break viewport widescreen hacks. + * May break viewport widescreen hacks. + * When this is disabled, the culling will only be skipped according to the NO_CULLING_EMULATOR_BLACKLIST. */ -// #define HORIZONTAL_CULLING_ON_EMULATOR +// #define CULLING_ON_EMULATOR /** - * Makes objects bellow the screen be culled. + * Makes objects below the screen be culled. + * NOTE: Vanilla objects do not account for vertical culling. */ -#define VERTICAL_CULLING +// #define VERTICAL_CULLING /** * If the first command of an object´s geolayout is not GEO_CULLING_RADIUS, DEFAULT_CULLING_RADIUS diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index c5d5c97b..295d6c4e 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -567,27 +567,15 @@ void geo_process_perspective(struct GraphNodePerspective *node) { sAspectRatio = 4.0f / 3.0f; // 1.33333f #endif - // The reason this is not divided as an integer is to prevent an integer division. - f32 vHalfFov = ( (f32) ((node->fov * 4096) + 8192) ) / 45.f; + f32 vHalfFov = ( ((node->fov * 4096.f) + 8192.f) ) / 45.f; // We need to account for aspect ratio changes by multiplying by the widescreen horizontal stretch // (normally 1.775). - f32 hHalfFov = vHalfFov * sAspectRatio; - - node->halfFovHorizontal = tans(hHalfFov); + node->halfFovHorizontal = tans(vHalfFov * sAspectRatio); #ifdef VERTICAL_CULLING node->halfFovVertical = tans(vHalfFov); #endif - -#ifndef HORIZONTAL_CULLING_ON_EMULATOR - // If an emulator is detected, use a large value for the half fov - // horizontal value to account for viewport widescreen hacks. - - if(!(gEmulator & EMU_CONSOLE)){ - node->halfFovHorizontal = 9999.0f; - } -#endif guPerspective(mtx, &perspNorm, node->fov, sAspectRatio, node->near / WORLD_SCALE, node->far / WORLD_SCALE, 1.0f); gSPPerspNormalize(gDisplayListHead++, perspNorm); @@ -1065,6 +1053,9 @@ void geo_process_shadow(struct GraphNodeShadow *node) { * * Since (0,0,0) is unaffected by rotation, columns 0, 1 and 2 are ignored. */ + +#define NO_CULLING_EMULATOR_BLACKLIST (EMU_CONSOLE | EMU_WIIVC | EMU_ARES | EMU_SIMPLE64 | EMU_CEN64) + s32 obj_is_in_view(struct GraphNodeObject *node) { struct GraphNode *geo = node->sharedChild; @@ -1089,6 +1080,13 @@ s32 obj_is_in_view(struct GraphNodeObject *node) { return FALSE; } +#ifndef CULLING_ON_EMULATOR + // If an emulator is detected, skip any other culling. + if(!(gEmulator & NO_CULLING_EMULATOR_BLACKLIST)){ + return TRUE; + } +#endif + #ifdef VERTICAL_CULLING f32 vScreenEdge = -cameraToObjectDepth * gCurGraphNodeCamFrustum->halfFovVertical;