From 2a75837bc30ba08e2470f4b91078747a08c5213a Mon Sep 17 00:00:00 2001 From: Subv Date: Fri, 9 Jun 2017 18:18:57 -0500 Subject: SwRasterizer: Corrected the light LUT lookups. --- src/video_core/swrasterizer/rasterizer.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp index a9098e1f0..2c804b6e7 100644 --- a/src/video_core/swrasterizer/rasterizer.cpp +++ b/src/video_core/swrasterizer/rasterizer.cpp @@ -177,9 +177,9 @@ std::tuple, Math::Vec4> ComputeFragmentsColors(const Math::Qu float sample_loc = scale * distance + bias; - u8 lutindex = MathUtil::Clamp(floorf(sample_loc * 256.f), 0.0f, 255.0f); + u8 lutindex = MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f); float delta = sample_loc * 256 - lutindex; - dist_atten = LookupLightingLut(lut, lutindex, delta / 256.f); + dist_atten = LookupLightingLut(lut, lutindex, delta); } float clamp_highlights = 1.0f; @@ -227,13 +227,14 @@ std::tuple, Math::Vec4> ComputeFragmentsColors(const Math::Qu else result = std::max(result, 0.0f); - u8 lutindex = MathUtil::Clamp(floorf(result * 256.f), 0.0f, 255.0f); + u8 lutindex = MathUtil::Clamp(std::floor(result * 256.f), 0.0f, 255.0f); float delta = result * 256 - lutindex; - return { lutindex, delta / 256.f }; + return { lutindex, delta }; } else { - u8 tmpi = MathUtil::Clamp(floorf(result * 128.f), 0.0f, 127.0f); + float flr = std::floor(result * 128.f); + s8 tmpi = MathUtil::Clamp(flr, -128.0f, 127.0f); float delta = result * 128.f - tmpi; - return { tmpi & 0xFF, delta / 128.f }; + return { tmpi & 0xFF, delta }; } }; -- cgit v1.2.3