Skip to content

Commit

Permalink
Shadergen: Fix small register decoding oopsie
Browse files Browse the repository at this point in the history
  • Loading branch information
wheremyfoodat committed Jul 19, 2024
1 parent 2509808 commit ac55c3e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/PICA/pica_frag_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions include/PICA/regs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ namespace PICA {
Light0Z = 0x145,
Light0SpotlightXY = 0x146,
Light0SpotlightZ = 0x147,
Light0Config = 0x149,
Light0AttenuationBias = 0x14A,
Light0AttenuationScale = 0x14B,

Expand Down
4 changes: 2 additions & 2 deletions src/core/PICA/shader_gen_glsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"(
Expand Down

0 comments on commit ac55c3e

Please sign in to comment.