mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-06 23:32:59 +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;
|
BitField<22, 2, u32> shadowSelector;
|
||||||
};
|
};
|
||||||
|
|
||||||
LightingLUTConfig d0{};
|
LightingLUTConfig luts[7]{};
|
||||||
LightingLUTConfig d1{};
|
|
||||||
LightingLUTConfig sp{};
|
|
||||||
LightingLUTConfig fr{};
|
|
||||||
LightingLUTConfig rr{};
|
|
||||||
LightingLUTConfig rg{};
|
|
||||||
LightingLUTConfig rb{};
|
|
||||||
|
|
||||||
u32 config1;
|
|
||||||
u32 lutAbs;
|
|
||||||
u32 lutScale;
|
|
||||||
u32 lutSelect;
|
|
||||||
|
|
||||||
std::array<Light, 8> lights{};
|
std::array<Light, 8> lights{};
|
||||||
|
|
||||||
|
@ -95,13 +84,9 @@ namespace PICA {
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 config0 = regs[InternalRegs::LightConfig0];
|
const u32 config0 = regs[InternalRegs::LightConfig0];
|
||||||
|
const u32 config1 = regs[InternalRegs::LightConfig1];
|
||||||
const u32 totalLightCount = Helpers::getBits<0, 3>(regs[InternalRegs::LightNumber]) + 1;
|
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;
|
enable = 1;
|
||||||
lightNum = totalLightCount;
|
lightNum = totalLightCount;
|
||||||
|
|
||||||
|
@ -138,6 +123,14 @@ namespace PICA {
|
||||||
light.distanceAttenuationEnable = ((config1 >> (24 + i)) & 1) ^ 1; // Of course same here
|
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;
|
d0.enable = Helpers::getBit<16>(config1) == 0;
|
||||||
d1.enable = Helpers::getBit<17>(config1) == 0;
|
d1.enable = Helpers::getBit<17>(config1) == 0;
|
||||||
fr.enable = Helpers::getBit<19>(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 {
|
enum class TextureFmt : u32 {
|
||||||
RGBA8 = 0x0,
|
RGBA8 = 0x0,
|
||||||
RGB8 = 0x1,
|
RGB8 = 0x1,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "PICA/pica_frag_config.hpp"
|
||||||
#include "PICA/regs.hpp"
|
#include "PICA/regs.hpp"
|
||||||
#include "PICA/shader_gen.hpp"
|
#include "PICA/shader_gen.hpp"
|
||||||
using namespace PICA;
|
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 FragmentGenerator::getDefaultVertexShader() {
|
||||||
std::string ret = "";
|
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 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";
|
shader += "lut_lookup_result = 1.0;\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr float scales[] = {1.0f, 2.0f, 4.0f, 8.0f, 0.0f, 0.0f, 0.25f, 0.5f};
|
float scale = lut.scale;
|
||||||
const u32 lutAbs = config.lighting.lutAbs;
|
uint inputID = lut.type;
|
||||||
const u32 lutSelect = config.lighting.lutSelect;
|
bool absEnabled = lut.absInput;
|
||||||
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...
|
|
||||||
|
|
||||||
switch (inputID) {
|
switch (inputID) {
|
||||||
case 0: shader += "lut_lookup_delta = dot(normal, normalize(half_vector));\n"; break;
|
case 0: shader += "lut_lookup_delta = dot(normal, normalize(half_vector));\n"; break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue