summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2017-06-28 12:43:00 -0500
committerGravatar wwylele2017-07-11 19:39:15 +0300
commit9906feefbd37ebfd658fecc47e960f23adc6b190 (patch)
tree6e1b0eab1e8a5d6531cbf96663e607510556a956 /src
parentSwRasterizer/Lighting: Move the lighting enable check outside the ComputeFrag... (diff)
downloadyuzu-9906feefbd37ebfd658fecc47e960f23adc6b190.tar.gz
yuzu-9906feefbd37ebfd658fecc47e960f23adc6b190.tar.xz
yuzu-9906feefbd37ebfd658fecc47e960f23adc6b190.zip
SwRasterizer/Lighting: Move the clamp highlight calculation to the end of the per-light loop body.
Diffstat (limited to 'src')
-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(
163 163
164 light_vector.Normalize(); 164 light_vector.Normalize();
165 165
166 auto LV_N = Math::Dot(light_vector, normal);
167 auto dot_product = LV_N;
168
169 if (light_config.config.two_sided_diffuse)
170 dot_product = std::abs(dot_product);
171 else
172 dot_product = std::max(dot_product, 0.0f);
173
174 float dist_atten = 1.0f; 166 float dist_atten = 1.0f;
175 if (!lighting.IsDistAttenDisabled(num)) { 167 if (!lighting.IsDistAttenDisabled(num)) {
176 auto distance = (-view - position).Length(); 168 auto distance = (-view - position).Length();
@@ -187,15 +179,6 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
187 dist_atten = LookupLightingLut(g_state.lighting, lut, lutindex, delta); 179 dist_atten = LookupLightingLut(g_state.lighting, lut, lutindex, delta);
188 } 180 }
189 181
190 float clamp_highlights = 1.0f;
191
192 if (lighting.config0.clamp_highlights) {
193 if (LV_N <= 0.f)
194 clamp_highlights = 0.f;
195 else
196 clamp_highlights = 1.f;
197 }
198
199 auto GetLutIndex = [&](unsigned num, LightingRegs::LightingLutInput input, 182 auto GetLutIndex = [&](unsigned num, LightingRegs::LightingLutInput input,
200 bool abs) -> std::tuple<u8, float> { 183 bool abs) -> std::tuple<u8, float> {
201 184
@@ -386,6 +369,23 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
386 } 369 }
387 } 370 }
388 371
372 auto dot_product = Math::Dot(light_vector, normal);
373
374 // Calculate clamp highlights before applying the two-sided diffuse configuration to the dot
375 // product.
376 float clamp_highlights = 1.0f;
377 if (lighting.config0.clamp_highlights) {
378 if (dot_product <= 0.f)
379 clamp_highlights = 0.f;
380 else
381 clamp_highlights = 1.f;
382 }
383
384 if (light_config.config.two_sided_diffuse)
385 dot_product = std::abs(dot_product);
386 else
387 dot_product = std::max(dot_product, 0.0f);
388
389 auto diffuse = 389 auto diffuse =
390 light_config.diffuse.ToVec3f() * dot_product + light_config.ambient.ToVec3f(); 390 light_config.diffuse.ToVec3f() * dot_product + light_config.ambient.ToVec3f();
391 diffuse_sum += Math::MakeVec(diffuse * dist_atten, 0.0f); 391 diffuse_sum += Math::MakeVec(diffuse * dist_atten, 0.0f);