yuzu-emu
/
yuzu
Archived
1
0
Fork 0

pica/lighting: only apply Fresnel factor for the last light

This commit is contained in:
wwylele 2017-08-27 07:33:27 +03:00
parent f0e461bf6f
commit 12fbc8c8df
2 changed files with 9 additions and 7 deletions

View File

@ -750,7 +750,8 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) {
} }
// Fresnel // Fresnel
if (lighting.lut_fr.enable && // Note: only the last entry in the light slots applies the Fresnel factor
if (light_index == lighting.src_num - 1 && lighting.lut_fr.enable &&
LightingRegs::IsLightingSamplerSupported(lighting.config, LightingRegs::IsLightingSamplerSupported(lighting.config,
LightingRegs::LightingSampler::Fresnel)) { LightingRegs::LightingSampler::Fresnel)) {
// Lookup fresnel LUT value // Lookup fresnel LUT value
@ -759,17 +760,17 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) {
lighting.lut_fr.type, lighting.lut_fr.abs_input); lighting.lut_fr.type, lighting.lut_fr.abs_input);
value = "(" + std::to_string(lighting.lut_fr.scale) + " * " + value + ")"; value = "(" + std::to_string(lighting.lut_fr.scale) + " * " + value + ")";
// Enabled for difffuse lighting alpha component // Enabled for diffuse lighting alpha component
if (lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::PrimaryAlpha || if (lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::PrimaryAlpha ||
lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) {
out += "diffuse_sum.a *= " + value + ";\n"; out += "diffuse_sum.a = " + value + ";\n";
} }
// Enabled for the specular lighting alpha component // Enabled for the specular lighting alpha component
if (lighting.fresnel_selector == if (lighting.fresnel_selector ==
LightingRegs::LightingFresnelSelector::SecondaryAlpha || LightingRegs::LightingFresnelSelector::SecondaryAlpha ||
lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) {
out += "specular_sum.a *= " + value + ";\n"; out += "specular_sum.a = " + value + ";\n";
} }
} }

View File

@ -230,7 +230,8 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
d1_lut_value * refl_value * light_config.specular_1.ToVec3f(); d1_lut_value * refl_value * light_config.specular_1.ToVec3f();
// Fresnel // Fresnel
if (lighting.config1.disable_lut_fr == 0 && // Note: only the last entry in the light slots applies the Fresnel factor
if (light_index == lighting.max_light_index && lighting.config1.disable_lut_fr == 0 &&
LightingRegs::IsLightingSamplerSupported(lighting.config0.config, LightingRegs::IsLightingSamplerSupported(lighting.config0.config,
LightingRegs::LightingSampler::Fresnel)) { LightingRegs::LightingSampler::Fresnel)) {
@ -242,14 +243,14 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
if (lighting.config0.fresnel_selector == if (lighting.config0.fresnel_selector ==
LightingRegs::LightingFresnelSelector::PrimaryAlpha || LightingRegs::LightingFresnelSelector::PrimaryAlpha ||
lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) {
diffuse_sum.a() *= lut_value; diffuse_sum.a() = lut_value;
} }
// Enabled for the specular lighting alpha component // Enabled for the specular lighting alpha component
if (lighting.config0.fresnel_selector == if (lighting.config0.fresnel_selector ==
LightingRegs::LightingFresnelSelector::SecondaryAlpha || LightingRegs::LightingFresnelSelector::SecondaryAlpha ||
lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) {
specular_sum.a() *= lut_value; specular_sum.a() = lut_value;
} }
} }