You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vr_box.c builds the dlist for a box, either to draw a literal skybox, or a prerendered room box. The distinction is important.
vr_box_draw.c renders that box
z_kankyo.c handles the environmental effects (weather, lighting, sky). It only manages the literal skyboxes through Environment_UpdateSkybox
Now here's where you have a bit of a branch. You've got two game states Play and FileSelect.
FileSelect includes from z_kankyo.c to create that background image of the sky behind everything else. The state does not import enough of the engine to create a full scene. It just uses the above to get a skybox rendered. In this context, EnvironmentContext.skyboxDisabled is initialized to zero and never touched.
Play on the other hand gets you the full engine, and part of this is the scene system.
z_scene.c parses scene data, setting up the configuration for the scene.
So in the play state, EnvironmentContext.skyboxDisabled is initialized by Scene_ExecuteCommands when it parses command 0x12 (SCENE_CMD_ID_SKYBOX_DISABLES) which is a room scoped command. Neat.
In Play_Draw, you have two sections of the draw routine where vr_box_draw's Skybox_Draw occurs:
The first spot is where it renders behind the scene/room, a.k.a. your actual skybox. That block checks if EnvironmentContext.skyboxDisabled is set, and completely skips drawing if true.
Second spot is where it renders over the top of the scene/room, a.k.a your prerendered room.
As you might imagine, these draws mutually exclusive. Also, incorrectly documented in MM.
The last spot in Play_Draw that EnvironmentContext.skyboxDisabled appears is to stop a call to Skybox_UpdateMatrix. For whatever reason, it appears that the devs thought that something in Play_Draw would dirty the View, requiring the Skybox matrix to be re-calculated. More importantly, it is critical that Skybox_Draw is called on the same frame before Skybox_UpdateMatrix is, as otherwise it will dereference a stale pointer in GRAPH_ALLOC.
Last place outside of z_camera.c that EnvironmentContext.skyboxDisabled is used is in z_kankyo.c. In OoT it basically disables Environment_UpdateSkybox for the regular skybox, but not the "holy" skybox, while in MM it makes it do nothing.
I did look into z_camera.c. The key functions to this discussion are Camera_BGCheckInfo vs func_80043F94. func_80043F94 is initially identical to Camera_BGCheckInfo up until the part where Camera_BGCheckInfo returns nonsense. func_80043F94 seems to just perform a few more collision checks that probably don't affect camera behavior substantially.
I don't fully understand it, but my feeling is that z_camera.c is using EnvironmentContext.skyboxDisabled as a way to check to see if the room has a sky. It's a little odd to do, but I don't know if that necessitates a name change. The change in camera behavior is probably minor, and is probably more appropriately documented as a quirk of the camera system.
Activity
mzxrules commentedon Sep 4, 2026
Quick recap of how the systems interact:
Environment_UpdateSkyboxNow here's where you have a bit of a branch. You've got two game states Play and FileSelect.
FileSelect includes from z_kankyo.c to create that background image of the sky behind everything else. The state does not import enough of the engine to create a full scene. It just uses the above to get a skybox rendered. In this context,
EnvironmentContext.skyboxDisabledis initialized to zero and never touched.Play on the other hand gets you the full engine, and part of this is the scene system.
So in the play state,
EnvironmentContext.skyboxDisabledis initialized byScene_ExecuteCommandswhen it parses command 0x12 (SCENE_CMD_ID_SKYBOX_DISABLES) which is a room scoped command. Neat.In
Play_Draw, you have two sections of the draw routine wherevr_box_draw'sSkybox_Drawoccurs:EnvironmentContext.skyboxDisabledis set, and completely skips drawing if true.As you might imagine, these draws mutually exclusive. Also, incorrectly documented in MM.
The last spot in
Play_DrawthatEnvironmentContext.skyboxDisabledappears is to stop a call toSkybox_UpdateMatrix. For whatever reason, it appears that the devs thought that something inPlay_Drawwould dirty theView, requiring the Skybox matrix to be re-calculated. More importantly, it is critical thatSkybox_Drawis called on the same frame beforeSkybox_UpdateMatrixis, as otherwise it will dereference a stale pointer in GRAPH_ALLOC.Last place outside of z_camera.c that
EnvironmentContext.skyboxDisabledis used is in z_kankyo.c. In OoT it basically disablesEnvironment_UpdateSkyboxfor the regular skybox, but not the "holy" skybox, while in MM it makes it do nothing.I did look into z_camera.c. The key functions to this discussion are
Camera_BGCheckInfovsfunc_80043F94.func_80043F94is initially identical toCamera_BGCheckInfoup until the part whereCamera_BGCheckInforeturns nonsense.func_80043F94seems to just perform a few more collision checks that probably don't affect camera behavior substantially.I don't fully understand it, but my feeling is that z_camera.c is using
EnvironmentContext.skyboxDisabledas a way to check to see if the room has a sky. It's a little odd to do, but I don't know if that necessitates a name change. The change in camera behavior is probably minor, and is probably more appropriately documented as a quirk of the camera system.