summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/swrasterizer/rasterizer.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp
index 382b5927b..54af53bbd 100644
--- a/src/video_core/swrasterizer/rasterizer.cpp
+++ b/src/video_core/swrasterizer/rasterizer.cpp
@@ -143,18 +143,18 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
143 // Use the normalized the quaternion when performing the rotation 143 // Use the normalized the quaternion when performing the rotation
144 auto normal = Math::QuaternionRotate(normquat.Normalized(), surface_normal); 144 auto normal = Math::QuaternionRotate(normquat.Normalized(), surface_normal);
145 145
146 Math::Vec3<float> light_vector = {};
147 Math::Vec4<float> diffuse_sum = {0.f, 0.f, 0.f, 1.f}; 146 Math::Vec4<float> diffuse_sum = {0.f, 0.f, 0.f, 1.f};
148 Math::Vec4<float> specular_sum = {0.f, 0.f, 0.f, 1.f}; 147 Math::Vec4<float> specular_sum = {0.f, 0.f, 0.f, 1.f};
149 Math::Vec3<float> refl_value = {};
150 148
151 for (unsigned light_index = 0; light_index <= lighting.max_light_index; ++light_index) { 149 for (unsigned light_index = 0; light_index <= lighting.max_light_index; ++light_index) {
152 unsigned num = lighting.light_enable.GetNum(light_index); 150 unsigned num = lighting.light_enable.GetNum(light_index);
153 const auto& light_config = g_state.regs.lighting.light[num]; 151 const auto& light_config = g_state.regs.lighting.light[num];
154 152
153 Math::Vec3<float> refl_value = {};
155 Math::Vec3<float> position = {float16::FromRaw(light_config.x).ToFloat32(), 154 Math::Vec3<float> position = {float16::FromRaw(light_config.x).ToFloat32(),
156 float16::FromRaw(light_config.y).ToFloat32(), 155 float16::FromRaw(light_config.y).ToFloat32(),
157 float16::FromRaw(light_config.z).ToFloat32()}; 156 float16::FromRaw(light_config.z).ToFloat32()};
157 Math::Vec3<float> light_vector;
158 158
159 if (light_config.config.directional) 159 if (light_config.config.directional)
160 light_vector = position; 160 light_vector = position;
@@ -175,11 +175,12 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
175 if (!lighting.IsDistAttenDisabled(num)) { 175 if (!lighting.IsDistAttenDisabled(num)) {
176 auto distance = (-view - position).Length(); 176 auto distance = (-view - position).Length();
177 float scale = Pica::float20::FromRaw(light_config.dist_atten_scale).ToFloat32(); 177 float scale = Pica::float20::FromRaw(light_config.dist_atten_scale).ToFloat32();
178 float bias = Pica::float20::FromRaw(light_config.dist_atten_scale).ToFloat32(); 178 float dist_aten_bias =
179 Pica::float20::FromRaw(light_config.dist_atten_scale).ToFloat32();
179 size_t lut = 180 size_t lut =
180 static_cast<size_t>(LightingRegs::LightingSampler::DistanceAttenuation) + num; 181 static_cast<size_t>(LightingRegs::LightingSampler::DistanceAttenuation) + num;
181 182
182 float sample_loc = scale * distance + bias; 183 float sample_loc = scale * distance + dist_aten_bias;
183 184
184 u8 lutindex = 185 u8 lutindex =
185 static_cast<u8>(MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f)); 186 static_cast<u8>(MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f));
@@ -238,7 +239,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
238 return {lutindex, delta}; 239 return {lutindex, delta};
239 } else { 240 } else {
240 float flr = std::floor(result * 128.f); 241 float flr = std::floor(result * 128.f);
241 s8 lutindex = static_cast<u8>(MathUtil::Clamp(flr, -128.0f, 127.0f)); 242 s8 lutindex = static_cast<s8>(MathUtil::Clamp(flr, -128.0f, 127.0f));
242 float delta = result * 128.f - lutindex; 243 float delta = result * 128.f - lutindex;
243 return {static_cast<u8>(lutindex), delta}; 244 return {static_cast<u8>(lutindex), delta};
244 } 245 }