summaryrefslogtreecommitdiff
path: root/src/video_core/swrasterizer/rasterizer.cpp
diff options
context:
space:
mode:
authorGravatar wwylele2017-07-11 22:07:19 +0300
committerGravatar wwylele2017-07-11 22:15:35 +0300
commit56e5425e593e29aecf255c441791f2e24512f418 (patch)
tree83560ab422a806c46d4b700bbff549a16ef71cc6 /src/video_core/swrasterizer/rasterizer.cpp
parentSwRasterizer/Lighting: get rid of nested return (diff)
downloadyuzu-56e5425e593e29aecf255c441791f2e24512f418.tar.gz
yuzu-56e5425e593e29aecf255c441791f2e24512f418.tar.xz
yuzu-56e5425e593e29aecf255c441791f2e24512f418.zip
SwRasterizer/Lighting: unify float suffix
Diffstat (limited to 'src/video_core/swrasterizer/rasterizer.cpp')
-rw-r--r--src/video_core/swrasterizer/rasterizer.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp
index e46790f85..c83680629 100644
--- a/src/video_core/swrasterizer/rasterizer.cpp
+++ b/src/video_core/swrasterizer/rasterizer.cpp
@@ -143,8 +143,8 @@ 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::Vec4<float> diffuse_sum = {0.f, 0.f, 0.f, 1.f}; 146 Math::Vec4<float> diffuse_sum = {0.0f, 0.0f, 0.0f, 1.0f};
147 Math::Vec4<float> specular_sum = {0.f, 0.f, 0.f, 1.f}; 147 Math::Vec4<float> specular_sum = {0.0f, 0.0f, 0.0f, 1.0f};
148 148
149 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) {
150 unsigned num = lighting.light_enable.GetNum(light_index); 150 unsigned num = lighting.light_enable.GetNum(light_index);
@@ -174,7 +174,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
174 float sample_loc = scale * distance + bias; 174 float sample_loc = scale * distance + bias;
175 175
176 u8 lutindex = 176 u8 lutindex =
177 static_cast<u8>(MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f)); 177 static_cast<u8>(MathUtil::Clamp(std::floor(sample_loc * 256.0f), 0.0f, 255.0f));
178 float delta = sample_loc * 256 - lutindex; 178 float delta = sample_loc * 256 - lutindex;
179 dist_atten = LookupLightingLut(lighting_state, lut, lutindex, delta); 179 dist_atten = LookupLightingLut(lighting_state, lut, lutindex, delta);
180 } 180 }
@@ -206,7 +206,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
206 default: 206 default:
207 LOG_CRITICAL(HW_GPU, "Unknown lighting LUT input %u\n", static_cast<u32>(input)); 207 LOG_CRITICAL(HW_GPU, "Unknown lighting LUT input %u\n", static_cast<u32>(input));
208 UNIMPLEMENTED(); 208 UNIMPLEMENTED();
209 result = 0.f; 209 result = 0.0f;
210 } 210 }
211 211
212 u8 index; 212 u8 index;
@@ -218,13 +218,13 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
218 else 218 else
219 result = std::max(result, 0.0f); 219 result = std::max(result, 0.0f);
220 220
221 float flr = std::floor(result * 256.f); 221 float flr = std::floor(result * 256.0f);
222 index = static_cast<u8>(MathUtil::Clamp(flr, 0.0f, 255.0f)); 222 index = static_cast<u8>(MathUtil::Clamp(flr, 0.0f, 255.0f));
223 delta = result * 256 - index; 223 delta = result * 256 - index;
224 } else { 224 } else {
225 float flr = std::floor(result * 128.f); 225 float flr = std::floor(result * 128.0f);
226 s8 signed_index = static_cast<s8>(MathUtil::Clamp(flr, -128.0f, 127.0f)); 226 s8 signed_index = static_cast<s8>(MathUtil::Clamp(flr, -128.0f, 127.0f));
227 delta = result * 128.f - signed_index; 227 delta = result * 128.0f - signed_index;
228 index = static_cast<u8>(signed_index); 228 index = static_cast<u8>(signed_index);
229 } 229 }
230 230
@@ -278,6 +278,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
278 refl_value.z = refl_value.x; 278 refl_value.z = refl_value.x;
279 } 279 }
280 280
281 // Specular 1 component
281 float d1_lut_value = 1.0f; 282 float d1_lut_value = 1.0f;
282 if (lighting.config1.disable_lut_d1 == 0 && 283 if (lighting.config1.disable_lut_d1 == 0 &&
283 LightingRegs::IsLightingSamplerSupported( 284 LightingRegs::IsLightingSamplerSupported(
@@ -290,6 +291,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
290 Math::Vec3<float> specular_1 = 291 Math::Vec3<float> specular_1 =
291 d1_lut_value * refl_value * light_config.specular_1.ToVec3f(); 292 d1_lut_value * refl_value * light_config.specular_1.ToVec3f();
292 293
294 // Fresnel
293 if (lighting.config1.disable_lut_fr == 0 && 295 if (lighting.config1.disable_lut_fr == 0 &&
294 LightingRegs::IsLightingSamplerSupported(lighting.config0.config, 296 LightingRegs::IsLightingSamplerSupported(lighting.config0.config,
295 LightingRegs::LightingSampler::Fresnel)) { 297 LightingRegs::LightingSampler::Fresnel)) {
@@ -319,10 +321,10 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
319 // product. 321 // product.
320 float clamp_highlights = 1.0f; 322 float clamp_highlights = 1.0f;
321 if (lighting.config0.clamp_highlights) { 323 if (lighting.config0.clamp_highlights) {
322 if (dot_product <= 0.f) 324 if (dot_product <= 0.0f)
323 clamp_highlights = 0.f; 325 clamp_highlights = 0.0f;
324 else 326 else
325 clamp_highlights = 1.f; 327 clamp_highlights = 1.0f;
326 } 328 }
327 329
328 if (light_config.config.two_sided_diffuse) 330 if (light_config.config.two_sided_diffuse)
@@ -335,7 +337,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
335 diffuse_sum += Math::MakeVec(diffuse * dist_atten, 0.0f); 337 diffuse_sum += Math::MakeVec(diffuse * dist_atten, 0.0f);
336 338
337 specular_sum += 339 specular_sum +=
338 Math::MakeVec((specular_0 + specular_1) * clamp_highlights * dist_atten, 0.f); 340 Math::MakeVec((specular_0 + specular_1) * clamp_highlights * dist_atten, 0.0f);
339 } 341 }
340 342
341 diffuse_sum += Math::MakeVec(lighting.global_ambient.ToVec3f(), 0.0f); 343 diffuse_sum += Math::MakeVec(lighting.global_ambient.ToVec3f(), 0.0f);