summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar wwylele2017-08-18 16:35:11 +0300
committerGravatar wwylele2017-08-22 09:34:44 +0300
commitb5aa5703540adceb1fc867b577dad50388a47e15 (patch)
tree54d9ba0c58d0d272c0e8201c8b8ed6346840561a /src
parentSwRasterizer/Lighting: implement bump mapping (diff)
downloadyuzu-b5aa5703540adceb1fc867b577dad50388a47e15.tar.gz
yuzu-b5aa5703540adceb1fc867b577dad50388a47e15.tar.xz
yuzu-b5aa5703540adceb1fc867b577dad50388a47e15.zip
SwRasterizer/Lighting: implement LUT input CP
Diffstat (limited to 'src')
-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(
52 52
53 // Use the normalized the quaternion when performing the rotation 53 // Use the normalized the quaternion when performing the rotation
54 auto normal = Math::QuaternionRotate(normquat, surface_normal); 54 auto normal = Math::QuaternionRotate(normquat, surface_normal);
55 auto tangent = Math::QuaternionRotate(normquat, surface_tangent);
55 56
56 Math::Vec4<float> diffuse_sum = {0.0f, 0.0f, 0.0f, 1.0f}; 57 Math::Vec4<float> diffuse_sum = {0.0f, 0.0f, 0.0f, 1.0f};
57 Math::Vec4<float> specular_sum = {0.0f, 0.0f, 0.0f, 1.0f}; 58 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(
120 result = Math::Dot(light_vector, spot_dir.Cast<float>() / 2047.0f); 121 result = Math::Dot(light_vector, spot_dir.Cast<float>() / 2047.0f);
121 break; 122 break;
122 } 123 }
124 case LightingRegs::LightingLutInput::CP:
125 if (lighting.config0.config == LightingRegs::LightingConfig::Config7) {
126 const Math::Vec3<float> norm_half_vector = half_vector.Normalized();
127 const Math::Vec3<float> half_vector_proj =
128 norm_half_vector - normal * Math::Dot(normal, norm_half_vector);
129 result = Math::Dot(half_vector_proj, tangent);
130 } else {
131 result = 0.0f;
132 }
133 break;
123 default: 134 default:
124 LOG_CRITICAL(HW_GPU, "Unknown lighting LUT input %u\n", static_cast<u32>(input)); 135 LOG_CRITICAL(HW_GPU, "Unknown lighting LUT input %u\n", static_cast<u32>(input));
125 UNIMPLEMENTED(); 136 UNIMPLEMENTED();