Fix small bug with LE inside graphics vertex function

I also brought back the lighting profiler because it's better than nothing.
This commit is contained in:
Agent X 2026-01-24 19:01:30 -05:00
parent f37908e131
commit 2e8f2ef360
3 changed files with 11 additions and 1 deletions

View file

@ -20,6 +20,7 @@ enum DebugContext {
CTX_RENDER,
CTX_LEVEL_SCRIPT,
CTX_HOOK,
CTX_LIGHTING,
CTX_MAX,
// MUST BE KEPT IN SYNC WITH sDebugContextNames
};

View file

@ -17,6 +17,7 @@ static char* sDebugContextNames[] = {
"RENDER",
"LEVEL",
"HOOK",
"LIGHTING",
"OTHER",
"MAX",
};

View file

@ -892,17 +892,21 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons
}
// if lighting engine is enabled and either we want to affect all shaded surfaces or the lighting engine geometry mode is on
if (le_is_enabled() && ((le_get_mode() != LE_MODE_AFFECT_ONLY_GEOMETRY_MODE) || (rsp.geometry_mode & G_LIGHTING_ENGINE_EXT))) {
if (le_is_enabled() && luaVertexColor && ((le_get_mode() != LE_MODE_AFFECT_ONLY_GEOMETRY_MODE) || (rsp.geometry_mode & G_LIGHTING_ENGINE_EXT))) {
Color color = { gLEAmbientColor[0], gLEAmbientColor[1], gLEAmbientColor[2] };
Vec3f vpos = { v->ob[0], v->ob[1], v->ob[2] };
Vec3f vnormal = { nx, ny, nz };
CTX_BEGIN(CTX_LIGHTING);
// transform vpos and vnormal to world space
gfx_local_to_world_space(vpos, vnormal);
le_calculate_lighting_color_with_normal(vpos, vnormal, color, 1.0f);
CTX_END(CTX_LIGHTING);
d->color.r *= color[0] / 255.0f;
d->color.g *= color[1] / 255.0f;
d->color.b *= color[2] / 255.0f;
@ -913,6 +917,8 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons
Vec3f vpos = { v->ob[0], v->ob[1], v->ob[2] };
CTX_BEGIN(CTX_LIGHTING);
// transform vpos to world space
gfx_local_to_world_space(vpos, NULL);
@ -926,6 +932,8 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons
le_calculate_vertex_lighting((Vtx_t*)v, vpos, color);
}
CTX_END(CTX_LIGHTING);
// combine the colors
if (affectAllVertexColored && !(rsp.geometry_mode & G_LIGHTING_ENGINE_EXT)) {
d->color.r = (v->cn[0] * color[0] / 255.0f) * vertexColorCached[0];