From ac55c3e3249603e4a77dc2bd7dc97f372dad6f78 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Fri, 19 Jul 2024 03:01:12 +0300 Subject: [PATCH] Shadergen: Fix small register decoding oopsie --- include/PICA/pica_frag_config.hpp | 2 +- include/PICA/regs.hpp | 1 + src/core/PICA/shader_gen_glsl.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/PICA/pica_frag_config.hpp b/include/PICA/pica_frag_config.hpp index cdb688545..5338f7194 100644 --- a/include/PICA/pica_frag_config.hpp +++ b/include/PICA/pica_frag_config.hpp @@ -116,7 +116,7 @@ namespace PICA { for (int i = 0; i < totalLightCount; i++) { auto& light = lights[i]; - const u32 lightConfig = 0x149 + 0x10 * i; + const u32 lightConfig = regs[InternalRegs::Light0Config + 0x10 * i]; light.num = (regs[InternalRegs::LightPermutation] >> (i * 4)) & 0x7; light.directional = Helpers::getBit<0>(lightConfig); diff --git a/include/PICA/regs.hpp b/include/PICA/regs.hpp index 2482c25b4..4518e16a3 100644 --- a/include/PICA/regs.hpp +++ b/include/PICA/regs.hpp @@ -77,6 +77,7 @@ namespace PICA { Light0Z = 0x145, Light0SpotlightXY = 0x146, Light0SpotlightZ = 0x147, + Light0Config = 0x149, Light0AttenuationBias = 0x14A, Light0AttenuationScale = 0x14B, diff --git a/src/core/PICA/shader_gen_glsl.cpp b/src/core/PICA/shader_gen_glsl.cpp index 21b553385..a892e514c 100644 --- a/src/core/PICA/shader_gen_glsl.cpp +++ b/src/core/PICA/shader_gen_glsl.cpp @@ -485,9 +485,9 @@ void FragmentGenerator::compileLights(std::string& shader, const PICA::FragmentC shader += "light_position = lightSources[" + std::to_string(lightID) + "].position;\n"; if (lightConfig.directional) { // Directional lighting - shader += "light_vector = light_position + v_view;\n"; - } else { // Positional lighting shader += "light_vector = light_position;\n"; + } else { // Positional lighting + shader += "light_vector = light_position + v_view;\n"; } shader += R"(