From 46184cd301d0144486f3d29c5eaf7e7771179eb6 Mon Sep 17 00:00:00 2001 From: Subv Date: Fri, 9 Jun 2017 15:24:28 -0500 Subject: [PATCH] SwRasterizer: Fixed the lighting lut lookup function. --- src/video_core/swrasterizer/rasterizer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp index bd3dc8822..5f28c3d53 100644 --- a/src/video_core/swrasterizer/rasterizer.cpp +++ b/src/video_core/swrasterizer/rasterizer.cpp @@ -117,7 +117,9 @@ static std::tuple ConvertCubeCoord(float24 u, float24 v float LookupLightingLut(size_t lut_index, float index) { - unsigned index_i = static_cast(MathUtil::Clamp(floor(index * 256), 0.0f, 1.0f)); + index *= 256; + + unsigned index_i = static_cast(MathUtil::Clamp(floor(index), 0.0f, 255.0f)); float index_f = index - index_i; @@ -126,7 +128,7 @@ float LookupLightingLut(size_t lut_index, float index) { float lut_value = g_state.lighting.luts[lut_index][index_i].ToFloat(); float lut_diff = g_state.lighting.luts[lut_index][index_i].DiffToFloat(); - return lut_value + lut_diff * index_f; + return lut_value + lut_diff * index_f / 256.f; } std::tuple, Math::Vec4> ComputeFragmentsColors(const Math::Quaternion& normquat, const Math::Vec3& view) {