From d1de52ee5de1e3e3346048a280b7685ee8e072e2 Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 13 Jun 2017 12:36:45 -0500 Subject: [PATCH] SwRasterizer: Fixed a few conversion warnings and moved per-light values into the per-light loop. --- src/video_core/swrasterizer/rasterizer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp index 08a2fbd53..f9a02c6f1 100644 --- a/src/video_core/swrasterizer/rasterizer.cpp +++ b/src/video_core/swrasterizer/rasterizer.cpp @@ -143,18 +143,18 @@ std::tuple, Math::Vec4> ComputeFragmentsColors( // Use the normalized the quaternion when performing the rotation auto normal = Math::QuaternionRotate(normquat.Normalized(), surface_normal); - Math::Vec3 light_vector = {}; Math::Vec4 diffuse_sum = {0.f, 0.f, 0.f, 1.f}; Math::Vec4 specular_sum = {0.f, 0.f, 0.f, 1.f}; - Math::Vec3 refl_value = {}; for (unsigned light_index = 0; light_index <= lighting.max_light_index; ++light_index) { unsigned num = lighting.light_enable.GetNum(light_index); const auto& light_config = g_state.regs.lighting.light[num]; + Math::Vec3 refl_value = {}; Math::Vec3 position = {float16::FromRaw(light_config.x).ToFloat32(), float16::FromRaw(light_config.y).ToFloat32(), float16::FromRaw(light_config.z).ToFloat32()}; + Math::Vec3 light_vector; if (light_config.config.directional) light_vector = position; @@ -175,11 +175,12 @@ std::tuple, Math::Vec4> ComputeFragmentsColors( if (!lighting.IsDistAttenDisabled(num)) { auto distance = (-view - position).Length(); float scale = Pica::float20::FromRaw(light_config.dist_atten_scale).ToFloat32(); - float bias = Pica::float20::FromRaw(light_config.dist_atten_scale).ToFloat32(); + float dist_aten_bias = + Pica::float20::FromRaw(light_config.dist_atten_scale).ToFloat32(); size_t lut = static_cast(LightingRegs::LightingSampler::DistanceAttenuation) + num; - float sample_loc = scale * distance + bias; + float sample_loc = scale * distance + dist_aten_bias; u8 lutindex = static_cast(MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f)); @@ -238,7 +239,7 @@ std::tuple, Math::Vec4> ComputeFragmentsColors( return {lutindex, delta}; } else { float flr = std::floor(result * 128.f); - s8 lutindex = static_cast(MathUtil::Clamp(flr, -128.0f, 127.0f)); + s8 lutindex = static_cast(MathUtil::Clamp(flr, -128.0f, 127.0f)); float delta = result * 128.f - lutindex; return {static_cast(lutindex), delta}; }