Add ability to set fog intensity multiplier (ramps up quickly)

This commit is contained in:
Agent X 2023-11-01 21:21:46 -04:00
parent a4cb43bbb9
commit 395ac50532
9 changed files with 100 additions and 2 deletions

View File

@ -8676,6 +8676,11 @@ function get_fog_color(index)
-- ...
end
--- @return number
function get_fog_intensity()
-- ...
end
--- @return boolean
function get_got_file_coin_hi_score()
-- ...
@ -8883,6 +8888,12 @@ function set_fog_color(index, value)
-- ...
end
--- @param intensity number
--- @return nil
function set_fog_intensity(intensity)
-- ...
end
--- @param value boolean
--- @return nil
function set_got_file_coin_hi_score(value)

View File

@ -813,6 +813,24 @@
<br />
## [get_fog_intensity](#get_fog_intensity)
### Lua Example
`local numberValue = get_fog_intensity()`
### Parameters
- None
### Returns
- `number`
### C Prototype
`f32 get_fog_intensity(void);`
[:arrow_up_small:](#)
<br />
## [get_got_file_coin_hi_score](#get_got_file_coin_hi_score)
### Lua Example
@ -1466,6 +1484,26 @@
<br />
## [set_fog_intensity](#set_fog_intensity)
### Lua Example
`set_fog_intensity(intensity)`
### Parameters
| Field | Type |
| ----- | ---- |
| intensity | `number` |
### Returns
- None
### C Prototype
`void set_fog_intensity(f32 intensity);`
[:arrow_up_small:](#)
<br />
## [set_got_file_coin_hi_score](#set_got_file_coin_hi_score)
### Lua Example

View File

@ -1625,6 +1625,7 @@
- [get_envfx](functions-5.md#get_envfx)
- [get_environment_region](functions-5.md#get_environment_region)
- [get_fog_color](functions-5.md#get_fog_color)
- [get_fog_intensity](functions-5.md#get_fog_intensity)
- [get_got_file_coin_hi_score](functions-5.md#get_got_file_coin_hi_score)
- [get_hand_foot_pos_x](functions-5.md#get_hand_foot_pos_x)
- [get_hand_foot_pos_y](functions-5.md#get_hand_foot_pos_y)
@ -1658,6 +1659,7 @@
- [save_file_set_using_backup_slot](functions-5.md#save_file_set_using_backup_slot)
- [set_environment_region](functions-5.md#set_environment_region)
- [set_fog_color](functions-5.md#set_fog_color)
- [set_fog_intensity](functions-5.md#set_fog_intensity)
- [set_got_file_coin_hi_score](functions-5.md#set_got_file_coin_hi_score)
- [set_last_completed_course_num](functions-5.md#set_last_completed_course_num)
- [set_last_completed_star_num](functions-5.md#set_last_completed_star_num)

View File

@ -184,6 +184,7 @@ Vec3f gLightingDir;
Color gLightingColor = { 255, 255, 255 };
Color gVertexColor = { 255, 255, 255 };
Color gFogColor = { 255, 255, 255 };
f32 gFogIntensity = 1;
// 4x4 pink-black checkerboard texture to indicate missing textures
#define MISSING_W 4
@ -848,7 +849,7 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons
z *= sDepthZMult;
z += sDepthZAdd;
float fog_z = z * winv * rsp.fog_mul + rsp.fog_offset;
float fog_z = z * winv * rsp.fog_mul * gFogIntensity + rsp.fog_offset;
if (fog_z < 0) fog_z = 0;
if (fog_z > 255) fog_z = 255;
@ -1013,7 +1014,7 @@ static void OPTIMIZE_O3 gfx_sp_tri1(uint8_t vtx1_idx, uint8_t vtx2_idx, uint8_t
float u = (v_arr[i]->u - rdp.texture_tile.uls * 8) / 32.0f;
float v = (v_arr[i]->v - rdp.texture_tile.ult * 8) / 32.0f;
if ((rdp.other_mode_h & (3U << G_MDSFT_TEXTFILT)) != G_TF_POINT) {
// Linear filter adds 0.5f to the coordinates
// Linear filter adds 0.5f to the coordinates (why?)
u += 0.5f;
v += 0.5f;
}

View File

@ -17,6 +17,7 @@ extern Vec3f gLightingDir;
extern Color gLightingColor;
extern Color gVertexColor;
extern Color gFogColor;
extern f32 gFogIntensity;
#ifdef __cplusplus
extern "C" {

View File

@ -28687,6 +28687,21 @@ int smlua_func_get_fog_color(lua_State* L) {
return 1;
}
int smlua_func_get_fog_intensity(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 0) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_fog_intensity", 0, top);
return 0;
}
lua_pushnumber(L, get_fog_intensity());
return 1;
}
int smlua_func_get_got_file_coin_hi_score(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
@ -29266,6 +29281,23 @@ int smlua_func_set_fog_color(lua_State* L) {
return 1;
}
int smlua_func_set_fog_intensity(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_fog_intensity", 1, top);
return 0;
}
f32 intensity = smlua_to_number(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_fog_intensity"); return 0; }
set_fog_intensity(intensity);
return 1;
}
int smlua_func_set_got_file_coin_hi_score(lua_State* L) {
if (L == NULL) { return 0; }
@ -32709,6 +32741,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "get_envfx", smlua_func_get_envfx);
smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region);
smlua_bind_function(L, "get_fog_color", smlua_func_get_fog_color);
smlua_bind_function(L, "get_fog_intensity", smlua_func_get_fog_intensity);
smlua_bind_function(L, "get_got_file_coin_hi_score", smlua_func_get_got_file_coin_hi_score);
smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x);
smlua_bind_function(L, "get_hand_foot_pos_y", smlua_func_get_hand_foot_pos_y);
@ -32742,6 +32775,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "save_file_set_using_backup_slot", smlua_func_save_file_set_using_backup_slot);
smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region);
smlua_bind_function(L, "set_fog_color", smlua_func_set_fog_color);
smlua_bind_function(L, "set_fog_intensity", smlua_func_set_fog_intensity);
smlua_bind_function(L, "set_got_file_coin_hi_score", smlua_func_set_got_file_coin_hi_score);
smlua_bind_function(L, "set_last_completed_course_num", smlua_func_set_last_completed_course_num);
smlua_bind_function(L, "set_last_completed_star_num", smlua_func_set_last_completed_star_num);

View File

@ -558,6 +558,14 @@ void set_fog_color(u8 index, u8 value) {
gFogColor[index] = value;
}
f32 get_fog_intensity(void) {
return gFogIntensity;
}
void set_fog_intensity(f32 intensity) {
gFogIntensity = intensity;
}
///
s8 get_skybox(void) {

View File

@ -132,6 +132,8 @@ void set_vertex_color(u8 index, u8 value);
u8 get_fog_color(u8 index);
void set_fog_color(u8 index, u8 value);
f32 get_fog_intensity(void);
void set_fog_intensity(f32 intensity);
s8 get_skybox(void);
void set_override_skybox(s8 background);

View File

@ -653,6 +653,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect
gFogColor[0] = 255;
gFogColor[1] = 255;
gFogColor[2] = 255;
gFogIntensity = 1;
gOverrideBackground = -1;
gOverrideEnvFx = -1;
gDjuiRenderBehindHud = false;