diff --git a/actors/power_meter/model.inc.c b/actors/power_meter/model.inc.c index ca1aff748..edb9bcd51 100644 --- a/actors/power_meter/model.inc.c +++ b/actors/power_meter/model.inc.c @@ -56,7 +56,7 @@ const Gfx dl_power_meter_base[] = { gsDPSetRenderMode(G_RM_TEX_EDGE, G_RM_TEX_EDGE2), gsDPSetTextureFilter(G_TF_POINT), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsSPVertex(vertex_power_meter_base, 8, 0), + gsSPVertexNonGlobal(vertex_power_meter_base, 8, 0), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), gsDPTileSync(), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 6, G_TX_NOLOD, G_TX_CLAMP, 5, G_TX_NOLOD), @@ -78,7 +78,7 @@ ROM_ASSET_LOAD_VTX(vertex_power_meter_health_segments, 0x00201410, 96653, 0x0002 // 0x03029570 - 0x030295A0 const Gfx dl_power_meter_health_segments_begin[] = { gsDPPipeSync(), - gsSPVertex(vertex_power_meter_health_segments, 4, 0), + gsSPVertexNonGlobal(vertex_power_meter_health_segments, 4, 0), gsDPTileSync(), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 5, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), diff --git a/actors/sparkle_animation/model.inc.c b/actors/sparkle_animation/model.inc.c index b0384cc37..7f62e7be9 100644 --- a/actors/sparkle_animation/model.inc.c +++ b/actors/sparkle_animation/model.inc.c @@ -22,18 +22,20 @@ ROM_ASSET_LOAD_TEXTURE(sparkles_animation_seg4_texture_04034A88, "actors/sparkle // 0x04035288 - 0x04035300 const Gfx sparkles_animation_seg4_dl_04035288[] = { gsSPClearGeometryMode(G_LIGHTING), - gsDPSetCombineMode(G_CC_MODULATEIA, G_CC_MODULATEIA), + gsDPSetCombineMode(G_CC_FADEA, G_CC_FADEA), + gsDPSetEnvColor(255, 255, 100, 255), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), gsDPSetTile(G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 5, G_TX_NOLOD), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), gsDPSetTile(G_IM_FMT_IA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 5, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), - gsSPVertexNonGlobal(sparkles_animation_seg4_vertex_04032A48, 4, 0), + gsSPVertex(sparkles_animation_seg4_vertex_04032A48, 4, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsSPSetGeometryMode(G_LIGHTING), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), + gsDPSetEnvColor(255, 255, 255, 255), gsSPEndDisplayList(), }; diff --git a/autogen/convert_constants.py b/autogen/convert_constants.py index 9dcbf602e..7cb49e24c 100644 --- a/autogen/convert_constants.py +++ b/autogen/convert_constants.py @@ -55,6 +55,7 @@ in_files = [ "src/engine/lighting_engine.h", "include/PR/gbi.h", "include/PR/gbi_extension.h", + "src/pc/gfx/gfx_pc.h", "src/engine/surface_load.h", "src/pc/lua/utils/smlua_audio_utils.h", ] diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 885b5a19d..245bc0c4b 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -3059,6 +3059,27 @@ BACKGROUND_CUSTOM = 10 --- @type SkyBackgroundParams --- | `BACKGROUND_PURPLE_SKY` --- | `BACKGROUND_CUSTOM` +SHADER_FLAG_HUE = 0 --- @type ShaderFlag +SHADER_FLAG_SATURATION = 1 --- @type ShaderFlag +SHADER_FLAG_BRIGHTNESS = 2 --- @type ShaderFlag +SHADER_FLAG_CONTRAST = 3 --- @type ShaderFlag +SHADER_FLAG_EXPOSURE = 4 --- @type ShaderFlag +SHADER_FLAG_DITHERING = 5 --- @type ShaderFlag +SHADER_FLAG_POSTERIZATION = 6 --- @type ShaderFlag +SHADER_FLAG_SCANLINES = 7 --- @type ShaderFlag +SHADER_FLAG_MAX = 8 --- @type ShaderFlag + +--- @alias ShaderFlag +--- | `SHADER_FLAG_HUE` +--- | `SHADER_FLAG_SATURATION` +--- | `SHADER_FLAG_BRIGHTNESS` +--- | `SHADER_FLAG_CONTRAST` +--- | `SHADER_FLAG_EXPOSURE` +--- | `SHADER_FLAG_DITHERING` +--- | `SHADER_FLAG_POSTERIZATION` +--- | `SHADER_FLAG_SCANLINES` +--- | `SHADER_FLAG_MAX` + --- @type integer GRAPH_RENDER_ACTIVE = (1 << 0) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 37531004a..1ceff4917 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -10790,6 +10790,51 @@ function surface_is_painting_warp(surf) -- ... end +--- @param flag ShaderFlag +--- @return boolean +--- Gets if a custom shader flag (`SHADER_FLAG_*`) is enabled or not +function get_shader_flag_enabled(flag) + -- ... +end + +--- @param flag ShaderFlag +--- @param enabled boolean +--- Enables a custom shader flag (`SHADER_FLAG_*`) for the renderer +function set_shader_flag_enabled(flag, enabled) + -- ... +end + +--- @param flag ShaderFlag +--- @return number +--- Gets a value for one of the custom shader flags (`SHADER_FLAG_*`) +function get_shader_flag_value(flag) + -- ... +end + +--- @param flag ShaderFlag +--- @param value number +--- Sets a value for one of the custom shader flags (`SHADER_FLAG_*`) for the renderer +function set_shader_flag_value(flag, value) + -- ... +end + +--- @return boolean +--- Gets if custom shader flags are enabled globally +function get_global_shader_flags_enabled() + -- ... +end + +--- @param enabled boolean +--- Enables custom shader flags as a global toggle, useful for disabling without manually going through every effect +function set_global_shader_flags_enabled(enabled) + -- ... +end + +--- Clears all custom shader flags (`SHADER_FLAG_*`) for the renderer +function clear_all_shader_flags() + -- ... +end + --- @param fov number --- Sets the override FOV function set_override_fov(fov) @@ -11032,7 +11077,7 @@ end --- @param name string --- @return Pointer_Vtx --- @return integer count ---- Gets a vertex buffer of the current mod from its name. Returns a pointer to the vertex buffering and its vertex count +--- Gets a vertex buffer of the current mod from its name. Returns a pointer to the vertex buffer and its vertex count function vtx_get_from_name(name) -- ... end diff --git a/bin/segment2.c b/bin/segment2.c index b10412813..eaeabea1d 100644 --- a/bin/segment2.c +++ b/bin/segment2.c @@ -2351,7 +2351,7 @@ const Gfx dl_transition_draw_filled_region[] = { const Gfx dl_skybox_begin[] = { gsDPPipeSync(), gsSPClearGeometryMode(G_LIGHTING), - gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), + gsDPSetCombineMode(G_CC_FADEA, G_CC_FADEA), gsSPPerspNormalize(0xFFFF), gsSPMatrix(&matrix_identity, G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH), gsSPEndDisplayList(), diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 4456ef42d..8b197bcb7 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -29,6 +29,8 @@ - [gbi_extension.h](#gbi_extensionh) - [geo_commands.h](#geo_commandsh) - [enum SkyBackgroundParams](#enum-SkyBackgroundParams) +- [gfx_pc.h](#gfx_pch) + - [enum ShaderFlag](#enum-ShaderFlag) - [graph_node.h](#graph_nodeh) - [interaction.c](#interactionc) - [interaction.h](#interactionh) @@ -1343,6 +1345,25 @@
+## [gfx_pc.h](#gfx_pc.h) + +### [enum ShaderFlag](#ShaderFlag) +| Identifier | Value | +| :--------- | :---- | +| SHADER_FLAG_HUE | 0 | +| SHADER_FLAG_SATURATION | 1 | +| SHADER_FLAG_BRIGHTNESS | 2 | +| SHADER_FLAG_CONTRAST | 3 | +| SHADER_FLAG_EXPOSURE | 4 | +| SHADER_FLAG_DITHERING | 5 | +| SHADER_FLAG_POSTERIZATION | 6 | +| SHADER_FLAG_SCANLINES | 7 | +| SHADER_FLAG_MAX | 8 | + +[:arrow_up_small:](#) + +
+ ## [graph_node.h](#graph_node.h) - GRAPH_RENDER_ACTIVE - GRAPH_RENDER_CHILDREN_FIRST diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index 8c21d8868..7a2ee4482 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -7576,1058 +7576,6 @@ Checks if the surface is a painting warp
- ---- -# functions from smlua_gfx_utils.h - -
- - -## [set_override_fov](#set_override_fov) - -### Description -Sets the override FOV - -### Lua Example -`set_override_fov(fov)` - -### Parameters -| Field | Type | -| ----- | ---- | -| fov | `number` | - -### Returns -- None - -### C Prototype -`void set_override_fov(f32 fov);` - -[:arrow_up_small:](#) - -
- -## [set_override_near](#set_override_near) - -### Description -Sets the override near plane - -### Lua Example -`set_override_near(near)` - -### Parameters -| Field | Type | -| ----- | ---- | -| near | `number` | - -### Returns -- None - -### C Prototype -`void set_override_near(f32 near);` - -[:arrow_up_small:](#) - -
- -## [set_override_far](#set_override_far) - -### Description -Sets the override far plane - -### Lua Example -`set_override_far(far)` - -### Parameters -| Field | Type | -| ----- | ---- | -| far | `number` | - -### Returns -- None - -### C Prototype -`void set_override_far(f32 far);` - -[:arrow_up_small:](#) - -
- -## [get_lighting_dir](#get_lighting_dir) - -### Description -Gets a value of the global lighting direction - -### Lua Example -`local numberValue = get_lighting_dir(index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | - -### Returns -- `number` - -### C Prototype -`f32 get_lighting_dir(u8 index);` - -[:arrow_up_small:](#) - -
- -## [set_lighting_dir](#set_lighting_dir) - -### Description -Sets a value of the global lighting direction - -### Lua Example -`set_lighting_dir(index, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| value | `number` | - -### Returns -- None - -### C Prototype -`void set_lighting_dir(u8 index, f32 value);` - -[:arrow_up_small:](#) - -
- -## [get_lighting_color](#get_lighting_color) - -### Description -Gets a value of the global lighting color - -### Lua Example -`local integerValue = get_lighting_color(index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | - -### Returns -- `integer` - -### C Prototype -`u8 get_lighting_color(u8 index);` - -[:arrow_up_small:](#) - -
- -## [get_lighting_color_ambient](#get_lighting_color_ambient) - -### Description -Gets a value of the global ambient lighting color - -### 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:](#) - -
- -## [set_lighting_color](#set_lighting_color) - -### Description -Sets a value of the global lighting color - -### Lua Example -`set_lighting_color(index, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void set_lighting_color(u8 index, u8 value);` - -[:arrow_up_small:](#) - -
- -## [set_lighting_color_ambient](#set_lighting_color_ambient) - -### Description -Sets a value of the global lighting color (run this after `set_lighting_color` for the ambient color to not be overriden) - -### 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:](#) - -
- -## [get_vertex_color](#get_vertex_color) - -### Description -Gets a value of the global vertex shading color - -### Lua Example -`local integerValue = get_vertex_color(index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | - -### Returns -- `integer` - -### C Prototype -`u8 get_vertex_color(u8 index);` - -[:arrow_up_small:](#) - -
- -## [set_vertex_color](#set_vertex_color) - -### Description -Sets a value of the global vertex shading color - -### Lua Example -`set_vertex_color(index, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void set_vertex_color(u8 index, u8 value);` - -[:arrow_up_small:](#) - -
- -## [get_fog_color](#get_fog_color) - -### Description -Gets a value of the global fog color - -### Lua Example -`local integerValue = get_fog_color(index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | - -### Returns -- `integer` - -### C Prototype -`u8 get_fog_color(u8 index);` - -[:arrow_up_small:](#) - -
- -## [set_fog_color](#set_fog_color) - -### Description -Sets a value of the global fog color - -### Lua Example -`set_fog_color(index, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void set_fog_color(u8 index, u8 value);` - -[:arrow_up_small:](#) - -
- -## [get_fog_intensity](#get_fog_intensity) - -### Description -Gets the intensity of the fog - -### Lua Example -`local numberValue = get_fog_intensity()` - -### Parameters -- None - -### Returns -- `number` - -### C Prototype -`f32 get_fog_intensity(void);` - -[:arrow_up_small:](#) - -
- -## [set_fog_intensity](#set_fog_intensity) - -### Description -Sets the intensity of the fog (this value scales very quickly, 1.0 to 1.1 is a desirable range) - -### Lua Example -`set_fog_intensity(intensity)` - -### Parameters -| Field | Type | -| ----- | ---- | -| intensity | `number` | - -### Returns -- None - -### C Prototype -`void set_fog_intensity(f32 intensity);` - -[:arrow_up_small:](#) - -
- -## [get_skybox](#get_skybox) - -### Description -Gets the current skybox - -### Lua Example -`local integerValue = get_skybox()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s8 get_skybox(void);` - -[:arrow_up_small:](#) - -
- -## [set_override_skybox](#set_override_skybox) - -### Description -Sets the override skybox - -### Lua Example -`set_override_skybox(background)` - -### Parameters -| Field | Type | -| ----- | ---- | -| background | `integer` | - -### Returns -- None - -### C Prototype -`void set_override_skybox(s8 background);` - -[:arrow_up_small:](#) - -
- -## [get_skybox_color](#get_skybox_color) - -### Description -Gets a value of the global skybox color - -### Lua Example -`local integerValue = get_skybox_color(index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | - -### Returns -- `integer` - -### C Prototype -`u8 get_skybox_color(u8 index);` - -[:arrow_up_small:](#) - -
- -## [set_skybox_color](#set_skybox_color) - -### Description -Sets a value of the global skybox color - -### Lua Example -`set_skybox_color(index, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void set_skybox_color(u8 index, u8 value);` - -[:arrow_up_small:](#) - -
- -## [gfx_parse](#gfx_parse) - -### Description -Traverses a display list. Takes a Lua function as a parameter, which is called back for each command in the display list with the parameters `cmd` (display list pointer), and `op` - -### Lua Example -`gfx_parse(cmd, func)` - -### Parameters -| Field | Type | -| ----- | ---- | -| cmd | `Pointer` <`Gfx`> | -| func | `Lua Function` () | - -### Returns -- None - -### C Prototype -`void gfx_parse(Gfx *cmd, LuaFunction func);` - -[:arrow_up_small:](#) - -
- -## [gfx_get_op](#gfx_get_op) - -### Description -Gets the op of the display list command - -### Lua Example -`local integerValue = gfx_get_op(cmd)` - -### Parameters -| Field | Type | -| ----- | ---- | -| cmd | `Pointer` <`Gfx`> | - -### Returns -- `integer` - -### C Prototype -`u32 gfx_get_op(Gfx *cmd);` - -[:arrow_up_small:](#) - -
- -## [gfx_get_display_list](#gfx_get_display_list) - -### Description -Gets the display list from a display list command if it has the op `G_DL` - -### Lua Example -`local pointerValue = gfx_get_display_list(cmd)` - -### Parameters -| Field | Type | -| ----- | ---- | -| cmd | `Pointer` <`Gfx`> | - -### Returns -- `Pointer` <`Gfx`> - -### C Prototype -`Gfx *gfx_get_display_list(Gfx *cmd);` - -[:arrow_up_small:](#) - -
- -## [gfx_get_vertex_buffer](#gfx_get_vertex_buffer) - -### Description -Gets the vertex buffer from a display list command if it has the op `G_VTX` - -### Lua Example -`local pointerValue = gfx_get_vertex_buffer(cmd)` - -### Parameters -| Field | Type | -| ----- | ---- | -| cmd | `Pointer` <`Gfx`> | - -### Returns -- `Pointer` <`Vtx`> - -### C Prototype -`Vtx *gfx_get_vertex_buffer(Gfx *cmd);` - -[:arrow_up_small:](#) - -
- -## [gfx_get_vertex_count](#gfx_get_vertex_count) - -### Description -Gets the number of vertices from a display list command if it has the op `G_VTX` - -### Lua Example -`local integerValue = gfx_get_vertex_count(cmd)` - -### Parameters -| Field | Type | -| ----- | ---- | -| cmd | `Pointer` <`Gfx`> | - -### Returns -- `integer` - -### C Prototype -`u16 gfx_get_vertex_count(Gfx *cmd);` - -[:arrow_up_small:](#) - -
- -## [gfx_get_texture](#gfx_get_texture) - -### Description -Gets the texture from a display list command if it has an image related op - -### Lua Example -`local pointerValue = gfx_get_texture(cmd)` - -### Parameters -| Field | Type | -| ----- | ---- | -| cmd | `Pointer` <`Gfx`> | - -### Returns -- `Pointer` <`Texture`> - -### C Prototype -`Texture *gfx_get_texture(Gfx *cmd);` - -[:arrow_up_small:](#) - -
- -## [gfx_get_from_name](#gfx_get_from_name) - -### Description -Gets a display list of the current mod from its name. Returns a pointer to the display list and its length - -### Lua Example -`local pointerValue, length = gfx_get_from_name(name)` - -### Parameters -| Field | Type | -| ----- | ---- | -| name | `string` | - -### Returns -- `Pointer` <`Gfx`> -- `integer` - -### C Prototype -`Gfx *gfx_get_from_name(const char *name, RET u32 *length);` - -[:arrow_up_small:](#) - -
- -## [gfx_get_name](#gfx_get_name) - -### Description -Gets the name of a display list - -### Lua Example -`local stringValue = gfx_get_name(gfx)` - -### Parameters -| Field | Type | -| ----- | ---- | -| gfx | `Pointer` <`Gfx`> | - -### Returns -- `string` - -### C Prototype -`const char *gfx_get_name(Gfx *gfx);` - -[:arrow_up_small:](#) - -
- -## [gfx_get_length](#gfx_get_length) - -### Description -Gets the max length of a display list - -### Lua Example -`local integerValue = gfx_get_length(gfx)` - -### Parameters -| Field | Type | -| ----- | ---- | -| gfx | `Pointer` <`Gfx`> | - -### Returns -- `integer` - -### C Prototype -`u32 gfx_get_length(Gfx *gfx);` - -[:arrow_up_small:](#) - -
- -## [gfx_get_command](#gfx_get_command) - -### Description -Gets a command of a display list at position `offset` - -### Lua Example -`local pointerValue = gfx_get_command(gfx, offset)` - -### Parameters -| Field | Type | -| ----- | ---- | -| gfx | `Pointer` <`Gfx`> | -| offset | `integer` | - -### Returns -- `Pointer` <`Gfx`> - -### C Prototype -`Gfx *gfx_get_command(Gfx *gfx, u32 offset);` - -[:arrow_up_small:](#) - -
- -## [gfx_get_next_command](#gfx_get_next_command) - -### Description -Gets the next command of a given display list pointer. Intended to use in a for loop - -### Lua Example -`local pointerValue = gfx_get_next_command(gfx)` - -### Parameters -| Field | Type | -| ----- | ---- | -| gfx | `Pointer` <`Gfx`> | - -### Returns -- `Pointer` <`Gfx`> - -### C Prototype -`Gfx *gfx_get_next_command(Gfx *gfx);` - -[:arrow_up_small:](#) - -
- -## [gfx_copy](#gfx_copy) - -### Description -Copies `length` commands from display list `src` to display list `dest` - -### Lua Example -`gfx_copy(dest, src, length)` - -### Parameters -| Field | Type | -| ----- | ---- | -| dest | `Pointer` <`Gfx`> | -| src | `Pointer` <`Gfx`> | -| length | `integer` | - -### Returns -- None - -### C Prototype -`void gfx_copy(Gfx *dest, Gfx *src, u32 length);` - -[:arrow_up_small:](#) - -
- -## [gfx_create](#gfx_create) - -### Description -Creates a new named display list of `length` commands - -### Lua Example -`local pointerValue = gfx_create(name, length)` - -### Parameters -| Field | Type | -| ----- | ---- | -| name | `string` | -| length | `integer` | - -### Returns -- `Pointer` <`Gfx`> - -### C Prototype -`Gfx *gfx_create(const char *name, u32 length);` - -[:arrow_up_small:](#) - -
- -## [gfx_resize](#gfx_resize) - -### Description -Resizes a display list created by `gfx_create` - -### Lua Example -`gfx_resize(gfx, newLength)` - -### Parameters -| Field | Type | -| ----- | ---- | -| gfx | `Pointer` <`Gfx`> | -| newLength | `integer` | - -### Returns -- None - -### C Prototype -`void gfx_resize(Gfx *gfx, u32 newLength);` - -[:arrow_up_small:](#) - -
- -## [gfx_delete](#gfx_delete) - -### Description -Deletes a display list created by `gfx_create` - -### Lua Example -`gfx_delete(gfx)` - -### Parameters -| Field | Type | -| ----- | ---- | -| gfx | `Pointer` <`Gfx`> | - -### Returns -- None - -### C Prototype -`void gfx_delete(Gfx *gfx);` - -[:arrow_up_small:](#) - -
- -## [gfx_delete_all](#gfx_delete_all) - -### Description -Deletes all display lists created by `gfx_create` - -### Lua Example -`gfx_delete_all()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void gfx_delete_all();` - -[:arrow_up_small:](#) - -
- -## [vtx_get_from_name](#vtx_get_from_name) - -### Description -Gets a vertex buffer of the current mod from its name. Returns a pointer to the vertex buffering and its vertex count - -### Lua Example -`local pointerValue, count = vtx_get_from_name(name)` - -### Parameters -| Field | Type | -| ----- | ---- | -| name | `string` | - -### Returns -- `Pointer` <`Vtx`> -- `integer` - -### C Prototype -`Vtx *vtx_get_from_name(const char *name, RET u32 *count);` - -[:arrow_up_small:](#) - -
- -## [vtx_get_name](#vtx_get_name) - -### Description -Gets the name of a vertex buffer - -### Lua Example -`local stringValue = vtx_get_name(vtx)` - -### Parameters -| Field | Type | -| ----- | ---- | -| vtx | `Pointer` <`Vtx`> | - -### Returns -- `string` - -### C Prototype -`const char *vtx_get_name(Vtx *vtx);` - -[:arrow_up_small:](#) - -
- -## [vtx_get_count](#vtx_get_count) - -### Description -Gets the max count of vertices of a vertex buffer - -### Lua Example -`local integerValue = vtx_get_count(vtx)` - -### Parameters -| Field | Type | -| ----- | ---- | -| vtx | `Pointer` <`Vtx`> | - -### Returns -- `integer` - -### C Prototype -`u32 vtx_get_count(Vtx *vtx);` - -[:arrow_up_small:](#) - -
- -## [vtx_get_vertex](#vtx_get_vertex) - -### Description -Gets a vertex of a vertex buffer at position `offset` - -### Lua Example -`local pointerValue = vtx_get_vertex(vtx, offset)` - -### Parameters -| Field | Type | -| ----- | ---- | -| vtx | `Pointer` <`Vtx`> | -| offset | `integer` | - -### Returns -- `Pointer` <`Vtx`> - -### C Prototype -`Vtx *vtx_get_vertex(Vtx *vtx, u32 offset);` - -[:arrow_up_small:](#) - -
- -## [vtx_get_next_vertex](#vtx_get_next_vertex) - -### Description -Gets the next vertex of a given vertex pointer. Intended to use in a for loop - -### Lua Example -`local pointerValue = vtx_get_next_vertex(vtx)` - -### Parameters -| Field | Type | -| ----- | ---- | -| vtx | `Pointer` <`Vtx`> | - -### Returns -- `Pointer` <`Vtx`> - -### C Prototype -`Vtx *vtx_get_next_vertex(Vtx *vtx);` - -[:arrow_up_small:](#) - -
- -## [vtx_copy](#vtx_copy) - -### Description -Copies `count` vertices from vertex buffer `src` to vertex buffer `dest` - -### Lua Example -`vtx_copy(dest, src, count)` - -### Parameters -| Field | Type | -| ----- | ---- | -| dest | `Pointer` <`Vtx`> | -| src | `Pointer` <`Vtx`> | -| count | `integer` | - -### Returns -- None - -### C Prototype -`void vtx_copy(Vtx *dest, Vtx *src, u32 count);` - -[:arrow_up_small:](#) - -
- -## [vtx_create](#vtx_create) - -### Description -Creates a new named vertex buffer of `count` vertices - -### Lua Example -`local pointerValue = vtx_create(name, count)` - -### Parameters -| Field | Type | -| ----- | ---- | -| name | `string` | -| count | `integer` | - -### Returns -- `Pointer` <`Vtx`> - -### C Prototype -`Vtx *vtx_create(const char *name, u32 count);` - -[:arrow_up_small:](#) - -
- -## [vtx_resize](#vtx_resize) - -### Description -Resizes a vertex buffer created by `vtx_create` - -### Lua Example -`vtx_resize(vtx, newCount)` - -### Parameters -| Field | Type | -| ----- | ---- | -| vtx | `Pointer` <`Vtx`> | -| newCount | `integer` | - -### Returns -- None - -### C Prototype -`void vtx_resize(Vtx *vtx, u32 newCount);` - -[:arrow_up_small:](#) - -
- -## [vtx_delete](#vtx_delete) - -### Description -Deletes a vertex buffer created by `vtx_create` - -### Lua Example -`vtx_delete(vtx)` - -### Parameters -| Field | Type | -| ----- | ---- | -| vtx | `Pointer` <`Vtx`> | - -### Returns -- None - -### C Prototype -`void vtx_delete(Vtx *vtx);` - -[:arrow_up_small:](#) - -
- -## [vtx_delete_all](#vtx_delete_all) - -### Description -Deletes all vertex buffers created by `vtx_create` - -### Lua Example -`vtx_delete_all()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void vtx_delete_all();` - -[:arrow_up_small:](#) - -
--- [< prev](functions-5.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | [5](functions-5.md) | 6 | [7](functions-7.md) | [next >](functions-7.md)] diff --git a/docs/lua/functions-7.md b/docs/lua/functions-7.md index 35b669390..23c515329 100644 --- a/docs/lua/functions-7.md +++ b/docs/lua/functions-7.md @@ -5,6 +5,1217 @@ [< prev](functions-6.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | [5](functions-5.md) | [6](functions-6.md) | 7] +--- +# functions from smlua_gfx_utils.h + +
+ + +## [get_shader_flag_enabled](#get_shader_flag_enabled) + +### Description +Gets if a custom shader flag (`SHADER_FLAG_*`) is enabled or not + +### Lua Example +`local booleanValue = get_shader_flag_enabled(flag)` + +### Parameters +| Field | Type | +| ----- | ---- | +| flag | [enum ShaderFlag](constants.md#enum-ShaderFlag) | + +### Returns +- `boolean` + +### C Prototype +`bool get_shader_flag_enabled(enum ShaderFlag flag);` + +[:arrow_up_small:](#) + +
+ +## [set_shader_flag_enabled](#set_shader_flag_enabled) + +### Description +Enables a custom shader flag (`SHADER_FLAG_*`) for the renderer + +### Lua Example +`set_shader_flag_enabled(flag, enabled)` + +### Parameters +| Field | Type | +| ----- | ---- | +| flag | [enum ShaderFlag](constants.md#enum-ShaderFlag) | +| enabled | `boolean` | + +### Returns +- None + +### C Prototype +`void set_shader_flag_enabled(enum ShaderFlag flag, bool enabled);` + +[:arrow_up_small:](#) + +
+ +## [get_shader_flag_value](#get_shader_flag_value) + +### Description +Gets a value for one of the custom shader flags (`SHADER_FLAG_*`) + +### Lua Example +`local numberValue = get_shader_flag_value(flag)` + +### Parameters +| Field | Type | +| ----- | ---- | +| flag | [enum ShaderFlag](constants.md#enum-ShaderFlag) | + +### Returns +- `number` + +### C Prototype +`f32 get_shader_flag_value(enum ShaderFlag flag);` + +[:arrow_up_small:](#) + +
+ +## [set_shader_flag_value](#set_shader_flag_value) + +### Description +Sets a value for one of the custom shader flags (`SHADER_FLAG_*`) for the renderer + +### Lua Example +`set_shader_flag_value(flag, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| flag | [enum ShaderFlag](constants.md#enum-ShaderFlag) | +| value | `number` | + +### Returns +- None + +### C Prototype +`void set_shader_flag_value(enum ShaderFlag flag, f32 value);` + +[:arrow_up_small:](#) + +
+ +## [get_global_shader_flags_enabled](#get_global_shader_flags_enabled) + +### Description +Gets if custom shader flags are enabled globally + +### Lua Example +`local booleanValue = get_global_shader_flags_enabled()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool get_global_shader_flags_enabled(void);` + +[:arrow_up_small:](#) + +
+ +## [set_global_shader_flags_enabled](#set_global_shader_flags_enabled) + +### Description +Enables custom shader flags as a global toggle, useful for disabling without manually going through every effect + +### Lua Example +`set_global_shader_flags_enabled(enabled)` + +### Parameters +| Field | Type | +| ----- | ---- | +| enabled | `boolean` | + +### Returns +- None + +### C Prototype +`void set_global_shader_flags_enabled(bool enabled);` + +[:arrow_up_small:](#) + +
+ +## [clear_all_shader_flags](#clear_all_shader_flags) + +### Description +Clears all custom shader flags (`SHADER_FLAG_*`) for the renderer + +### Lua Example +`clear_all_shader_flags()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void clear_all_shader_flags(void);` + +[:arrow_up_small:](#) + +
+ +## [set_override_fov](#set_override_fov) + +### Description +Sets the override FOV + +### Lua Example +`set_override_fov(fov)` + +### Parameters +| Field | Type | +| ----- | ---- | +| fov | `number` | + +### Returns +- None + +### C Prototype +`void set_override_fov(f32 fov);` + +[:arrow_up_small:](#) + +
+ +## [set_override_near](#set_override_near) + +### Description +Sets the override near plane + +### Lua Example +`set_override_near(near)` + +### Parameters +| Field | Type | +| ----- | ---- | +| near | `number` | + +### Returns +- None + +### C Prototype +`void set_override_near(f32 near);` + +[:arrow_up_small:](#) + +
+ +## [set_override_far](#set_override_far) + +### Description +Sets the override far plane + +### Lua Example +`set_override_far(far)` + +### Parameters +| Field | Type | +| ----- | ---- | +| far | `number` | + +### Returns +- None + +### C Prototype +`void set_override_far(f32 far);` + +[:arrow_up_small:](#) + +
+ +## [get_lighting_dir](#get_lighting_dir) + +### Description +Gets a value of the global lighting direction + +### Lua Example +`local numberValue = get_lighting_dir(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `number` + +### C Prototype +`f32 get_lighting_dir(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [set_lighting_dir](#set_lighting_dir) + +### Description +Sets a value of the global lighting direction + +### Lua Example +`set_lighting_dir(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `number` | + +### Returns +- None + +### C Prototype +`void set_lighting_dir(u8 index, f32 value);` + +[:arrow_up_small:](#) + +
+ +## [get_lighting_color](#get_lighting_color) + +### Description +Gets a value of the global lighting color + +### Lua Example +`local integerValue = get_lighting_color(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `integer` + +### C Prototype +`u8 get_lighting_color(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [get_lighting_color_ambient](#get_lighting_color_ambient) + +### Description +Gets a value of the global ambient lighting color + +### 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:](#) + +
+ +## [set_lighting_color](#set_lighting_color) + +### Description +Sets a value of the global lighting color + +### Lua Example +`set_lighting_color(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_lighting_color(u8 index, u8 value);` + +[:arrow_up_small:](#) + +
+ +## [set_lighting_color_ambient](#set_lighting_color_ambient) + +### Description +Sets a value of the global lighting color (run this after `set_lighting_color` for the ambient color to not be overriden) + +### 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:](#) + +
+ +## [get_vertex_color](#get_vertex_color) + +### Description +Gets a value of the global vertex shading color + +### Lua Example +`local integerValue = get_vertex_color(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `integer` + +### C Prototype +`u8 get_vertex_color(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [set_vertex_color](#set_vertex_color) + +### Description +Sets a value of the global vertex shading color + +### Lua Example +`set_vertex_color(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_vertex_color(u8 index, u8 value);` + +[:arrow_up_small:](#) + +
+ +## [get_fog_color](#get_fog_color) + +### Description +Gets a value of the global fog color + +### Lua Example +`local integerValue = get_fog_color(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `integer` + +### C Prototype +`u8 get_fog_color(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [set_fog_color](#set_fog_color) + +### Description +Sets a value of the global fog color + +### Lua Example +`set_fog_color(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_fog_color(u8 index, u8 value);` + +[:arrow_up_small:](#) + +
+ +## [get_fog_intensity](#get_fog_intensity) + +### Description +Gets the intensity of the fog + +### Lua Example +`local numberValue = get_fog_intensity()` + +### Parameters +- None + +### Returns +- `number` + +### C Prototype +`f32 get_fog_intensity(void);` + +[:arrow_up_small:](#) + +
+ +## [set_fog_intensity](#set_fog_intensity) + +### Description +Sets the intensity of the fog (this value scales very quickly, 1.0 to 1.1 is a desirable range) + +### Lua Example +`set_fog_intensity(intensity)` + +### Parameters +| Field | Type | +| ----- | ---- | +| intensity | `number` | + +### Returns +- None + +### C Prototype +`void set_fog_intensity(f32 intensity);` + +[:arrow_up_small:](#) + +
+ +## [get_skybox](#get_skybox) + +### Description +Gets the current skybox + +### Lua Example +`local integerValue = get_skybox()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s8 get_skybox(void);` + +[:arrow_up_small:](#) + +
+ +## [set_override_skybox](#set_override_skybox) + +### Description +Sets the override skybox + +### Lua Example +`set_override_skybox(background)` + +### Parameters +| Field | Type | +| ----- | ---- | +| background | `integer` | + +### Returns +- None + +### C Prototype +`void set_override_skybox(s8 background);` + +[:arrow_up_small:](#) + +
+ +## [get_skybox_color](#get_skybox_color) + +### Description +Gets a value of the global skybox color + +### Lua Example +`local integerValue = get_skybox_color(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `integer` + +### C Prototype +`u8 get_skybox_color(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [set_skybox_color](#set_skybox_color) + +### Description +Sets a value of the global skybox color + +### Lua Example +`set_skybox_color(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_skybox_color(u8 index, u8 value);` + +[:arrow_up_small:](#) + +
+ +## [gfx_parse](#gfx_parse) + +### Description +Traverses a display list. Takes a Lua function as a parameter, which is called back for each command in the display list with the parameters `cmd` (display list pointer), and `op` + +### Lua Example +`gfx_parse(cmd, func)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cmd | `Pointer` <`Gfx`> | +| func | `Lua Function` () | + +### Returns +- None + +### C Prototype +`void gfx_parse(Gfx *cmd, LuaFunction func);` + +[:arrow_up_small:](#) + +
+ +## [gfx_get_op](#gfx_get_op) + +### Description +Gets the op of the display list command + +### Lua Example +`local integerValue = gfx_get_op(cmd)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cmd | `Pointer` <`Gfx`> | + +### Returns +- `integer` + +### C Prototype +`u32 gfx_get_op(Gfx *cmd);` + +[:arrow_up_small:](#) + +
+ +## [gfx_get_display_list](#gfx_get_display_list) + +### Description +Gets the display list from a display list command if it has the op `G_DL` + +### Lua Example +`local pointerValue = gfx_get_display_list(cmd)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cmd | `Pointer` <`Gfx`> | + +### Returns +- `Pointer` <`Gfx`> + +### C Prototype +`Gfx *gfx_get_display_list(Gfx *cmd);` + +[:arrow_up_small:](#) + +
+ +## [gfx_get_vertex_buffer](#gfx_get_vertex_buffer) + +### Description +Gets the vertex buffer from a display list command if it has the op `G_VTX` + +### Lua Example +`local pointerValue = gfx_get_vertex_buffer(cmd)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cmd | `Pointer` <`Gfx`> | + +### Returns +- `Pointer` <`Vtx`> + +### C Prototype +`Vtx *gfx_get_vertex_buffer(Gfx *cmd);` + +[:arrow_up_small:](#) + +
+ +## [gfx_get_vertex_count](#gfx_get_vertex_count) + +### Description +Gets the number of vertices from a display list command if it has the op `G_VTX` + +### Lua Example +`local integerValue = gfx_get_vertex_count(cmd)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cmd | `Pointer` <`Gfx`> | + +### Returns +- `integer` + +### C Prototype +`u16 gfx_get_vertex_count(Gfx *cmd);` + +[:arrow_up_small:](#) + +
+ +## [gfx_get_texture](#gfx_get_texture) + +### Description +Gets the texture from a display list command if it has an image related op + +### Lua Example +`local pointerValue = gfx_get_texture(cmd)` + +### Parameters +| Field | Type | +| ----- | ---- | +| cmd | `Pointer` <`Gfx`> | + +### Returns +- `Pointer` <`Texture`> + +### C Prototype +`Texture *gfx_get_texture(Gfx *cmd);` + +[:arrow_up_small:](#) + +
+ +## [gfx_get_from_name](#gfx_get_from_name) + +### Description +Gets a display list of the current mod from its name. Returns a pointer to the display list and its length + +### Lua Example +`local pointerValue, length = gfx_get_from_name(name)` + +### Parameters +| Field | Type | +| ----- | ---- | +| name | `string` | + +### Returns +- `Pointer` <`Gfx`> +- `integer` + +### C Prototype +`Gfx *gfx_get_from_name(const char *name, RET u32 *length);` + +[:arrow_up_small:](#) + +
+ +## [gfx_get_name](#gfx_get_name) + +### Description +Gets the name of a display list + +### Lua Example +`local stringValue = gfx_get_name(gfx)` + +### Parameters +| Field | Type | +| ----- | ---- | +| gfx | `Pointer` <`Gfx`> | + +### Returns +- `string` + +### C Prototype +`const char *gfx_get_name(Gfx *gfx);` + +[:arrow_up_small:](#) + +
+ +## [gfx_get_length](#gfx_get_length) + +### Description +Gets the max length of a display list + +### Lua Example +`local integerValue = gfx_get_length(gfx)` + +### Parameters +| Field | Type | +| ----- | ---- | +| gfx | `Pointer` <`Gfx`> | + +### Returns +- `integer` + +### C Prototype +`u32 gfx_get_length(Gfx *gfx);` + +[:arrow_up_small:](#) + +
+ +## [gfx_get_command](#gfx_get_command) + +### Description +Gets a command of a display list at position `offset` + +### Lua Example +`local pointerValue = gfx_get_command(gfx, offset)` + +### Parameters +| Field | Type | +| ----- | ---- | +| gfx | `Pointer` <`Gfx`> | +| offset | `integer` | + +### Returns +- `Pointer` <`Gfx`> + +### C Prototype +`Gfx *gfx_get_command(Gfx *gfx, u32 offset);` + +[:arrow_up_small:](#) + +
+ +## [gfx_get_next_command](#gfx_get_next_command) + +### Description +Gets the next command of a given display list pointer. Intended to use in a for loop + +### Lua Example +`local pointerValue = gfx_get_next_command(gfx)` + +### Parameters +| Field | Type | +| ----- | ---- | +| gfx | `Pointer` <`Gfx`> | + +### Returns +- `Pointer` <`Gfx`> + +### C Prototype +`Gfx *gfx_get_next_command(Gfx *gfx);` + +[:arrow_up_small:](#) + +
+ +## [gfx_copy](#gfx_copy) + +### Description +Copies `length` commands from display list `src` to display list `dest` + +### Lua Example +`gfx_copy(dest, src, length)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dest | `Pointer` <`Gfx`> | +| src | `Pointer` <`Gfx`> | +| length | `integer` | + +### Returns +- None + +### C Prototype +`void gfx_copy(Gfx *dest, Gfx *src, u32 length);` + +[:arrow_up_small:](#) + +
+ +## [gfx_create](#gfx_create) + +### Description +Creates a new named display list of `length` commands + +### Lua Example +`local pointerValue = gfx_create(name, length)` + +### Parameters +| Field | Type | +| ----- | ---- | +| name | `string` | +| length | `integer` | + +### Returns +- `Pointer` <`Gfx`> + +### C Prototype +`Gfx *gfx_create(const char *name, u32 length);` + +[:arrow_up_small:](#) + +
+ +## [gfx_resize](#gfx_resize) + +### Description +Resizes a display list created by `gfx_create` + +### Lua Example +`gfx_resize(gfx, newLength)` + +### Parameters +| Field | Type | +| ----- | ---- | +| gfx | `Pointer` <`Gfx`> | +| newLength | `integer` | + +### Returns +- None + +### C Prototype +`void gfx_resize(Gfx *gfx, u32 newLength);` + +[:arrow_up_small:](#) + +
+ +## [gfx_delete](#gfx_delete) + +### Description +Deletes a display list created by `gfx_create` + +### Lua Example +`gfx_delete(gfx)` + +### Parameters +| Field | Type | +| ----- | ---- | +| gfx | `Pointer` <`Gfx`> | + +### Returns +- None + +### C Prototype +`void gfx_delete(Gfx *gfx);` + +[:arrow_up_small:](#) + +
+ +## [gfx_delete_all](#gfx_delete_all) + +### Description +Deletes all display lists created by `gfx_create` + +### Lua Example +`gfx_delete_all()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void gfx_delete_all();` + +[:arrow_up_small:](#) + +
+ +## [vtx_get_from_name](#vtx_get_from_name) + +### Description +Gets a vertex buffer of the current mod from its name. Returns a pointer to the vertex buffer and its vertex count + +### Lua Example +`local pointerValue, count = vtx_get_from_name(name)` + +### Parameters +| Field | Type | +| ----- | ---- | +| name | `string` | + +### Returns +- `Pointer` <`Vtx`> +- `integer` + +### C Prototype +`Vtx *vtx_get_from_name(const char *name, RET u32 *count);` + +[:arrow_up_small:](#) + +
+ +## [vtx_get_name](#vtx_get_name) + +### Description +Gets the name of a vertex buffer + +### Lua Example +`local stringValue = vtx_get_name(vtx)` + +### Parameters +| Field | Type | +| ----- | ---- | +| vtx | `Pointer` <`Vtx`> | + +### Returns +- `string` + +### C Prototype +`const char *vtx_get_name(Vtx *vtx);` + +[:arrow_up_small:](#) + +
+ +## [vtx_get_count](#vtx_get_count) + +### Description +Gets the max count of vertices of a vertex buffer + +### Lua Example +`local integerValue = vtx_get_count(vtx)` + +### Parameters +| Field | Type | +| ----- | ---- | +| vtx | `Pointer` <`Vtx`> | + +### Returns +- `integer` + +### C Prototype +`u32 vtx_get_count(Vtx *vtx);` + +[:arrow_up_small:](#) + +
+ +## [vtx_get_vertex](#vtx_get_vertex) + +### Description +Gets a vertex of a vertex buffer at position `offset` + +### Lua Example +`local pointerValue = vtx_get_vertex(vtx, offset)` + +### Parameters +| Field | Type | +| ----- | ---- | +| vtx | `Pointer` <`Vtx`> | +| offset | `integer` | + +### Returns +- `Pointer` <`Vtx`> + +### C Prototype +`Vtx *vtx_get_vertex(Vtx *vtx, u32 offset);` + +[:arrow_up_small:](#) + +
+ +## [vtx_get_next_vertex](#vtx_get_next_vertex) + +### Description +Gets the next vertex of a given vertex pointer. Intended to use in a for loop + +### Lua Example +`local pointerValue = vtx_get_next_vertex(vtx)` + +### Parameters +| Field | Type | +| ----- | ---- | +| vtx | `Pointer` <`Vtx`> | + +### Returns +- `Pointer` <`Vtx`> + +### C Prototype +`Vtx *vtx_get_next_vertex(Vtx *vtx);` + +[:arrow_up_small:](#) + +
+ +## [vtx_copy](#vtx_copy) + +### Description +Copies `count` vertices from vertex buffer `src` to vertex buffer `dest` + +### Lua Example +`vtx_copy(dest, src, count)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dest | `Pointer` <`Vtx`> | +| src | `Pointer` <`Vtx`> | +| count | `integer` | + +### Returns +- None + +### C Prototype +`void vtx_copy(Vtx *dest, Vtx *src, u32 count);` + +[:arrow_up_small:](#) + +
+ +## [vtx_create](#vtx_create) + +### Description +Creates a new named vertex buffer of `count` vertices + +### Lua Example +`local pointerValue = vtx_create(name, count)` + +### Parameters +| Field | Type | +| ----- | ---- | +| name | `string` | +| count | `integer` | + +### Returns +- `Pointer` <`Vtx`> + +### C Prototype +`Vtx *vtx_create(const char *name, u32 count);` + +[:arrow_up_small:](#) + +
+ +## [vtx_resize](#vtx_resize) + +### Description +Resizes a vertex buffer created by `vtx_create` + +### Lua Example +`vtx_resize(vtx, newCount)` + +### Parameters +| Field | Type | +| ----- | ---- | +| vtx | `Pointer` <`Vtx`> | +| newCount | `integer` | + +### Returns +- None + +### C Prototype +`void vtx_resize(Vtx *vtx, u32 newCount);` + +[:arrow_up_small:](#) + +
+ +## [vtx_delete](#vtx_delete) + +### Description +Deletes a vertex buffer created by `vtx_create` + +### Lua Example +`vtx_delete(vtx)` + +### Parameters +| Field | Type | +| ----- | ---- | +| vtx | `Pointer` <`Vtx`> | + +### Returns +- None + +### C Prototype +`void vtx_delete(Vtx *vtx);` + +[:arrow_up_small:](#) + +
+ +## [vtx_delete_all](#vtx_delete_all) + +### Description +Deletes all vertex buffers created by `vtx_create` + +### Lua Example +`vtx_delete_all()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void vtx_delete_all();` + +[:arrow_up_small:](#) + +
+ --- # functions from smlua_level_utils.h diff --git a/docs/lua/functions.md b/docs/lua/functions.md index fd2fb18b3..a286da56d 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1937,51 +1937,58 @@
- smlua_gfx_utils.h - - [set_override_fov](functions-6.md#set_override_fov) - - [set_override_near](functions-6.md#set_override_near) - - [set_override_far](functions-6.md#set_override_far) - - [get_lighting_dir](functions-6.md#get_lighting_dir) - - [set_lighting_dir](functions-6.md#set_lighting_dir) - - [get_lighting_color](functions-6.md#get_lighting_color) - - [get_lighting_color_ambient](functions-6.md#get_lighting_color_ambient) - - [set_lighting_color](functions-6.md#set_lighting_color) - - [set_lighting_color_ambient](functions-6.md#set_lighting_color_ambient) - - [get_vertex_color](functions-6.md#get_vertex_color) - - [set_vertex_color](functions-6.md#set_vertex_color) - - [get_fog_color](functions-6.md#get_fog_color) - - [set_fog_color](functions-6.md#set_fog_color) - - [get_fog_intensity](functions-6.md#get_fog_intensity) - - [set_fog_intensity](functions-6.md#set_fog_intensity) - - [get_skybox](functions-6.md#get_skybox) - - [set_override_skybox](functions-6.md#set_override_skybox) - - [get_skybox_color](functions-6.md#get_skybox_color) - - [set_skybox_color](functions-6.md#set_skybox_color) - - [gfx_parse](functions-6.md#gfx_parse) - - [gfx_get_op](functions-6.md#gfx_get_op) - - [gfx_get_display_list](functions-6.md#gfx_get_display_list) - - [gfx_get_vertex_buffer](functions-6.md#gfx_get_vertex_buffer) - - [gfx_get_vertex_count](functions-6.md#gfx_get_vertex_count) - - [gfx_get_texture](functions-6.md#gfx_get_texture) - - [gfx_get_from_name](functions-6.md#gfx_get_from_name) - - [gfx_get_name](functions-6.md#gfx_get_name) - - [gfx_get_length](functions-6.md#gfx_get_length) - - [gfx_get_command](functions-6.md#gfx_get_command) - - [gfx_get_next_command](functions-6.md#gfx_get_next_command) - - [gfx_copy](functions-6.md#gfx_copy) - - [gfx_create](functions-6.md#gfx_create) - - [gfx_resize](functions-6.md#gfx_resize) - - [gfx_delete](functions-6.md#gfx_delete) - - [gfx_delete_all](functions-6.md#gfx_delete_all) - - [vtx_get_from_name](functions-6.md#vtx_get_from_name) - - [vtx_get_name](functions-6.md#vtx_get_name) - - [vtx_get_count](functions-6.md#vtx_get_count) - - [vtx_get_vertex](functions-6.md#vtx_get_vertex) - - [vtx_get_next_vertex](functions-6.md#vtx_get_next_vertex) - - [vtx_copy](functions-6.md#vtx_copy) - - [vtx_create](functions-6.md#vtx_create) - - [vtx_resize](functions-6.md#vtx_resize) - - [vtx_delete](functions-6.md#vtx_delete) - - [vtx_delete_all](functions-6.md#vtx_delete_all) + - [get_shader_flag_enabled](functions-7.md#get_shader_flag_enabled) + - [set_shader_flag_enabled](functions-7.md#set_shader_flag_enabled) + - [get_shader_flag_value](functions-7.md#get_shader_flag_value) + - [set_shader_flag_value](functions-7.md#set_shader_flag_value) + - [get_global_shader_flags_enabled](functions-7.md#get_global_shader_flags_enabled) + - [set_global_shader_flags_enabled](functions-7.md#set_global_shader_flags_enabled) + - [clear_all_shader_flags](functions-7.md#clear_all_shader_flags) + - [set_override_fov](functions-7.md#set_override_fov) + - [set_override_near](functions-7.md#set_override_near) + - [set_override_far](functions-7.md#set_override_far) + - [get_lighting_dir](functions-7.md#get_lighting_dir) + - [set_lighting_dir](functions-7.md#set_lighting_dir) + - [get_lighting_color](functions-7.md#get_lighting_color) + - [get_lighting_color_ambient](functions-7.md#get_lighting_color_ambient) + - [set_lighting_color](functions-7.md#set_lighting_color) + - [set_lighting_color_ambient](functions-7.md#set_lighting_color_ambient) + - [get_vertex_color](functions-7.md#get_vertex_color) + - [set_vertex_color](functions-7.md#set_vertex_color) + - [get_fog_color](functions-7.md#get_fog_color) + - [set_fog_color](functions-7.md#set_fog_color) + - [get_fog_intensity](functions-7.md#get_fog_intensity) + - [set_fog_intensity](functions-7.md#set_fog_intensity) + - [get_skybox](functions-7.md#get_skybox) + - [set_override_skybox](functions-7.md#set_override_skybox) + - [get_skybox_color](functions-7.md#get_skybox_color) + - [set_skybox_color](functions-7.md#set_skybox_color) + - [gfx_parse](functions-7.md#gfx_parse) + - [gfx_get_op](functions-7.md#gfx_get_op) + - [gfx_get_display_list](functions-7.md#gfx_get_display_list) + - [gfx_get_vertex_buffer](functions-7.md#gfx_get_vertex_buffer) + - [gfx_get_vertex_count](functions-7.md#gfx_get_vertex_count) + - [gfx_get_texture](functions-7.md#gfx_get_texture) + - [gfx_get_from_name](functions-7.md#gfx_get_from_name) + - [gfx_get_name](functions-7.md#gfx_get_name) + - [gfx_get_length](functions-7.md#gfx_get_length) + - [gfx_get_command](functions-7.md#gfx_get_command) + - [gfx_get_next_command](functions-7.md#gfx_get_next_command) + - [gfx_copy](functions-7.md#gfx_copy) + - [gfx_create](functions-7.md#gfx_create) + - [gfx_resize](functions-7.md#gfx_resize) + - [gfx_delete](functions-7.md#gfx_delete) + - [gfx_delete_all](functions-7.md#gfx_delete_all) + - [vtx_get_from_name](functions-7.md#vtx_get_from_name) + - [vtx_get_name](functions-7.md#vtx_get_name) + - [vtx_get_count](functions-7.md#vtx_get_count) + - [vtx_get_vertex](functions-7.md#vtx_get_vertex) + - [vtx_get_next_vertex](functions-7.md#vtx_get_next_vertex) + - [vtx_copy](functions-7.md#vtx_copy) + - [vtx_create](functions-7.md#vtx_create) + - [vtx_resize](functions-7.md#vtx_resize) + - [vtx_delete](functions-7.md#vtx_delete) + - [vtx_delete_all](functions-7.md#vtx_delete_all)
diff --git a/levels/bbh/areas/1/10/model.inc.c b/levels/bbh/areas/1/10/model.inc.c index 784955fce..790aec55e 100644 --- a/levels/bbh/areas/1/10/model.inc.c +++ b/levels/bbh/areas/1/10/model.inc.c @@ -19,26 +19,26 @@ static const Gfx bbh_seg7_dl_0700B8A8[] = { gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, spooky_09006800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_0700B488, 15, 0), + gsSPVertex(bbh_seg7_vertex_0700B488, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 3, 1, 0x0), gsSP2Triangles( 4, 5, 6, 0x0, 7, 8, 9, 0x0), gsSP2Triangles( 5, 10, 11, 0x0, 5, 1, 10, 0x0), gsSP1Triangle(12, 13, 14, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_0700B578, 16, 0), + gsSPVertex(bbh_seg7_vertex_0700B578, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 6, 4, 0x0, 7, 8, 9, 0x0), gsSP2Triangles( 7, 4, 8, 0x0, 10, 11, 12, 0x0), gsSP2Triangles(10, 13, 11, 0x0, 14, 13, 15, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_0700B678, 15, 0), + gsSPVertex(bbh_seg7_vertex_0700B678, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 6, 7, 8, 0x0, 9, 10, 11, 0x0), gsSP1Triangle(12, 13, 14, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_0700B768, 14, 0), + gsSPVertex(bbh_seg7_vertex_0700B768, 14, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 3, 1, 0x0), gsSP2Triangles( 4, 1, 5, 0x0, 4, 5, 6, 0x0), gsSP2Triangles( 7, 8, 9, 0x0, 7, 10, 8, 0x0), gsSP2Triangles(11, 10, 12, 0x0, 11, 13, 10, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_0700B848, 6, 0), + gsSPVertex(bbh_seg7_vertex_0700B848, 6, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSPEndDisplayList(), }; @@ -46,7 +46,7 @@ static const Gfx bbh_seg7_dl_0700B8A8[] = { // 0x0700B9E0 - 0x0700BA50 const Gfx bbh_seg7_dl_0700B9E0[] = { gsDPPipeSync(), - gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), + gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA), gsSPClearGeometryMode(G_LIGHTING), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), diff --git a/levels/bbh/areas/1/11/model.inc.c b/levels/bbh/areas/1/11/model.inc.c index cef6ca89b..6d18c0a91 100644 --- a/levels/bbh/areas/1/11/model.inc.c +++ b/levels/bbh/areas/1/11/model.inc.c @@ -7,7 +7,7 @@ static const Gfx bbh_seg7_dl_0700BB50[] = { gsDPSetTextureImage(G_IM_FMT_IA, G_IM_SIZ_16b, 1, spooky_0900B000), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_0700BA50, 16, 0), + gsSPVertex(bbh_seg7_vertex_0700BA50, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 5, 6, 0x0, 7, 4, 3, 0x0), gsSP2Triangles( 7, 8, 4, 0x0, 6, 5, 9, 0x0), diff --git a/levels/bbh/areas/1/15/model.inc.c b/levels/bbh/areas/1/15/model.inc.c index 8c94e203e..80436ebfe 100644 --- a/levels/bbh/areas/1/15/model.inc.c +++ b/levels/bbh/areas/1/15/model.inc.c @@ -10,14 +10,14 @@ static const Gfx bbh_seg7_dl_0700D6F0[] = { gsDPSetTextureImage(G_IM_FMT_IA, G_IM_SIZ_16b, 1, spooky_0900B000), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_0700D500, 16, 0), + gsSPVertex(bbh_seg7_vertex_0700D500, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 6, 4, 0x0, 7, 6, 3, 0x0), gsSP2Triangles( 7, 8, 6, 0x0, 5, 4, 9, 0x0), gsSP2Triangles( 5, 9, 10, 0x0, 10, 9, 8, 0x0), gsSP2Triangles(10, 8, 7, 0x0, 11, 1, 0, 0x0), gsSP2Triangles( 0, 2, 12, 0x0, 13, 14, 15, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_0700D600, 15, 0), + gsSPVertex(bbh_seg7_vertex_0700D600, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 5, 6, 0x0, 6, 5, 1, 0x0), gsSP2Triangles( 6, 1, 0, 0x0, 7, 8, 9, 0x0), diff --git a/levels/bbh/areas/1/21/model.inc.c b/levels/bbh/areas/1/21/model.inc.c index bfe47aecd..36937e234 100644 --- a/levels/bbh/areas/1/21/model.inc.c +++ b/levels/bbh/areas/1/21/model.inc.c @@ -7,7 +7,7 @@ static const Gfx bbh_seg7_dl_07012680[] = { gsDPSetTextureImage(G_IM_FMT_IA, G_IM_SIZ_16b, 1, spooky_0900B000), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_07012580, 16, 0), + gsSPVertex(bbh_seg7_vertex_07012580, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 5, 6, 0x0, 7, 8, 9, 0x0), gsSP2Triangles( 7, 9, 10, 0x0, 11, 12, 13, 0x0), diff --git a/levels/bbh/areas/1/27/model.inc.c b/levels/bbh/areas/1/27/model.inc.c index 070bd23ee..bf339ffb5 100644 --- a/levels/bbh/areas/1/27/model.inc.c +++ b/levels/bbh/areas/1/27/model.inc.c @@ -10,14 +10,14 @@ static const Gfx bbh_seg7_dl_07015930[] = { gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, spooky_09006800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_07015750, 15, 0), + gsSPVertex(bbh_seg7_vertex_07015750, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 1, 3, 2, 0x0), gsSP2Triangles( 3, 4, 2, 0x0, 4, 0, 2, 0x0), gsSP2Triangles( 5, 6, 7, 0x0, 8, 5, 7, 0x0), gsSP2Triangles( 6, 9, 7, 0x0, 9, 8, 7, 0x0), gsSP2Triangles(10, 11, 12, 0x0, 11, 13, 12, 0x0), gsSP2Triangles(13, 14, 12, 0x0, 14, 10, 12, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07015840, 15, 0), + gsSPVertex(bbh_seg7_vertex_07015840, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 1, 3, 2, 0x0), gsSP2Triangles( 3, 4, 2, 0x0, 4, 0, 2, 0x0), gsSP2Triangles( 5, 6, 7, 0x0, 8, 5, 7, 0x0), @@ -30,7 +30,7 @@ static const Gfx bbh_seg7_dl_07015930[] = { // 0x07015A20 - 0x07015A90 const Gfx bbh_seg7_dl_07015A20[] = { gsDPPipeSync(), - gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), + gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA), gsSPClearGeometryMode(G_LIGHTING), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), diff --git a/levels/bbh/areas/1/30/model.inc.c b/levels/bbh/areas/1/30/model.inc.c index 6497e3efe..291ca900b 100644 --- a/levels/bbh/areas/1/30/model.inc.c +++ b/levels/bbh/areas/1/30/model.inc.c @@ -7,7 +7,7 @@ static const Gfx bbh_seg7_dl_070176E0[] = { gsDPSetTextureImage(G_IM_FMT_IA, G_IM_SIZ_16b, 1, spooky_0900B000), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_070175E0, 16, 0), + gsSPVertex(bbh_seg7_vertex_070175E0, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 5, 6, 0x0, 7, 4, 3, 0x0), gsSP2Triangles( 7, 8, 4, 0x0, 6, 5, 9, 0x0), diff --git a/levels/bbh/areas/1/38/model.inc.c b/levels/bbh/areas/1/38/model.inc.c index 0790886e0..d6f7097d6 100644 --- a/levels/bbh/areas/1/38/model.inc.c +++ b/levels/bbh/areas/1/38/model.inc.c @@ -21,7 +21,7 @@ static const Gfx bbh_seg7_dl_0701EE90[] = { gsDPSetTextureImage(G_IM_FMT_IA, G_IM_SIZ_16b, 1, spooky_0900B800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_0701EE08, 4, 0), + gsSPVertex(bbh_seg7_vertex_0701EE08, 4, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPEndDisplayList(), }; diff --git a/levels/bbh/areas/1/39/model.inc.c b/levels/bbh/areas/1/39/model.inc.c index 91f6a0b4b..ca10a0111 100644 --- a/levels/bbh/areas/1/39/model.inc.c +++ b/levels/bbh/areas/1/39/model.inc.c @@ -7,7 +7,7 @@ static const Gfx bbh_seg7_dl_0701F018[] = { gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, spooky_09006800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_0701EF58, 12, 0), + gsSPVertex(bbh_seg7_vertex_0701EF58, 12, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 3, 1, 0x0), gsSP2Triangles( 4, 3, 5, 0x0, 4, 6, 3, 0x0), gsSP2Triangles( 7, 8, 9, 0x0, 10, 5, 11, 0x0), @@ -17,7 +17,7 @@ static const Gfx bbh_seg7_dl_0701F018[] = { // 0x0701F070 - 0x0701F0E0 const Gfx bbh_seg7_dl_0701F070[] = { gsDPPipeSync(), - gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), + gsDPSetCombineMode(G_CC_DECALRGB, G_CC_DECALRGB), gsSPClearGeometryMode(G_LIGHTING), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), diff --git a/levels/bbh/areas/1/4/model.inc.c b/levels/bbh/areas/1/4/model.inc.c index f42d54f8e..89a8f615d 100644 --- a/levels/bbh/areas/1/4/model.inc.c +++ b/levels/bbh/areas/1/4/model.inc.c @@ -13,17 +13,17 @@ static const Gfx bbh_seg7_dl_07007EE8[] = { gsDPSetTextureImage(G_IM_FMT_IA, G_IM_SIZ_16b, 1, spooky_0900B800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_07007C08, 15, 0), + gsSPVertex(bbh_seg7_vertex_07007C08, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 6, 4, 0x0, 7, 8, 9, 0x0), gsSP2Triangles( 7, 10, 8, 0x0, 11, 12, 13, 0x0), gsSP1Triangle(11, 13, 14, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07007CF8, 15, 0), + gsSPVertex(bbh_seg7_vertex_07007CF8, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 6, 7, 8, 0x0, 6, 9, 7, 0x0), gsSP2Triangles(10, 11, 12, 0x0, 10, 13, 11, 0x0), gsSP1Triangle( 0, 2, 14, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07007DE8, 16, 0), + gsSPVertex(bbh_seg7_vertex_07007DE8, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 6, 4, 0x0, 7, 8, 9, 0x0), gsSP2Triangles( 7, 9, 10, 0x0, 11, 12, 13, 0x0), diff --git a/levels/bbh/areas/1/5/model.inc.c b/levels/bbh/areas/1/5/model.inc.c index efa80a882..89e97f0dd 100644 --- a/levels/bbh/areas/1/5/model.inc.c +++ b/levels/bbh/areas/1/5/model.inc.c @@ -31,45 +31,45 @@ static const Gfx bbh_seg7_dl_070088E0[] = { gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, spooky_09006800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008040, 16, 0), + gsSPVertex(bbh_seg7_vertex_07008040, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSP2Triangles( 4, 5, 6, 0x0, 7, 0, 8, 0x0), gsSP2Triangles( 9, 1, 10, 0x0, 9, 11, 1, 0x0), gsSP2Triangles(12, 13, 14, 0x0, 12, 15, 13, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008140, 16, 0), + gsSPVertex(bbh_seg7_vertex_07008140, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 1, 6, 7, 0x0, 1, 7, 8, 0x0), gsSP2Triangles( 9, 10, 11, 0x0, 9, 11, 12, 0x0), gsSP2Triangles(13, 14, 10, 0x0, 13, 10, 15, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008240, 15, 0), + gsSPVertex(bbh_seg7_vertex_07008240, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 6, 7, 8, 0x0, 6, 8, 9, 0x0), gsSP2Triangles(10, 11, 12, 0x0, 13, 6, 14, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008330, 16, 0), + gsSPVertex(bbh_seg7_vertex_07008330, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 3, 1, 0x0), gsSP2Triangles( 4, 5, 6, 0x0, 7, 8, 9, 0x0), gsSP2Triangles( 5, 10, 11, 0x0, 5, 11, 12, 0x0), gsSP2Triangles(13, 14, 10, 0x0, 13, 10, 15, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008430, 16, 0), + gsSPVertex(bbh_seg7_vertex_07008430, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSP2Triangles( 4, 5, 6, 0x0, 7, 8, 9, 0x0), gsSP2Triangles( 5, 2, 10, 0x0, 5, 10, 11, 0x0), gsSP2Triangles(12, 13, 14, 0x0, 12, 14, 15, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008530, 15, 0), + gsSPVertex(bbh_seg7_vertex_07008530, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSP2Triangles( 4, 5, 6, 0x0, 7, 0, 8, 0x0), gsSP2Triangles( 9, 10, 11, 0x0, 12, 13, 14, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008620, 16, 0), + gsSPVertex(bbh_seg7_vertex_07008620, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSP2Triangles( 4, 2, 5, 0x0, 4, 5, 6, 0x0), gsSP2Triangles( 7, 8, 9, 0x0, 7, 9, 10, 0x0), gsSP2Triangles(11, 12, 13, 0x0, 14, 10, 15, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008720, 16, 0), + gsSPVertex(bbh_seg7_vertex_07008720, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSP2Triangles( 4, 5, 6, 0x0, 7, 8, 9, 0x0), gsSP2Triangles(10, 11, 5, 0x0, 10, 12, 11, 0x0), gsSP2Triangles(13, 14, 15, 0x0, 13, 11, 14, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008820, 12, 0), + gsSPVertex(bbh_seg7_vertex_07008820, 12, 0), gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSP2Triangles( 4, 5, 6, 0x0, 7, 3, 8, 0x0), gsSP2Triangles( 9, 2, 10, 0x0, 9, 10, 11, 0x0), @@ -79,7 +79,7 @@ static const Gfx bbh_seg7_dl_070088E0[] = { // 0x07008B58 - 0x07008BC8 const Gfx bbh_seg7_dl_07008B58[] = { gsDPPipeSync(), - gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB), + gsDPSetCombineMode(G_CC_DECALRGB, G_CC_DECALRGB), gsSPClearGeometryMode(G_LIGHTING), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), diff --git a/levels/bbh/areas/1/6/model.inc.c b/levels/bbh/areas/1/6/model.inc.c index dd1776f26..e21e328e6 100644 --- a/levels/bbh/areas/1/6/model.inc.c +++ b/levels/bbh/areas/1/6/model.inc.c @@ -10,14 +10,14 @@ static const Gfx bbh_seg7_dl_07008DB8[] = { gsDPSetTextureImage(G_IM_FMT_IA, G_IM_SIZ_16b, 1, spooky_0900B000), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008BC8, 16, 0), + gsSPVertex(bbh_seg7_vertex_07008BC8, 16, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 6, 4, 0x0, 7, 6, 3, 0x0), gsSP2Triangles( 7, 8, 6, 0x0, 5, 4, 9, 0x0), gsSP2Triangles( 5, 9, 10, 0x0, 10, 9, 8, 0x0), gsSP2Triangles(10, 8, 7, 0x0, 11, 1, 0, 0x0), gsSP2Triangles( 0, 2, 12, 0x0, 13, 14, 15, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_07008CC8, 15, 0), + gsSPVertex(bbh_seg7_vertex_07008CC8, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 5, 6, 0x0, 6, 5, 1, 0x0), gsSP2Triangles( 6, 1, 0, 0x0, 7, 8, 9, 0x0), diff --git a/levels/bbh/areas/1/9/model.inc.c b/levels/bbh/areas/1/9/model.inc.c index 8bd745ab7..576ace3f8 100644 --- a/levels/bbh/areas/1/9/model.inc.c +++ b/levels/bbh/areas/1/9/model.inc.c @@ -10,12 +10,12 @@ static const Gfx bbh_seg7_dl_0700B398[] = { gsDPSetTextureImage(G_IM_FMT_IA, G_IM_SIZ_16b, 1, spooky_0900B800), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)), - gsSPVertexNonGlobal(bbh_seg7_vertex_0700B238, 15, 0), + gsSPVertex(bbh_seg7_vertex_0700B238, 15, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP2Triangles( 3, 5, 6, 0x0, 7, 8, 9, 0x0), gsSP2Triangles( 7, 9, 10, 0x0, 11, 12, 13, 0x0), gsSP1Triangle(11, 14, 12, 0x0), - gsSPVertexNonGlobal(bbh_seg7_vertex_0700B328, 7, 0), + gsSPVertex(bbh_seg7_vertex_0700B328, 7, 0), gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0), gsSP1Triangle( 0, 6, 1, 0x0), gsSPEndDisplayList(), diff --git a/src/game/hud.c b/src/game/hud.c index 245edd56b..1e1641348 100644 --- a/src/game/hud.c +++ b/src/game/hud.c @@ -325,7 +325,7 @@ void render_hud_icon(Vtx *vtx, const Texture *texture, u32 fmt, u32 siz, s32 tex case G_IM_SIZ_16b: gDPLoadTextureBlock(gDisplayListHead++, texture, fmt, G_IM_SIZ_16b, texW, texH, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); break; case G_IM_SIZ_32b: gDPLoadTextureBlock(gDisplayListHead++, texture, fmt, G_IM_SIZ_32b, texW, texH, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); break; } - gSPVertex(gDisplayListHead++, vtx, 4, 0); + gSPVertexNonGlobal(gDisplayListHead++, vtx, 4, 0); gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0x0, 0, 2, 3, 0x0); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF); gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); diff --git a/src/game/skybox.c b/src/game/skybox.c index 424c58ab1..d3c156095 100644 --- a/src/game/skybox.c +++ b/src/game/skybox.c @@ -191,7 +191,7 @@ f32 calculate_skybox_scaled_y(s8 player, UNUSED f32 fov) { * into an x and y by modulus and division by SKYBOX_COLS. x and y are then scaled by * SKYBOX_TILE_WIDTH to get a point in world space. */ -Vtx *make_skybox_rect(s32 tileRow, s32 tileCol, s8 colorIndex, s32 row, s32 col) { +Vtx *make_skybox_rect(s32 tileRow, s32 tileCol, s32 row, s32 col) { u16 index = row * sSkyboxTileNumX + col; Vtx *verts; if (gRenderingInterpolated) { @@ -205,14 +205,10 @@ Vtx *make_skybox_rect(s32 tileRow, s32 tileCol, s8 colorIndex, s32 row, s32 col) f32 y = SKYBOX_HEIGHT - tileRow / SKYBOX_COLS * SKYBOX_TILE_HEIGHT; if (verts != NULL) { - f32 r = gSkyboxColor[0] / 255.0f; - f32 g = gSkyboxColor[1] / 255.0f; - f32 b = gSkyboxColor[2] / 255.0f; - u8 *colors = sSkyboxColors[colorIndex]; - make_vertex(verts, 0, x, y, -1, 0, 0, colors[0] * r, colors[1] * g, colors[2] * b, 255); - make_vertex(verts, 1, x, y - SKYBOX_TILE_HEIGHT, -1, 0, 31 << 5, colors[0] * r, colors[1] * g, colors[2] * b, 255); - make_vertex(verts, 2, x + SKYBOX_TILE_WIDTH, y - SKYBOX_TILE_HEIGHT, -1, 31 << 5, 31 << 5, colors[0] * r, colors[1] * g, colors[2] * b, 255); - make_vertex(verts, 3, x + SKYBOX_TILE_WIDTH, y, -1, 31 << 5, 0, colors[0] * r, colors[1] * g, colors[2] * b, 255); + make_vertex(verts, 0, x, y, -1, 0, 0, 255, 255, 255, 255); + make_vertex(verts, 1, x, y - SKYBOX_TILE_HEIGHT, -1, 0, 31 << 5, 255, 255, 255, 255); + make_vertex(verts, 2, x + SKYBOX_TILE_WIDTH, y - SKYBOX_TILE_HEIGHT, -1, 31 << 5, 31 << 5, 255, 255, 255, 255); + make_vertex(verts, 3, x + SKYBOX_TILE_WIDTH, y, -1, 31 << 5, 0, 255, 255, 255, 255); } return verts; } @@ -246,10 +242,16 @@ void draw_skybox_tile_grid(Gfx **dlist, s8 background, s8 player, s8 colorIndex) texture = (*(SkyboxTexture *) segmented_to_virtual(sSkyboxTextures[background]))[tileIndex]; } - Vtx *vertices = make_skybox_rect(tileRow, tileColTmp, colorIndex, row, col); + f32 r = gSkyboxColor[0] / 255.0f; + f32 g = gSkyboxColor[1] / 255.0f; + f32 b = gSkyboxColor[2] / 255.0f; + u8 *color = sSkyboxColors[colorIndex]; + gDPSetEnvColor((*dlist)++, color[0] * r, color[1] * g, color[2] * b, 255); + + Vtx *vertices = make_skybox_rect(tileRow, tileColTmp, row, col); gLoadBlockTexture((*dlist)++, 32, 32, G_IM_FMT_RGBA, texture); - gSPVertexNonGlobal((*dlist)++, VIRTUAL_TO_PHYSICAL(vertices), 4, 0); + gSPVertex((*dlist)++, VIRTUAL_TO_PHYSICAL(vertices), 4, 0); gSPDisplayList((*dlist)++, dl_draw_quad_verts_0123); } } @@ -284,7 +286,7 @@ void *create_skybox_ortho_matrix(s8 player) { Gfx *init_skybox_display_list(s8 player, s8 background, s8 colorIndex) { extern Gfx* gBackgroundSkyboxGfx; - s32 dlCommandCount = 5 + (sSkyboxTileNumY * sSkyboxTileNumX) * 7; // 5 for the start and end, plus the amount of skybox tiles + s32 dlCommandCount = 5 + (sSkyboxTileNumY * sSkyboxTileNumX) * 8; // 5 for the start and end, plus the amount of skybox tiles void *skybox; if (gRenderingInterpolated) { diff --git a/src/pc/gfx/gfx.h b/src/pc/gfx/gfx.h index 34e735b01..a2c21a70f 100644 --- a/src/pc/gfx/gfx.h +++ b/src/pc/gfx/gfx.h @@ -46,6 +46,7 @@ struct GfxVertex { struct RGBA color; uint8_t fog_z; uint8_t clip_rej; + uint8_t world_geometry; }; struct GfxDimensions { diff --git a/src/pc/gfx/gfx_cc.h b/src/pc/gfx/gfx_cc.h index 336a237b5..30ebe45cb 100644 --- a/src/pc/gfx/gfx_cc.h +++ b/src/pc/gfx/gfx_cc.h @@ -72,12 +72,13 @@ struct CombineMode { }; union { struct { - uint8_t use_alpha : 1; - uint8_t use_fog : 1; - uint8_t texture_edge : 1; - uint8_t use_dither : 1; - uint8_t use_2cycle : 1; - uint8_t light_map : 1; + uint8_t use_alpha : 1; + uint8_t use_fog : 1; + uint8_t texture_edge : 1; + uint8_t use_dither : 1; + uint8_t use_2cycle : 1; + uint8_t light_map : 1; + uint8_t world_geometry : 1; }; uint32_t flags; }; diff --git a/src/pc/gfx/gfx_opengl.c b/src/pc/gfx/gfx_opengl.c index 8544dedd8..3a803ede7 100644 --- a/src/pc/gfx/gfx_opengl.c +++ b/src/pc/gfx/gfx_opengl.c @@ -41,11 +41,12 @@ struct ShaderProgram { bool used_textures[2]; uint8_t num_floats; GLint attrib_locations[7]; - GLint uniform_locations[7]; + GLint uniform_locations[9]; uint8_t attrib_sizes[7]; uint8_t num_attribs; bool used_noise; bool used_lightmap; + bool world_geometry; }; struct GLTexture { @@ -88,7 +89,12 @@ static void gfx_opengl_vertex_array_set_attribs(struct ShaderProgram *prg) { static inline void gfx_opengl_set_shader_uniforms(struct ShaderProgram *prg) { if (prg->used_noise) { glUniform1f(prg->uniform_locations[4], (float)frame_count); } if (prg->used_lightmap) { glUniform3f(prg->uniform_locations[5], gVertexColor[0] / 255.0f, gVertexColor[1] / 255.0f, gVertexColor[2] / 255.0f); } - glUniform1i(prg->uniform_locations[6], configFiltering); + if (prg->world_geometry) { + glUniform1iv(prg->uniform_locations[6], SHADER_FLAG_MAX, gShaderFlags); + glUniform1fv(prg->uniform_locations[7], SHADER_FLAG_MAX, gShaderFlagValues); + } + + glUniform1i(prg->uniform_locations[8], configFiltering); } static inline void gfx_opengl_set_texture_uniforms(struct ShaderProgram *prg, const int tile) { @@ -245,6 +251,7 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC bool opt_texture_edge = cc->cm.texture_edge; bool opt_2cycle = cc->cm.use_2cycle; bool opt_light_map = cc->cm.light_map; + bool world_geometry = cc->cm.world_geometry; #ifdef USE_GLES bool opt_dither = false; @@ -252,8 +259,8 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC bool opt_dither = cc->cm.use_dither; #endif - char vs_buf[1024]; - char fs_buf[2048]; + char vs_buf[8192]; + char fs_buf[8192]; size_t vs_len = 0; size_t fs_len = 0; size_t num_floats = 4; @@ -357,6 +364,56 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC append_line(fs_buf, &fs_len, "}"); } + if (world_geometry) { + append_line(fs_buf, &fs_len, "float dither4x4(vec2 position, float brightness) {"); + append_line(fs_buf, &fs_len, " int x = int(mod(position.x, 4.0));"); + append_line(fs_buf, &fs_len, " int y = int(mod(position.y, 4.0));"); + append_line(fs_buf, &fs_len, " int index = x + y * 4;"); + append_line(fs_buf, &fs_len, " float limit = 0.0;"); + append_line(fs_buf, &fs_len, " if (x < 8) {"); + append_line(fs_buf, &fs_len, " if (index == 0) limit = 0.0625;"); + append_line(fs_buf, &fs_len, " if (index == 1) limit = 0.5625;"); + append_line(fs_buf, &fs_len, " if (index == 2) limit = 0.1875;"); + append_line(fs_buf, &fs_len, " if (index == 3) limit = 0.6875;"); + append_line(fs_buf, &fs_len, " if (index == 4) limit = 0.8125;"); + append_line(fs_buf, &fs_len, " if (index == 5) limit = 0.3125;"); + append_line(fs_buf, &fs_len, " if (index == 6) limit = 0.9375;"); + append_line(fs_buf, &fs_len, " if (index == 7) limit = 0.4375;"); + append_line(fs_buf, &fs_len, " if (index == 8) limit = 0.25;"); + append_line(fs_buf, &fs_len, " if (index == 9) limit = 0.75;"); + append_line(fs_buf, &fs_len, " if (index == 10) limit = 0.125;"); + append_line(fs_buf, &fs_len, " if (index == 11) limit = 0.625;"); + append_line(fs_buf, &fs_len, " if (index == 12) limit = 1.0;"); + append_line(fs_buf, &fs_len, " if (index == 13) limit = 0.5;"); + append_line(fs_buf, &fs_len, " if (index == 14) limit = 0.875;"); + append_line(fs_buf, &fs_len, " if (index == 15) limit = 0.375;"); + append_line(fs_buf, &fs_len, " }"); + append_line(fs_buf, &fs_len, " return brightness < limit ? 0.0 : 1.0;"); + append_line(fs_buf, &fs_len, "}"); + + append_line(fs_buf, &fs_len, "vec3 rgb2hsv(vec3 c) {"); + append_line(fs_buf, &fs_len, " vec4 K = vec4(0.0, -1.0/3.0, 2.0/3.0, -1.0);"); + append_line(fs_buf, &fs_len, " vec4 p = mix(vec4(c.bg, K.wz),"); + append_line(fs_buf, &fs_len, " vec4(c.gb, K.xy),"); + append_line(fs_buf, &fs_len, " step(c.b, c.g));"); + append_line(fs_buf, &fs_len, " vec4 q = mix(vec4(p.xyw, c.r),"); + append_line(fs_buf, &fs_len, " vec4(c.r, p.yzx),"); + append_line(fs_buf, &fs_len, " step(p.x, c.r));"); + append_line(fs_buf, &fs_len, " float d = q.x - min(q.w, q.y);"); + append_line(fs_buf, &fs_len, " float e = 1.0e-10;"); + append_line(fs_buf, &fs_len, " return vec3("); + append_line(fs_buf, &fs_len, " abs(q.z + (q.w - q.y) / (6.0 * d + e)), // hue"); + append_line(fs_buf, &fs_len, " d / (q.x + e), // saturation"); + append_line(fs_buf, &fs_len, " q.x // value"); + append_line(fs_buf, &fs_len, " );"); + append_line(fs_buf, &fs_len, "}"); + append_line(fs_buf, &fs_len, ""); + append_line(fs_buf, &fs_len, "vec3 hsv2rgb(vec3 c) {"); + append_line(fs_buf, &fs_len, " vec3 p = abs(fract(c.xxx + vec3(0.0, 2.0/3.0, 1.0/3.0)) * 6.0 - 3.0);"); + append_line(fs_buf, &fs_len, " return c.z * mix(vec3(1.0), clamp(p - 1.0, 0.0, 1.0), c.y);"); + append_line(fs_buf, &fs_len, "}"); + } + if ((opt_alpha && opt_dither) || ccf.do_noise) { append_line(fs_buf, &fs_len, "uniform float uFrameCount;"); @@ -370,6 +427,11 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC append_line(fs_buf, &fs_len, "uniform vec3 uLightmapColor;"); } + if (world_geometry) { + fs_len += sprintf(fs_buf + fs_len, "uniform int uShaderFlags[%d];\n", SHADER_FLAG_MAX); + fs_len += sprintf(fs_buf + fs_len, "uniform float uShaderFlagValues[%d];\n", SHADER_FLAG_MAX); + } + append_line(fs_buf, &fs_len, "uniform int uFilter;"); append_line(fs_buf, &fs_len, "void main() {"); @@ -416,6 +478,55 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC // TODO discard if alpha is 0? + if (world_geometry) { + // hue + append_line(fs_buf, &fs_len, "if (uShaderFlags[0] == 1) {"); + append_line(fs_buf, &fs_len, "vec3 hsv = rgb2hsv(texel.rgb);"); + append_line(fs_buf, &fs_len, "hsv.x = fract(hsv.x + uShaderFlagValues[0]);"); + append_line(fs_buf, &fs_len, "vec3 finalColor = hsv2rgb(hsv);"); + append_line(fs_buf, &fs_len, "texel.rgb = finalColor;"); + append_line(fs_buf, &fs_len, "}"); + + // saturation + append_line(fs_buf, &fs_len, "if (uShaderFlags[1] == 1) {"); + append_line(fs_buf, &fs_len, "const vec3 w = vec3(0.2125, 0.7154, 0.0721);"); + append_line(fs_buf, &fs_len, "vec3 intensity = vec3(dot(texel.rgb, w));"); + append_line(fs_buf, &fs_len, "texel.rgb = mix(intensity, texel.rgb, uShaderFlagValues[1]);"); + append_line(fs_buf, &fs_len, "}"); + + // brightness + append_line(fs_buf, &fs_len, "if (uShaderFlags[2] == 1) {"); + append_line(fs_buf, &fs_len, "texel.rgb *= uShaderFlagValues[2];"); + append_line(fs_buf, &fs_len, "}"); + + // contrast + append_line(fs_buf, &fs_len, "if (uShaderFlags[3] == 1) {"); + append_line(fs_buf, &fs_len, "texel.rgb = 0.5 + uShaderFlagValues[3] * (texel.rgb - 0.5);"); + append_line(fs_buf, &fs_len, "}"); + + // exposure + append_line(fs_buf, &fs_len, "if (uShaderFlags[4] == 1) {"); + append_line(fs_buf, &fs_len, "texel.rgb = texel.rgb + (uShaderFlagValues[4] - 2) * texel.rgb + texel.rgb;"); + append_line(fs_buf, &fs_len, "}"); + + // dithering + append_line(fs_buf, &fs_len, "if (uShaderFlags[5] == 1) {"); + append_line(fs_buf, &fs_len, "texel.rgb *= dither4x4(gl_FragCoord.xy, dot(texel.rgb, vec3(0.299, 0.587, 0.114)));"); + append_line(fs_buf, &fs_len, "}"); + + // posterization + append_line(fs_buf, &fs_len, "if (uShaderFlags[6] == 1) {"); + append_line(fs_buf, &fs_len, "int levels = int(max(1.0, uShaderFlagValues[6]));"); + append_line(fs_buf, &fs_len, "texel.rgb = floor(texel.rgb * levels) / levels;"); + append_line(fs_buf, &fs_len, "}"); + + // scan lines + append_line(fs_buf, &fs_len, "if (uShaderFlags[7] == 1) {"); + append_line(fs_buf, &fs_len, "float scan = sin(gl_FragCoord.y * 1.5) * 0.04;"); + append_line(fs_buf, &fs_len, "texel.rgb -= scan * uShaderFlagValues[7];"); + append_line(fs_buf, &fs_len, "}"); + } + if (opt_fog) { if (opt_alpha) { append_line(fs_buf, &fs_len, "texel = vec4(mix(texel.rgb, vFog.rgb, vFog.a), texel.a);"); @@ -558,7 +669,15 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC prg->used_lightmap = false; } - prg->uniform_locations[6] = glGetUniformLocation(shader_program, "uFilter"); + if (world_geometry) { + prg->uniform_locations[6] = glGetUniformLocation(shader_program, "uShaderFlags"); + prg->uniform_locations[7] = glGetUniformLocation(shader_program, "uShaderFlagValues"); + prg->world_geometry = true; + } else { + prg->world_geometry = false; + } + + prg->uniform_locations[8] = glGetUniformLocation(shader_program, "uFilter"); return prg; } diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index fd8045361..70e011f76 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -129,6 +129,20 @@ Color gVertexColor = { 0xFF, 0xFF, 0xFF }; Color gFogColor = { 0xFF, 0xFF, 0xFF }; f32 gFogIntensity = 1; +int gShaderFlags[SHADER_FLAG_MAX] = { 0 }; +f32 gDefaultShaderFlagValues[SHADER_FLAG_MAX] = { + [SHADER_FLAG_HUE] = 0.0f, + [SHADER_FLAG_SATURATION] = 1.0f, + [SHADER_FLAG_BRIGHTNESS] = 1.0f, + [SHADER_FLAG_CONTRAST] = 1.0f, + [SHADER_FLAG_EXPOSURE] = 1.0f, + [SHADER_FLAG_DITHERING] = 0.0f, + [SHADER_FLAG_POSTERIZATION] = 8.0f, + [SHADER_FLAG_SCANLINES] = 1.0f +}; +f32 gShaderFlagValues[SHADER_FLAG_MAX] = { 0 }; +bool gShaderFlagsEnabled = true; + // need inverse camera matrix to compute world space for lighting engine static Mat4 sInverseCameraMatrix; static bool sHasInverseCameraMatrix = false; @@ -1015,6 +1029,8 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons if (!(rsp.geometry_mode & G_FRESNEL_ALPHA_EXT)) { d->color.a = v->cn[3]; } + + d->world_geometry = luaVertexColor; } } @@ -1103,12 +1119,13 @@ static void OPTIMIZE_O3 gfx_sp_tri1(uint8_t vtx1_idx, uint8_t vtx2_idx, uint8_t struct CombineMode* cm = &rdp.combine_mode; - cm->use_alpha = (rdp.other_mode_l & (G_BL_A_MEM << 18)) == 0; - cm->texture_edge = (rdp.other_mode_l & CVG_X_ALPHA) == CVG_X_ALPHA; - cm->use_dither = (rdp.other_mode_l & G_AC_DITHER) == G_AC_DITHER; - cm->use_2cycle = (rdp.other_mode_h & (3U << G_MDSFT_CYCLETYPE)) == G_CYC_2CYCLE; - cm->use_fog = (rdp.other_mode_l >> 30) == G_BL_CLR_FOG; - cm->light_map = (rsp.geometry_mode & G_LIGHT_MAP_EXT) == G_LIGHT_MAP_EXT; + cm->use_alpha = (rdp.other_mode_l & (G_BL_A_MEM << 18)) == 0; + cm->texture_edge = (rdp.other_mode_l & CVG_X_ALPHA) == CVG_X_ALPHA; + cm->use_dither = (rdp.other_mode_l & G_AC_DITHER) == G_AC_DITHER; + cm->use_2cycle = (rdp.other_mode_h & (3U << G_MDSFT_CYCLETYPE)) == G_CYC_2CYCLE; + cm->use_fog = (rdp.other_mode_l >> 30) == G_BL_CLR_FOG; + cm->light_map = (rsp.geometry_mode & G_LIGHT_MAP_EXT) == G_LIGHT_MAP_EXT; + cm->world_geometry = gShaderFlagsEnabled && (v1->world_geometry && v2->world_geometry && v3->world_geometry); if (cm->texture_edge) { cm->use_alpha = true; diff --git a/src/pc/gfx/gfx_pc.h b/src/pc/gfx/gfx_pc.h index 97fdca0cc..b4a970822 100644 --- a/src/pc/gfx/gfx_pc.h +++ b/src/pc/gfx/gfx_pc.h @@ -4,6 +4,18 @@ #include "types.h" #include "pc/gfx/gfx.h" +enum ShaderFlag { + SHADER_FLAG_HUE, + SHADER_FLAG_SATURATION, + SHADER_FLAG_BRIGHTNESS, + SHADER_FLAG_CONTRAST, + SHADER_FLAG_EXPOSURE, + SHADER_FLAG_DITHERING, + SHADER_FLAG_POSTERIZATION, + SHADER_FLAG_SCANLINES, + SHADER_FLAG_MAX +}; + struct GfxRenderingAPI; struct GfxWindowManagerAPI; @@ -13,6 +25,11 @@ extern Color gVertexColor; extern Color gFogColor; extern f32 gFogIntensity; +extern int gShaderFlags[SHADER_FLAG_MAX]; +extern f32 gDefaultShaderFlagValues[SHADER_FLAG_MAX]; +extern f32 gShaderFlagValues[SHADER_FLAG_MAX]; +extern bool gShaderFlagsEnabled; + #ifdef __cplusplus extern "C" { #endif diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 88096aebd..1549a78f8 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -1596,6 +1596,15 @@ char gSmluaConstants[] = "" "BACKGROUND_ABOVE_CLOUDS=8\n" "BACKGROUND_PURPLE_SKY=9\n" "BACKGROUND_CUSTOM=10\n" +"SHADER_FLAG_HUE=0\n" +"SHADER_FLAG_SATURATION=1\n" +"SHADER_FLAG_BRIGHTNESS=2\n" +"SHADER_FLAG_CONTRAST=3\n" +"SHADER_FLAG_EXPOSURE=4\n" +"SHADER_FLAG_DITHERING=5\n" +"SHADER_FLAG_POSTERIZATION=6\n" +"SHADER_FLAG_SCANLINES=7\n" +"SHADER_FLAG_MAX=8\n" "GRAPH_RENDER_ACTIVE=(1 << 0)\n" "GRAPH_RENDER_CHILDREN_FIRST=(1 << 1)\n" "GRAPH_RENDER_BILLBOARD=(1 << 2)\n" diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index d5d8acca7..86c6d90df 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -32124,6 +32124,125 @@ int smlua_func_network_player_palette_to_color(lua_State* L) { // smlua_gfx_utils.h // /////////////////////// +int smlua_func_get_shader_flag_enabled(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_shader_flag_enabled", 1, top); + return 0; + } + + int flag = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_shader_flag_enabled"); return 0; } + + lua_pushboolean(L, get_shader_flag_enabled(flag)); + + return 1; +} + +int smlua_func_set_shader_flag_enabled(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_shader_flag_enabled", 2, top); + return 0; + } + + int flag = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_shader_flag_enabled"); return 0; } + bool enabled = smlua_to_boolean(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_shader_flag_enabled"); return 0; } + + set_shader_flag_enabled(flag, enabled); + + return 1; +} + +int smlua_func_get_shader_flag_value(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_shader_flag_value", 1, top); + return 0; + } + + int flag = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_shader_flag_value"); return 0; } + + lua_pushnumber(L, get_shader_flag_value(flag)); + + return 1; +} + +int smlua_func_set_shader_flag_value(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_shader_flag_value", 2, top); + return 0; + } + + int flag = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_shader_flag_value"); return 0; } + f32 value = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_shader_flag_value"); return 0; } + + set_shader_flag_value(flag, value); + + return 1; +} + +int smlua_func_get_global_shader_flags_enabled(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_global_shader_flags_enabled", 0, top); + return 0; + } + + + lua_pushboolean(L, get_global_shader_flags_enabled()); + + return 1; +} + +int smlua_func_set_global_shader_flags_enabled(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_global_shader_flags_enabled", 1, top); + return 0; + } + + bool enabled = smlua_to_boolean(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_global_shader_flags_enabled"); return 0; } + + set_global_shader_flags_enabled(enabled); + + return 1; +} + +int smlua_func_clear_all_shader_flags(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", "clear_all_shader_flags", 0, top); + return 0; + } + + + clear_all_shader_flags(); + + return 1; +} + int smlua_func_set_override_fov(lua_State* L) { if (L == NULL) { return 0; } @@ -38802,6 +38921,13 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "network_player_palette_to_color", smlua_func_network_player_palette_to_color); // smlua_gfx_utils.h + smlua_bind_function(L, "get_shader_flag_enabled", smlua_func_get_shader_flag_enabled); + smlua_bind_function(L, "set_shader_flag_enabled", smlua_func_set_shader_flag_enabled); + smlua_bind_function(L, "get_shader_flag_value", smlua_func_get_shader_flag_value); + smlua_bind_function(L, "set_shader_flag_value", smlua_func_set_shader_flag_value); + smlua_bind_function(L, "get_global_shader_flags_enabled", smlua_func_get_global_shader_flags_enabled); + smlua_bind_function(L, "set_global_shader_flags_enabled", smlua_func_set_global_shader_flags_enabled); + smlua_bind_function(L, "clear_all_shader_flags", smlua_func_clear_all_shader_flags); smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov); smlua_bind_function(L, "set_override_near", smlua_func_set_override_near); smlua_bind_function(L, "set_override_far", smlua_func_set_override_far); diff --git a/src/pc/lua/utils/smlua_gfx_utils.c b/src/pc/lua/utils/smlua_gfx_utils.c index 78a3679b1..19833e9e4 100644 --- a/src/pc/lua/utils/smlua_gfx_utils.c +++ b/src/pc/lua/utils/smlua_gfx_utils.c @@ -1,9 +1,45 @@ #include "smlua_gfx_utils.h" -#include "pc/gfx/gfx_pc.h" +#include "pc/pc_main.h" #include "game/rendering_graph_node.h" #include "game/skybox.h" #include "geo_commands.h" +bool get_shader_flag_enabled(enum ShaderFlag flag) { + if (flag < 0 || flag >= SHADER_FLAG_MAX) { return false; } + return gShaderFlags[flag]; +} + +void set_shader_flag_enabled(enum ShaderFlag flag, bool enabled) { + if (flag < 0 || flag >= SHADER_FLAG_MAX) { return; } + gShaderFlags[flag] = enabled ? 1 : 0; +} + +f32 get_shader_flag_value(enum ShaderFlag flag) { + if (flag < 0 || flag >= SHADER_FLAG_MAX) { return 0.0f; } + return gShaderFlagValues[flag]; +} + +void set_shader_flag_value(enum ShaderFlag flag, f32 value) { + if (flag < 0 || flag >= SHADER_FLAG_MAX) { return; } + gShaderFlagValues[flag] = value; +} + +bool get_global_shader_flags_enabled(void) { + return gShaderFlagsEnabled; +} + +void set_global_shader_flags_enabled(bool enabled) { + gShaderFlagsEnabled = enabled; +} + +AT_STARTUP void clear_all_shader_flags(void) { + gShaderFlagsEnabled = true; + memset(gShaderFlags, 0, sizeof(s32) * SHADER_FLAG_MAX); + memcpy(gShaderFlagValues, gDefaultShaderFlagValues, sizeof(f32) * SHADER_FLAG_MAX); +} + +/// + void set_override_fov(f32 fov) { gOverrideFOV = fov; } diff --git a/src/pc/lua/utils/smlua_gfx_utils.h b/src/pc/lua/utils/smlua_gfx_utils.h index d49ebed34..8dbca45a1 100644 --- a/src/pc/lua/utils/smlua_gfx_utils.h +++ b/src/pc/lua/utils/smlua_gfx_utils.h @@ -1,6 +1,7 @@ #ifndef SMLUA_GFX_UTILS_H #define SMLUA_GFX_UTILS_H +#include "pc/gfx/gfx_pc.h" #include "pc/lua/smlua.h" #include "types.h" #include "geo_commands.h" @@ -12,6 +13,21 @@ Gfx *gfx_allocate_internal(Gfx *gfx, u32 length); Vtx *vtx_allocate_internal(Vtx *vtx, u32 count); u32 gfx_get_length_no_sentinel(const Gfx *gfx); +/* |description|Gets if a custom shader flag (`SHADER_FLAG_*`) is enabled or not|descriptionEnd| */ +bool get_shader_flag_enabled(enum ShaderFlag flag); +/* |description|Enables a custom shader flag (`SHADER_FLAG_*`) for the renderer|descriptionEnd| */ +void set_shader_flag_enabled(enum ShaderFlag flag, bool enabled); +/* |description|Gets a value for one of the custom shader flags (`SHADER_FLAG_*`)|descriptionEnd| */ +f32 get_shader_flag_value(enum ShaderFlag flag); +/* |description|Sets a value for one of the custom shader flags (`SHADER_FLAG_*`) for the renderer|descriptionEnd| */ +void set_shader_flag_value(enum ShaderFlag flag, f32 value); +/* |description|Gets if custom shader flags are enabled globally|descriptionEnd| */ +bool get_global_shader_flags_enabled(void); +/* |description|Enables custom shader flags as a global toggle, useful for disabling without manually going through every effect|descriptionEnd| */ +void set_global_shader_flags_enabled(bool enabled); +/* |description|Clears all custom shader flags (`SHADER_FLAG_*`) for the renderer|descriptionEnd| */ +void clear_all_shader_flags(void); + /* |description|Sets the override FOV|descriptionEnd| */ void set_override_fov(f32 fov); /* |description|Sets the override near plane|descriptionEnd| */ @@ -96,7 +112,7 @@ void gfx_delete_all(); /* |description| Gets a vertex buffer of the current mod from its name. -Returns a pointer to the vertex buffering and its vertex count +Returns a pointer to the vertex buffer and its vertex count |descriptionEnd| */ Vtx *vtx_get_from_name(const char *name, RET u32 *count); /* |description|Gets the name of a vertex buffer|descriptionEnd| */ diff --git a/src/pc/network/network.c b/src/pc/network/network.c index ff5ce1d5e..559eba8b2 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -16,6 +16,7 @@ #include "pc/lua/utils/smlua_model_utils.h" #include "pc/lua/utils/smlua_misc_utils.h" #include "pc/lua/utils/smlua_camera_utils.h" +#include "pc/lua/utils/smlua_gfx_utils.h" #include "pc/mods/mods.h" #include "pc/crash_handler.h" #include "pc/debuglog.h" @@ -36,7 +37,7 @@ #include "game/mario.h" #include "engine/math_util.h" #include "engine/lighting_engine.h" -#include "src/audio/load.h" +#include "audio/load.h" #ifdef DISCORD_SDK #include "pc/discord/discord.h" @@ -723,6 +724,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect color_set(gSkyboxColor, 0xFF, 0xFF, 0xFF); color_set(gFogColor, 0xFF, 0xFF, 0xFF); gFogIntensity = 1.0f; + clear_all_shader_flags(); gOverrideBackground = -1; gOverrideEnvFx = ENVFX_MODE_NO_OVERRIDE; gRomhackCameraSettings.centering = FALSE;