mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-12 09:09:47 +12:00
Nyom
This commit is contained in:
parent
ce4146f9ba
commit
75f839509e
3 changed files with 21 additions and 33 deletions
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "PICA/pica_frag_config.hpp"
|
||||
#include "PICA/regs.hpp"
|
||||
#include "PICA/shader_gen.hpp"
|
||||
using namespace PICA;
|
||||
|
@ -30,11 +31,6 @@ static constexpr const char* uniformDefinition = R"(
|
|||
};
|
||||
)";
|
||||
|
||||
// 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;
|
||||
|
||||
std::string FragmentGenerator::getDefaultVertexShader() {
|
||||
std::string ret = "";
|
||||
|
||||
|
@ -613,22 +609,16 @@ void FragmentGenerator::compileLUTLookup(std::string& shader, const PICA::Fragme
|
|||
}
|
||||
|
||||
const bool samplerEnabled = isSamplerEnabled(config.lighting.config, lutID);
|
||||
const u32 config1 = config.lighting.config1;
|
||||
const LightingLUTConfig& lut = config.lighting.luts[lutID];
|
||||
|
||||
if (!samplerEnabled || ((config1 >> bitInConfig1) & 1)) {
|
||||
if (!samplerEnabled || !lut.enable) {
|
||||
shader += "lut_lookup_result = 1.0;\n";
|
||||
return;
|
||||
}
|
||||
|
||||
static constexpr float scales[] = {1.0f, 2.0f, 4.0f, 8.0f, 0.0f, 0.0f, 0.25f, 0.5f};
|
||||
const u32 lutAbs = config.lighting.lutAbs;
|
||||
const u32 lutSelect = config.lighting.lutSelect;
|
||||
const u32 lutScale = config.lighting.lutScale;
|
||||
|
||||
// The way these bitfields are encoded is so cursed
|
||||
float scale = scales[(lutScale >> (4 * lutID)) & 0x7];
|
||||
uint inputID = (lutSelect >> (4 * lutID)) & 0x7;
|
||||
bool absEnabled = ((lutAbs >> (4 * lutID + 1)) & 0x1) == 0; // 0 = enabled...
|
||||
float scale = lut.scale;
|
||||
uint inputID = lut.type;
|
||||
bool absEnabled = lut.absInput;
|
||||
|
||||
switch (inputID) {
|
||||
case 0: shader += "lut_lookup_delta = dot(normal, normalize(half_vector));\n"; break;
|
||||
|
|
Loading…
Add table
Reference in a new issue