Skip to content

VERY experimental Nintendo Switch 2 emulator

C++

Merge pull request #2872 from wwylele/sw-geo-factor

Yuri Kunde Schlesnerd7d434cbc7e8
diff --cc src/video_core/swrasterizer/lighting.cpp
index ffd35792a2,91683afa4d..39a3e396d6
--- a/src/video_core/swrasterizer/lighting.cpp
+++ b/src/video_core/swrasterizer/lighting.cpp
@@@ -240,12 -225,23 +241,23 @@@ std::tuple<Math::Vec4<u8>, Math::Vec4<u
else
dot_product = std::max(dot_product, 0.0f);
+ if (light_config.config.geometric_factor_0 || light_config.config.geometric_factor_1) {
+ float geo_factor = half_vector.Length2();
+ geo_factor = geo_factor == 0.0f ? 0.0f : std::min(dot_product / geo_factor, 1.0f);
+ if (light_config.config.geometric_factor_0) {
+ specular_0 *= geo_factor;
+ }
+ if (light_config.config.geometric_factor_1) {
+ specular_1 *= geo_factor;
+ }
+ }
+
auto diffuse =
light_config.diffuse.ToVec3f() * dot_product + light_config.ambient.ToVec3f();
- diffuse_sum += Math::MakeVec(diffuse * dist_atten, 0.0f);
+ diffuse_sum += Math::MakeVec(diffuse * dist_atten * spot_atten, 0.0f);
- specular_sum +=
- Math::MakeVec((specular_0 + specular_1) * clamp_highlights * dist_atten, 0.0f);
+ specular_sum += Math::MakeVec(
+ (specular_0 + specular_1) * clamp_highlights * dist_atten * spot_atten, 0.0f);
}
diffuse_sum += Math::MakeVec(lighting.global_ambient.ToVec3f(), 0.0f);