From 937bb2aa2e12b635ba328af8de7c9a5d5963d084 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 24 Sep 2024 23:46:45 -0700 Subject: Cache normals in addition to binormals and tangents Fixes LIT (https://bugs.dolphin-emu.org/issues/13635). The text does not include normals, but has lighting enabled. With the previous default of (0, 0, 0), lighting was always black (as dot(X, (0, 0, 0)) is always 0). It seems like the normal from the map in the background (0, 0, 1) is re-used. LIT also has the vertex color enabled while vertex color is not specified, the same as SMS's debug cubes; the default MissingColorValue GameINI value of solid white seems to work correctly in this case. --- Source/Core/VideoCommon/VertexLoaderBase.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Source/Core/VideoCommon/VertexLoaderBase.cpp') diff --git a/Source/Core/VideoCommon/VertexLoaderBase.cpp b/Source/Core/VideoCommon/VertexLoaderBase.cpp index 3284a2ccdb..a3597b53e5 100644 --- a/Source/Core/VideoCommon/VertexLoaderBase.cpp +++ b/Source/Core/VideoCommon/VertexLoaderBase.cpp @@ -68,6 +68,7 @@ public: VertexLoaderManager::position_matrix_index_cache; const std::array, 3> old_position_cache = VertexLoaderManager::position_cache; + const std::array old_normal_cache = VertexLoaderManager::normal_cache; const std::array old_tangent_cache = VertexLoaderManager::tangent_cache; const std::array old_binormal_cache = VertexLoaderManager::binormal_cache; @@ -77,12 +78,14 @@ public: VertexLoaderManager::position_matrix_index_cache; const std::array, 3> a_position_cache = VertexLoaderManager::position_cache; + const std::array a_normal_cache = VertexLoaderManager::normal_cache; const std::array a_tangent_cache = VertexLoaderManager::tangent_cache; const std::array a_binormal_cache = VertexLoaderManager::binormal_cache; // Reset state before running b VertexLoaderManager::position_matrix_index_cache = old_position_matrix_index_cache; VertexLoaderManager::position_cache = old_position_cache; + VertexLoaderManager::normal_cache = old_normal_cache; VertexLoaderManager::tangent_cache = old_tangent_cache; VertexLoaderManager::binormal_cache = old_binormal_cache; @@ -92,6 +95,7 @@ public: VertexLoaderManager::position_matrix_index_cache; const std::array, 3> b_position_cache = VertexLoaderManager::position_cache; + const std::array b_normal_cache = VertexLoaderManager::normal_cache; const std::array b_tangent_cache = VertexLoaderManager::tangent_cache; const std::array b_binormal_cache = VertexLoaderManager::binormal_cache; @@ -140,6 +144,12 @@ public: fmt::join(b_position_cache[1], ", "), fmt::join(b_position_cache[2], ", ")); // The last element is allowed to be garbage for SIMD overwrites + ASSERT_MSG(VIDEO, + std::equal(a_normal_cache.begin(), a_normal_cache.begin() + 3, + b_normal_cache.begin(), b_normal_cache.begin() + 3, bit_equal), + "Expected matching normal caches after loading (a: {}; b: {})", + fmt::join(a_normal_cache, ", "), fmt::join(b_normal_cache, ", ")); + ASSERT_MSG(VIDEO, std::equal(a_tangent_cache.begin(), a_tangent_cache.begin() + 3, b_tangent_cache.begin(), b_tangent_cache.begin() + 3, bit_equal), -- cgit v1.2.3