Skip to content

Rename EnvironmentContext.skyboxDisabled #2825

Open

Description

@Dragorn421

It also changes camera collision

Activity

  1. mzxrules commented on Sep 4, 2026

    @mzxrules
    Contributor

    Quick recap of how the systems interact:

    • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions