From b5aa5703540adceb1fc867b577dad50388a47e15 Mon Sep 17 00:00:00 2001 From: wwylele Date: Fri, 18 Aug 2017 16:35:11 +0300 Subject: SwRasterizer/Lighting: implement LUT input CP --- src/video_core/swrasterizer/lighting.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/video_core/swrasterizer/lighting.cpp b/src/video_core/swrasterizer/lighting.cpp index 4f16bac07..b38964530 100644 --- a/src/video_core/swrasterizer/lighting.cpp +++ b/src/video_core/swrasterizer/lighting.cpp @@ -52,6 +52,7 @@ std::tuple, Math::Vec4> ComputeFragmentsColors( // Use the normalized the quaternion when performing the rotation auto normal = Math::QuaternionRotate(normquat, surface_normal); + auto tangent = Math::QuaternionRotate(normquat, surface_tangent); Math::Vec4 diffuse_sum = {0.0f, 0.0f, 0.0f, 1.0f}; Math::Vec4 specular_sum = {0.0f, 0.0f, 0.0f, 1.0f}; @@ -120,6 +121,16 @@ std::tuple, Math::Vec4> ComputeFragmentsColors( result = Math::Dot(light_vector, spot_dir.Cast() / 2047.0f); break; } + case LightingRegs::LightingLutInput::CP: + if (lighting.config0.config == LightingRegs::LightingConfig::Config7) { + const Math::Vec3 norm_half_vector = half_vector.Normalized(); + const Math::Vec3 half_vector_proj = + norm_half_vector - normal * Math::Dot(normal, norm_half_vector); + result = Math::Dot(half_vector_proj, tangent); + } else { + result = 0.0f; + } + break; default: LOG_CRITICAL(HW_GPU, "Unknown lighting LUT input %u\n", static_cast(input)); UNIMPLEMENTED(); -- cgit v1.2.3