From a7cd938ef78ca896f1048c2eb1dbb437c730b244 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 27 Feb 2022 13:58:21 -0800 Subject: [PATCH] Revert "Remove front-facing check for specular lights" This reverts commit 0b425bbb41daa1f613d99641cf8da35cc901a4a1. The patent says this exists. --- Source/Core/VideoCommon/LightingShaderGen.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Core/VideoCommon/LightingShaderGen.cpp b/Source/Core/VideoCommon/LightingShaderGen.cpp index 130fc27e31..906907bb04 100644 --- a/Source/Core/VideoCommon/LightingShaderGen.cpp +++ b/Source/Core/VideoCommon/LightingShaderGen.cpp @@ -41,12 +41,15 @@ static void GenerateLightShader(ShaderCode& object, const LightingUidData& uid_d break; case AttenuationFunc::Spec: object.Write(" float cosine = 0.0;\n" - " // Compute the cosine of the angle between the object normal\n" - " // and the half-angle direction for the viewer\n" - " // (assuming the half-angle direction is a unit vector)\n" - " cosine = max(0.0, dot(_normal, " LIGHT_DIR ".xyz));\n", + " // Ensure that the object is facing the light\n" + " if (dot(_normal, ldir) >= 0.0) {{\n" + " // Compute the cosine of the angle between the object normal\n" + " // and the half-angle direction for the viewer\n" + " // (assuming the half-angle direction is a unit vector)\n" + " cosine = max(0.0, dot(_normal, " LIGHT_DIR ".xyz));\n", LIGHT_DIR_PARAMS(index)); - object.Write(" // Specular lights use the angle for the denominator as well\n" + object.Write(" }}\n" + " // Specular lights use the angle for the denominator as well\n" " dist = cosine;\n" " dist2 = dist * dist;\n"); break;