From 3fdefb7ea51062ba704ce5613be7521b53d139d9 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Sun, 3 Mar 2024 15:24:08 -0500 Subject: [PATCH] Fix: Setting per pixel lighting from graphics menu --- src/frontend.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/frontend.cpp b/src/frontend.cpp index a0dda42d935..a8ed1ee5b4f 100644 --- a/src/frontend.cpp +++ b/src/frontend.cpp @@ -1300,8 +1300,22 @@ bool runGraphicsOptionsMenu() case FRONTEND_LIGHTS: case FRONTEND_LIGHTS_R: { - war_setPointLightPerPixelLighting(!war_getPointLightPerPixelLighting()); - widgSetString(psWScreen, FRONTEND_LIGHTS_R, graphicsOptionsLightingString()); + bool newValue = !war_getPointLightPerPixelLighting(); + if (getTerrainShaderQuality() != TerrainShaderQuality::NORMAL_MAPPING) + { + newValue = false; // point light per pixel lighting is only supported in normal_mapping mode + } + auto shadowConstants = gfx_api::context::get().getShadowConstants(); + shadowConstants.isPointLightPerPixelEnabled = newValue; + if (gfx_api::context::get().setShadowConstants(shadowConstants)) + { + war_setPointLightPerPixelLighting(newValue); + widgSetString(psWScreen, FRONTEND_LIGHTS_R, graphicsOptionsLightingString()); + } + else + { + debug(LOG_ERROR, "Failed to set per pixel point lighting value: %d", (int)newValue); + } break; } case FRONTEND_FOG: