This commit is contained in:
offtkp 2024-07-20 00:09:12 +03:00
parent ce4146f9ba
commit 75f839509e
3 changed files with 21 additions and 33 deletions

View file

@ -73,18 +73,7 @@ namespace PICA {
BitField<22, 2, u32> shadowSelector;
};
LightingLUTConfig d0{};
LightingLUTConfig d1{};
LightingLUTConfig sp{};
LightingLUTConfig fr{};
LightingLUTConfig rr{};
LightingLUTConfig rg{};
LightingLUTConfig rb{};
u32 config1;
u32 lutAbs;
u32 lutScale;
u32 lutSelect;
LightingLUTConfig luts[7]{};
std::array<Light, 8> lights{};
@ -95,13 +84,9 @@ namespace PICA {
}
const u32 config0 = regs[InternalRegs::LightConfig0];
const u32 config1 = regs[InternalRegs::LightConfig1];
const u32 totalLightCount = Helpers::getBits<0, 3>(regs[InternalRegs::LightNumber]) + 1;
config1 = regs[InternalRegs::LightConfig1];
lutAbs = regs[InternalRegs::LightLUTAbs];
lutScale = regs[InternalRegs::LightLUTScale];
lutSelect = regs[InternalRegs::LightLUTSelect];
enable = 1;
lightNum = totalLightCount;
@ -138,6 +123,14 @@ namespace PICA {
light.distanceAttenuationEnable = ((config1 >> (24 + i)) & 1) ^ 1; // Of course same here
}
LightingLUTConfig& d0 = luts[Lights::LUT_D0];
LightingLUTConfig& d1 = luts[Lights::LUT_D1];
LightingLUTConfig& sp = luts[spotlightLutIndex];
LightingLUTConfig& fr = luts[Lights::LUT_FR];
LightingLUTConfig& rb = luts[Lights::LUT_RB];
LightingLUTConfig& rg = luts[Lights::LUT_RG];
LightingLUTConfig& rr = luts[Lights::LUT_RR];
d0.enable = Helpers::getBit<16>(config1) == 0;
d1.enable = Helpers::getBit<17>(config1) == 0;
fr.enable = Helpers::getBit<19>(config1) == 0;

View file

@ -278,6 +278,11 @@ namespace PICA {
};
}
// There's actually 8 different LUTs (SP0-SP7), one for each light with different indices (8-15)
// We use an unused LUT value for "this light source's spotlight" instead and figure out which light source to use in compileLutLookup
// This is particularly intuitive in several places, such as checking if a LUT is enabled
static constexpr int spotlightLutIndex = 2;
enum class TextureFmt : u32 {
RGBA8 = 0x0,
RGB8 = 0x1,