summaryrefslogtreecommitdiffstats
path: root/src/video_core/swrasterizer
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2017-08-18 15:35:11 +0200
committerwwylele <wwylele@gmail.com>2017-08-22 08:34:44 +0200
commitb5aa5703540adceb1fc867b577dad50388a47e15 (patch)
tree54d9ba0c58d0d272c0e8201c8b8ed6346840561a /src/video_core/swrasterizer
parentSwRasterizer/Lighting: implement bump mapping (diff)
downloadyuzu-b5aa5703540adceb1fc867b577dad50388a47e15.tar
yuzu-b5aa5703540adceb1fc867b577dad50388a47e15.tar.gz
yuzu-b5aa5703540adceb1fc867b577dad50388a47e15.tar.bz2
yuzu-b5aa5703540adceb1fc867b577dad50388a47e15.tar.lz
yuzu-b5aa5703540adceb1fc867b577dad50388a47e15.tar.xz
yuzu-b5aa5703540adceb1fc867b577dad50388a47e15.tar.zst
yuzu-b5aa5703540adceb1fc867b577dad50388a47e15.zip
Diffstat (limited to 'src/video_core/swrasterizer')
-rw-r--r--src/video_core/swrasterizer/lighting.cpp11
1 files changed, 11 insertions, 0 deletions
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<u8>, Math::Vec4<u8>> 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<float> diffuse_sum = {0.0f, 0.0f, 0.0f, 1.0f};
Math::Vec4<float> specular_sum = {0.0f, 0.0f, 0.0f, 1.0f};
@@ -120,6 +121,16 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
result = Math::Dot(light_vector, spot_dir.Cast<float>() / 2047.0f);
break;
}
+ case LightingRegs::LightingLutInput::CP:
+ if (lighting.config0.config == LightingRegs::LightingConfig::Config7) {
+ const Math::Vec3<float> norm_half_vector = half_vector.Normalized();
+ const Math::Vec3<float> 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<u32>(input));
UNIMPLEMENTED();