diff options
| author | 2017-06-09 14:55:54 -0500 | |
|---|---|---|
| committer | 2017-07-11 19:39:15 +0300 | |
| commit | 10b0bea06008fea89564dc5ef8895c0274f8ef18 (patch) | |
| tree | d32aea17963c7e01ad447270423ca22475f1cc34 /src | |
| parent | SwRasterizer: Calculate specular_1 for fragment lighting. (diff) | |
| download | yuzu-10b0bea06008fea89564dc5ef8895c0274f8ef18.tar.gz yuzu-10b0bea06008fea89564dc5ef8895c0274f8ef18.tar.xz yuzu-10b0bea06008fea89564dc5ef8895c0274f8ef18.zip | |
SwRasterizer: Calculate fresnel for fragment lighting.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/swrasterizer/rasterizer.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp index e0c326a4a..2d1daa24a 100644 --- a/src/video_core/swrasterizer/rasterizer.cpp +++ b/src/video_core/swrasterizer/rasterizer.cpp | |||
| @@ -310,7 +310,31 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(const Math::Qu | |||
| 310 | 310 | ||
| 311 | Math::Vec3<float> specular_1 = d1_lut_value * refl_value * light_config.specular_1.ToVec3f(); | 311 | Math::Vec3<float> specular_1 = d1_lut_value * refl_value * light_config.specular_1.ToVec3f(); |
| 312 | 312 | ||
| 313 | // TODO(Subv): Fresnel | 313 | if (lighting.config1.disable_lut_fr == 0 && |
| 314 | LightingRegs::IsLightingSamplerSupported( | ||
| 315 | lighting.config0.config, LightingRegs::LightingSampler::Fresnel)) { | ||
| 316 | |||
| 317 | // Lookup fresnel LUT value | ||
| 318 | float index = GetLutIndex(num, lighting.lut_input.fr.Value(), lighting.abs_lut_input.disable_fr == 0); | ||
| 319 | |||
| 320 | float scale = lighting.lut_scale.GetScale(lighting.lut_scale.fr); | ||
| 321 | |||
| 322 | float lut_value = scale * LookupLightingLut(static_cast<size_t>(LightingRegs::LightingSampler::Fresnel), index); | ||
| 323 | |||
| 324 | // Enabled for difffuse lighting alpha component | ||
| 325 | if (lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::PrimaryAlpha || | ||
| 326 | lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { | ||
| 327 | diffuse_sum.a() *= lut_value; | ||
| 328 | } | ||
| 329 | |||
| 330 | // Enabled for the specular lighting alpha component | ||
| 331 | if (lighting.config0.fresnel_selector == | ||
| 332 | LightingRegs::LightingFresnelSelector::SecondaryAlpha || | ||
| 333 | lighting.config0.fresnel_selector == LightingRegs::LightingFresnelSelector::Both) { | ||
| 334 | specular_sum.a() *= lut_value; | ||
| 335 | } | ||
| 336 | } | ||
| 337 | |||
| 314 | 338 | ||
| 315 | auto diffuse = light_config.diffuse.ToVec3f() * dot_product + light_config.ambient.ToVec3f(); | 339 | auto diffuse = light_config.diffuse.ToVec3f() * dot_product + light_config.ambient.ToVec3f(); |
| 316 | diffuse_sum += Math::MakeVec(diffuse * dist_atten, 0.0f); | 340 | diffuse_sum += Math::MakeVec(diffuse * dist_atten, 0.0f); |