mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
Add AWESOME new lighting color functions
This commit is contained in:
parent
26683b9b4f
commit
3359ebba0b
10 changed files with 161 additions and 16 deletions
|
@ -2946,6 +2946,10 @@ function shake_camera_yaw(pos, focus)
|
|||
-- ...
|
||||
end
|
||||
|
||||
function skip_camera_interpolation()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param c Camera
|
||||
function soft_reset_camera(c)
|
||||
-- ...
|
||||
|
@ -7885,6 +7889,12 @@ function get_lighting_color(index)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @return integer
|
||||
function get_lighting_color_ambient(index)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @return number
|
||||
function get_lighting_dir(index)
|
||||
|
@ -7925,6 +7935,12 @@ function set_lighting_color(index, value)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @param value integer
|
||||
function set_lighting_color_ambient(index, value)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @param value number
|
||||
function set_lighting_dir(index, value)
|
||||
|
|
|
@ -1706,6 +1706,24 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [skip_camera_interpolation](#skip_camera_interpolation)
|
||||
|
||||
### Lua Example
|
||||
`skip_camera_interpolation()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void skip_camera_interpolation(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [soft_reset_camera](#soft_reset_camera)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
@ -1135,6 +1135,26 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [get_lighting_color_ambient](#get_lighting_color_ambient)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = get_lighting_color_ambient(index)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u8 get_lighting_color_ambient(u8 index);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_lighting_dir](#get_lighting_dir)
|
||||
|
||||
### Lua Example
|
||||
|
@ -1275,6 +1295,27 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [set_lighting_color_ambient](#set_lighting_color_ambient)
|
||||
|
||||
### Lua Example
|
||||
`set_lighting_color_ambient(index, value)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
| value | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_lighting_color_ambient(u8 index, u8 value);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_lighting_dir](#set_lighting_dir)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
@ -710,6 +710,7 @@
|
|||
- [shake_camera_pitch](functions-3.md#shake_camera_pitch)
|
||||
- [shake_camera_roll](functions-3.md#shake_camera_roll)
|
||||
- [shake_camera_yaw](functions-3.md#shake_camera_yaw)
|
||||
- [skip_camera_interpolation](functions-3.md#skip_camera_interpolation)
|
||||
- [soft_reset_camera](functions-3.md#soft_reset_camera)
|
||||
- [start_cutscene](functions-3.md#start_cutscene)
|
||||
- [start_object_cutscene_without_focus](functions-3.md#start_object_cutscene_without_focus)
|
||||
|
@ -1655,6 +1656,7 @@
|
|||
- [get_fog_color](functions-5.md#get_fog_color)
|
||||
- [get_fog_intensity](functions-5.md#get_fog_intensity)
|
||||
- [get_lighting_color](functions-5.md#get_lighting_color)
|
||||
- [get_lighting_color_ambient](functions-5.md#get_lighting_color_ambient)
|
||||
- [get_lighting_dir](functions-5.md#get_lighting_dir)
|
||||
- [get_skybox](functions-5.md#get_skybox)
|
||||
- [get_skybox_color](functions-5.md#get_skybox_color)
|
||||
|
@ -1662,6 +1664,7 @@
|
|||
- [set_fog_color](functions-5.md#set_fog_color)
|
||||
- [set_fog_intensity](functions-5.md#set_fog_intensity)
|
||||
- [set_lighting_color](functions-5.md#set_lighting_color)
|
||||
- [set_lighting_color_ambient](functions-5.md#set_lighting_color_ambient)
|
||||
- [set_lighting_dir](functions-5.md#set_lighting_dir)
|
||||
- [set_override_far](functions-5.md#set_override_far)
|
||||
- [set_override_fov](functions-5.md#set_override_fov)
|
||||
|
|
|
@ -184,7 +184,7 @@ static f32 sDepthZMult = 1;
|
|||
static f32 sDepthZSub = 0;
|
||||
|
||||
Vec3f gLightingDir;
|
||||
Color gLightingColor = { 255, 255, 255 };
|
||||
Color gLightingColor[2] = { { 255, 255, 255 }, { 255, 255, 255 } };
|
||||
Color gVertexColor = { 255, 255, 255 };
|
||||
Color gFogColor = { 255, 255, 255 };
|
||||
f32 gFogIntensity = 1;
|
||||
|
@ -792,9 +792,9 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons
|
|||
rsp.lights_changed = false;
|
||||
}
|
||||
|
||||
int r = rsp.current_lights[rsp.current_num_lights - 1].col[0];
|
||||
int g = rsp.current_lights[rsp.current_num_lights - 1].col[1];
|
||||
int b = rsp.current_lights[rsp.current_num_lights - 1].col[2];
|
||||
int r = rsp.current_lights[rsp.current_num_lights - 1].col[0] * gLightingColor[1][0] / 255.0f;
|
||||
int g = rsp.current_lights[rsp.current_num_lights - 1].col[1] * gLightingColor[1][1] / 255.0f;
|
||||
int b = rsp.current_lights[rsp.current_num_lights - 1].col[2] * gLightingColor[1][2] / 255.0f;
|
||||
|
||||
for (int32_t i = 0; i < rsp.current_num_lights - 1; i++) {
|
||||
float intensity = 0;
|
||||
|
@ -803,15 +803,12 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons
|
|||
intensity += vn->n[2] * rsp.current_lights_coeffs[i][2];
|
||||
intensity /= 127.0f;
|
||||
if (intensity > 0.0f) {
|
||||
r += intensity * rsp.current_lights[i].col[0];
|
||||
g += intensity * rsp.current_lights[i].col[1];
|
||||
b += intensity * rsp.current_lights[i].col[2];
|
||||
r += intensity * rsp.current_lights[i].col[0] * gLightingColor[0][0] / 255.0f;
|
||||
g += intensity * rsp.current_lights[i].col[1] * gLightingColor[0][1] / 255.0f;
|
||||
b += intensity * rsp.current_lights[i].col[2] * gLightingColor[0][2] / 255.0f;
|
||||
}
|
||||
}
|
||||
|
||||
r *= gLightingColor[0] / 255.0f;
|
||||
g *= gLightingColor[1] / 255.0f;
|
||||
b *= gLightingColor[2] / 255.0f;
|
||||
d->color.r = r > 255 ? 255 : r;
|
||||
d->color.g = g > 255 ? 255 : g;
|
||||
d->color.b = b > 255 ? 255 : b;
|
||||
|
|
|
@ -14,7 +14,7 @@ struct GfxDimensions {
|
|||
extern struct GfxDimensions gfx_current_dimensions;
|
||||
|
||||
extern Vec3f gLightingDir;
|
||||
extern Color gLightingColor;
|
||||
extern Color gLightingColor[2];
|
||||
extern Color gVertexColor;
|
||||
extern Color gFogColor;
|
||||
extern f32 gFogIntensity;
|
||||
|
|
|
@ -11868,6 +11868,21 @@ int smlua_func_shake_camera_yaw(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_skip_camera_interpolation(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", "skip_camera_interpolation", 0, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
skip_camera_interpolation();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_soft_reset_camera(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
@ -29276,6 +29291,23 @@ int smlua_func_get_lighting_color(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_lighting_color_ambient(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", "get_lighting_color_ambient", 1, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_lighting_color_ambient"); return 0; }
|
||||
|
||||
lua_pushinteger(L, get_lighting_color_ambient(index));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_lighting_dir(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
@ -29397,6 +29429,25 @@ int smlua_func_set_lighting_color(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_lighting_color_ambient(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 2) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_lighting_color_ambient", 2, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_lighting_color_ambient"); return 0; }
|
||||
u8 value = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_lighting_color_ambient"); return 0; }
|
||||
|
||||
set_lighting_color_ambient(index, value);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_lighting_dir(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
@ -33481,6 +33532,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "shake_camera_pitch", smlua_func_shake_camera_pitch);
|
||||
smlua_bind_function(L, "shake_camera_roll", smlua_func_shake_camera_roll);
|
||||
smlua_bind_function(L, "shake_camera_yaw", smlua_func_shake_camera_yaw);
|
||||
smlua_bind_function(L, "skip_camera_interpolation", smlua_func_skip_camera_interpolation);
|
||||
smlua_bind_function(L, "soft_reset_camera", smlua_func_soft_reset_camera);
|
||||
smlua_bind_function(L, "start_cutscene", smlua_func_start_cutscene);
|
||||
smlua_bind_function(L, "start_object_cutscene_without_focus", smlua_func_start_object_cutscene_without_focus);
|
||||
|
@ -34371,6 +34423,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
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_lighting_color", smlua_func_get_lighting_color);
|
||||
smlua_bind_function(L, "get_lighting_color_ambient", smlua_func_get_lighting_color_ambient);
|
||||
smlua_bind_function(L, "get_lighting_dir", smlua_func_get_lighting_dir);
|
||||
smlua_bind_function(L, "get_skybox", smlua_func_get_skybox);
|
||||
smlua_bind_function(L, "get_skybox_color", smlua_func_get_skybox_color);
|
||||
|
@ -34378,6 +34431,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
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_lighting_color", smlua_func_set_lighting_color);
|
||||
smlua_bind_function(L, "set_lighting_color_ambient", smlua_func_set_lighting_color_ambient);
|
||||
smlua_bind_function(L, "set_lighting_dir", smlua_func_set_lighting_dir);
|
||||
smlua_bind_function(L, "set_override_far", smlua_func_set_override_far);
|
||||
smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov);
|
||||
|
|
|
@ -34,12 +34,23 @@ void set_lighting_dir(u8 index, f32 value) {
|
|||
|
||||
u8 get_lighting_color(u8 index) {
|
||||
if (index > 2) { return 0; }
|
||||
return gLightingColor[index];
|
||||
return gLightingColor[0][index];
|
||||
}
|
||||
|
||||
u8 get_lighting_color_ambient(u8 index) {
|
||||
if (index > 2) { return 0; }
|
||||
return gLightingColor[1][index];
|
||||
}
|
||||
|
||||
void set_lighting_color(u8 index, u8 value) {
|
||||
if (index > 2) { return; }
|
||||
gLightingColor[index] = value;
|
||||
gLightingColor[0][index] = value;
|
||||
gLightingColor[1][index] = value;
|
||||
}
|
||||
|
||||
void set_lighting_color_ambient(u8 index, u8 value) {
|
||||
if (index > 2) { return; }
|
||||
gLightingColor[1][index] = value;
|
||||
}
|
||||
|
||||
///
|
||||
|
|
|
@ -11,7 +11,9 @@ f32 get_lighting_dir(u8 index);
|
|||
void set_lighting_dir(u8 index, f32 value);
|
||||
|
||||
u8 get_lighting_color(u8 index);
|
||||
u8 get_lighting_color_ambient(u8 index);
|
||||
void set_lighting_color(u8 index, u8 value);
|
||||
void set_lighting_color_ambient(u8 index, u8 value);
|
||||
|
||||
u8 get_vertex_color(u8 index);
|
||||
void set_vertex_color(u8 index, u8 value);
|
||||
|
|
|
@ -669,9 +669,12 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect
|
|||
gLightingDir[0] = 0;
|
||||
gLightingDir[1] = 0;
|
||||
gLightingDir[2] = 0;
|
||||
gLightingColor[0] = 255;
|
||||
gLightingColor[1] = 255;
|
||||
gLightingColor[2] = 255;
|
||||
gLightingColor[0][0] = 255;
|
||||
gLightingColor[0][1] = 255;
|
||||
gLightingColor[0][2] = 255;
|
||||
gLightingColor[1][0] = 255;
|
||||
gLightingColor[1][1] = 255;
|
||||
gLightingColor[1][2] = 255;
|
||||
gVertexColor[0] = 255;
|
||||
gVertexColor[1] = 255;
|
||||
gVertexColor[2] = 255;
|
||||
|
|
Loading…
Reference in a new issue