summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2017-06-28 19:43:00 +0200
committerwwylele <wwylele@gmail.com>2017-07-11 18:39:15 +0200
commit9906feefbd37ebfd658fecc47e960f23adc6b190 (patch)
tree6e1b0eab1e8a5d6531cbf96663e607510556a956 /src/video_core
parentSwRasterizer/Lighting: Move the lighting enable check outside the ComputeFragmentsColors function. (diff)
downloadyuzu-9906feefbd37ebfd658fecc47e960f23adc6b190.tar
yuzu-9906feefbd37ebfd658fecc47e960f23adc6b190.tar.gz
yuzu-9906feefbd37ebfd658fecc47e960f23adc6b190.tar.bz2
yuzu-9906feefbd37ebfd658fecc47e960f23adc6b190.tar.lz
yuzu-9906feefbd37ebfd658fecc47e960f23adc6b190.tar.xz
yuzu-9906feefbd37ebfd658fecc47e960f23adc6b190.tar.zst
yuzu-9906feefbd37ebfd658fecc47e960f23adc6b190.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/swrasterizer/rasterizer.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp
index b2d2b6ef2..2c7a1a815 100644
--- a/src/video_core/swrasterizer/rasterizer.cpp
+++ b/src/video_core/swrasterizer/rasterizer.cpp
@@ -163,14 +163,6 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
light_vector.Normalize();
- auto LV_N = Math::Dot(light_vector, normal);
- auto dot_product = LV_N;
-
- if (light_config.config.two_sided_diffuse)
- dot_product = std::abs(dot_product);
- else
- dot_product = std::max(dot_product, 0.0f);
-
float dist_atten = 1.0f;
if (!lighting.IsDistAttenDisabled(num)) {
auto distance = (-view - position).Length();
@@ -187,15 +179,6 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
dist_atten = LookupLightingLut(g_state.lighting, lut, lutindex, delta);
}
- float clamp_highlights = 1.0f;
-
- if (lighting.config0.clamp_highlights) {
- if (LV_N <= 0.f)
- clamp_highlights = 0.f;
- else
- clamp_highlights = 1.f;
- }
-
auto GetLutIndex = [&](unsigned num, LightingRegs::LightingLutInput input,
bool abs) -> std::tuple<u8, float> {
@@ -386,6 +369,23 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
}
}
+ auto dot_product = Math::Dot(light_vector, normal);
+
+ // Calculate clamp highlights before applying the two-sided diffuse configuration to the dot
+ // product.
+ float clamp_highlights = 1.0f;
+ if (lighting.config0.clamp_highlights) {
+ if (dot_product <= 0.f)
+ clamp_highlights = 0.f;
+ else
+ clamp_highlights = 1.f;
+ }
+
+ if (light_config.config.two_sided_diffuse)
+ dot_product = std::abs(dot_product);
+ else
+ dot_product = std::max(dot_product, 0.0f);
+
auto diffuse =
light_config.diffuse.ToVec3f() * dot_product + light_config.ambient.ToVec3f();
diffuse_sum += Math::MakeVec(diffuse * dist_atten, 0.0f);