summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2017-09-05 10:00:49 -0400
committerGravatar GitHub2017-09-05 10:00:49 -0400
commitff4941fb3a1a839033a27d6341d6212cd83de691 (patch)
tree7987ce9807dbc35b573439407cbe4ebb8e243163
parentMerge pull request #2831 from Subv/uds_auth (diff)
parentpica/lighting: only apply Fresnel factor for the last light (diff)
downloadyuzu-ff4941fb3a1a839033a27d6341d6212cd83de691.tar.gz
yuzu-ff4941fb3a1a839033a27d6341d6212cd83de691.tar.xz
yuzu-ff4941fb3a1a839033a27d6341d6212cd83de691.zip
Merge pull request #2914 from wwylele/fresnel-fix
pica/lighting: only apply Fresnel factor for the last light
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.cpp9
-rw-r--r--src/video_core/swrasterizer/lighting.cpp7
2 files changed, 9 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp
index c8fc7a0ff..c536e61e1 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp
@@ -751,7 +751,8 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) {
751 } 751 }
752 752
753 // Fresnel 753 // Fresnel
754 if (lighting.lut_fr.enable && 754 // Note: only the last entry in the light slots applies the Fresnel factor
755 if (light_index == lighting.src_num - 1 && lighting.lut_fr.enable &&
755 LightingRegs::IsLightingSamplerSupported(lighting.config, 756 LightingRegs::IsLightingSamplerSupported(lighting.config,
756 LightingRegs::LightingSampler::Fresnel)) { 757 LightingRegs::LightingSampler::Fresnel)) {
757 // Lookup fresnel LUT value 758 // Lookup fresnel LUT value
@@ -760,17 +761,17 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) {
760 lighting.lut_fr.type, lighting.lut_fr.abs_input); 761 lighting.lut_fr.type, lighting.lut_fr.abs_input);
761 value = "(" + std::to_string(lighting.lut_fr.scale) + " * " + value + ")"; 762 value = "(" + std::to_string(lighting.lut_fr.scale) + " * " + value + ")";
762 763
763 // Enabled for difffuse lighting alpha component 764 // Enabled for diffuse lighting alpha component
764 if (lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::PrimaryAlpha || 765 if (lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::PrimaryAlpha ||
765 lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { 766 lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) {
766 out += "diffuse_sum.a *= " + value + ";\n"; 767 out += "diffuse_sum.a = " + value + ";\n";
767 } 768 }
768 769
769 // Enabled for the specular lighting alpha component 770 // Enabled for the specular lighting alpha component
770 if (lighting.fresnel_selector == 771 if (lighting.fresnel_selector ==
771 LightingRegs::LightingFresnelSelector::SecondaryAlpha || 772 LightingRegs::LightingFresnelSelector::SecondaryAlpha ||
772 lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { 773 lighting.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) {
773 out += "specular_sum.a *= " + value + ";\n"; 774 out += "specular_sum.a = " + value + ";\n";
774 } 775 }
775 } 776 }
776 777
diff --git a/src/video_core/swrasterizer/lighting.cpp b/src/video_core/swrasterizer/lighting.cpp
index b38964530..5fa748611 100644
--- a/src/video_core/swrasterizer/lighting.cpp
+++ b/src/video_core/swrasterizer/lighting.cpp
@@ -230,7 +230,8 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
230 d1_lut_value * refl_value * light_config.specular_1.ToVec3f(); 230 d1_lut_value * refl_value * light_config.specular_1.ToVec3f();
231 231
232 // Fresnel 232 // Fresnel
233 if (lighting.config1.disable_lut_fr == 0 && 233 // Note: only the last entry in the light slots applies the Fresnel factor
234 if (light_index == lighting.max_light_index && lighting.config1.disable_lut_fr == 0 &&
234 LightingRegs::IsLightingSamplerSupported(lighting.config0.config, 235 LightingRegs::IsLightingSamplerSupported(lighting.config0.config,
235 LightingRegs::LightingSampler::Fresnel)) { 236 LightingRegs::LightingSampler::Fresnel)) {
236 237
@@ -242,14 +243,14 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
242 if (lighting.config0.fresnel_selector == 243 if (lighting.config0.fresnel_selector ==
243 LightingRegs::LightingFresnelSelector::PrimaryAlpha || 244 LightingRegs::LightingFresnelSelector::PrimaryAlpha ||
244 lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { 245 lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) {
245 diffuse_sum.a() *= lut_value; 246 diffuse_sum.a() = lut_value;
246 } 247 }
247 248
248 // Enabled for the specular lighting alpha component 249 // Enabled for the specular lighting alpha component
249 if (lighting.config0.fresnel_selector == 250 if (lighting.config0.fresnel_selector ==
250 LightingRegs::LightingFresnelSelector::SecondaryAlpha || 251 LightingRegs::LightingFresnelSelector::SecondaryAlpha ||
251 lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { 252 lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) {
252 specular_sum.a() *= lut_value; 253 specular_sum.a() = lut_value;
253 } 254 }
254 } 255 }
255 256