Nyom 3: The final nyom

This commit is contained in:
offtkp 2024-07-20 00:32:00 +03:00
parent a903e1b2a4
commit f46163006a
2 changed files with 13 additions and 12 deletions

View file

@ -197,12 +197,12 @@ namespace PICA {
return std::memcmp(this, &config, sizeof(FragmentConfig)) == 0; return std::memcmp(this, &config, sizeof(FragmentConfig)) == 0;
} }
FragmentConfig(const std::array<u32, 0x300>& regs) : lighting(regs) FragmentConfig(const std::array<u32, 0x300>& regs) : lighting(regs) {
{
auto alphaTestConfig = regs[InternalRegs::AlphaTestConfig]; auto alphaTestConfig = regs[InternalRegs::AlphaTestConfig];
auto alphaTestFunction = Helpers::getBits<4, 3>(alphaTestConfig); auto alphaTestFunction = Helpers::getBits<4, 3>(alphaTestConfig);
outConfig.alphaTestFunction = (alphaTestConfig & 1) ? static_cast<PICA::CompareFunction>(alphaTestFunction) : PICA::CompareFunction::Always; outConfig.alphaTestFunction =
(alphaTestConfig & 1) ? static_cast<PICA::CompareFunction>(alphaTestFunction) : PICA::CompareFunction::Always;
outConfig.depthMapEnable = regs[InternalRegs::DepthmapEnable] & 1; outConfig.depthMapEnable = regs[InternalRegs::DepthmapEnable] & 1;
texConfig.texUnitConfig = regs[InternalRegs::TexUnitCfg]; texConfig.texUnitConfig = regs[InternalRegs::TexUnitCfg];

View file

@ -594,23 +594,24 @@ bool FragmentGenerator::isSamplerEnabled(u32 environmentID, u32 lutID) {
} }
void FragmentGenerator::compileLUTLookup(std::string& shader, const PICA::FragmentConfig& config, u32 lightIndex, u32 lutID) { void FragmentGenerator::compileLUTLookup(std::string& shader, const PICA::FragmentConfig& config, u32 lightIndex, u32 lutID) {
const LightingLUTConfig& lut = config.lighting.luts[lutID];
uint lutIndex = 0; uint lutIndex = 0;
bool spotAttenuationEnable = true; bool lutEnabled = false;
if (lutID == spotlightLutIndex) { if (lutID == spotlightLutIndex) {
// These are the spotlight attenuation LUTs // These are the spotlight attenuation LUTs
lutIndex = 8u + lightIndex; lutIndex = 8u + lightIndex;
spotAttenuationEnable = config.lighting.lights[lightIndex].spotAttenuationEnable; lutEnabled = config.lighting.lights[lightIndex].spotAttenuationEnable;
} else if (lutID <= 6) { } else if (lutID <= 6) {
lutIndex = lutID; lutIndex = lutID;
lutEnabled = lut.enable;
} else { } else {
Helpers::warn("Shadergen: Unimplemented LUT value"); Helpers::warn("Shadergen: Unimplemented LUT value");
} }
const bool samplerEnabled = isSamplerEnabled(config.lighting.config, lutID); const bool samplerEnabled = isSamplerEnabled(config.lighting.config, lutID);
const LightingLUTConfig& lut = config.lighting.luts[lutID];
if (!samplerEnabled || !lut.enable || !spotAttenuationEnable) { if (!samplerEnabled || !lutEnabled) {
shader += "lut_lookup_result = 1.0;\n"; shader += "lut_lookup_result = 1.0;\n";
return; return;
} }