Some doc on env light settings (#1307)

* remove `LightSettings` struct, typedef for zapd

* more decimal

* fog far -> z far

* `LIGHTCTX_FOGNEAR_MAX`, `LIGHTCTX_ZFAR_MAX`

* name sp88,sp8C in `Environment_Update`

* `EnvLightSettings.fogNear` -> `blendRateAndFogNear` and macros

* A different struct for `EnvironmentContext.lightSettings`

* Uniform zapd compat typedefs todos

* `LIGHTCTX_` -> `ENV_`

* Comment on `blendRateAndFogNear` + "fogFar"

* Move fogFar~1000 comment to zFar

* comment rewrite attempt

* move relevant macros down

Co-authored-by: fig02 <fig02srl@gmail.com>
This commit is contained in:
Dragorn421
2022-11-02 00:00:38 +01:00
committed by GitHub
parent 451e855dbc
commit d2191a5d48
14 changed files with 151 additions and 125 deletions
+28 -4
View File
@@ -139,10 +139,34 @@ typedef struct {
/* 0x09 */ s8 light2Dir[3];
/* 0x0C */ u8 light2Color[3];
/* 0x0F */ u8 fogColor[3];
/* 0x12 */ s16 fogNear;
/* 0x14 */ s16 fogFar;
/* 0x12 */ s16 fogNear; // ranges from 0-1000 (0: starts immediately, 1000: no fog), but is clamped to ENV_FOGNEAR_MAX
/* 0x14 */ s16 zFar; // Max depth (render distance) of the view as a whole. fogFar will always match zFar
} CurrentEnvLightSettings; // size = 0x16
// `EnvLightSettings` is very similar to `CurrentEnvLightSettings` with one key difference.
// The light settings data in the scene packs blend rate information with the fog near value.
// The blendRate determines how fast the current light settings fade to the next one
// (under LIGHT_MODE_SETTINGS, otherwise unused).
// Get blend rate from `EnvLightSettings.blendRateAndFogNear` in 0-255 range
#define ENV_LIGHT_SETTINGS_BLEND_RATE_U8(blendRateAndFogNear) (((blendRateAndFogNear) >> 10) * 4)
#define ENV_LIGHT_SETTINGS_FOG_NEAR(blendRateAndFogNear) ((blendRateAndFogNear) & 0x3FF)
typedef struct {
/* 0x00 */ u8 ambientColor[3];
/* 0x03 */ s8 light1Dir[3];
/* 0x06 */ u8 light1Color[3];
/* 0x09 */ s8 light2Dir[3];
/* 0x0C */ u8 light2Color[3];
/* 0x0F */ u8 fogColor[3];
/* 0x12 */ s16 blendRateAndFogNear;
/* 0x14 */ s16 zFar;
} EnvLightSettings; // size = 0x16
// ZAPD compatibility typedefs
// TODO: Remove when ZAPD adds support for them
typedef EnvLightSettings LightSettings;
typedef struct {
/* 0x00 */ char unk_00[0x02];
/* 0x02 */ u16 sceneTimeSpeed; // time speed value from the scene file
@@ -178,7 +202,7 @@ typedef struct {
/* 0x92 */ s16 adjLight1Color[3];
/* 0x98 */ s16 adjFogColor[3];
/* 0x9E */ s16 adjFogNear;
/* 0xA0 */ s16 adjFogFar;
/* 0xA0 */ s16 adjZFar;
/* 0xA2 */ char unk_A2[0x06];
/* 0xA8 */ Vec3s windDirection;
/* 0xB0 */ f32 windSpeed;
@@ -188,7 +212,7 @@ typedef struct {
/* 0xBD */ u8 lightSetting; // only used with `LIGHT_MODE_SETTINGS` or on override
/* 0xBE */ u8 prevLightSetting;
/* 0xBF */ u8 lightSettingOverride;
/* 0xC0 */ EnvLightSettings lightSettings; // settings for the currently "live" lights
/* 0xC0 */ CurrentEnvLightSettings lightSettings; // settings for the currently "live" lights
/* 0xD6 */ u16 lightBlendRateOverride;
/* 0xD8 */ f32 lightBlend; // only used with `LIGHT_MODE_SETTINGS` or on setting override
/* 0xDC */ u8 lightBlendOverride;