mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
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.
This commit is contained in:
@ -68,6 +68,7 @@ public:
|
||||
VertexLoaderManager::position_matrix_index_cache;
|
||||
const std::array<std::array<float, 4>, 3> old_position_cache =
|
||||
VertexLoaderManager::position_cache;
|
||||
const std::array<float, 4> old_normal_cache = VertexLoaderManager::normal_cache;
|
||||
const std::array<float, 4> old_tangent_cache = VertexLoaderManager::tangent_cache;
|
||||
const std::array<float, 4> old_binormal_cache = VertexLoaderManager::binormal_cache;
|
||||
|
||||
@ -77,12 +78,14 @@ public:
|
||||
VertexLoaderManager::position_matrix_index_cache;
|
||||
const std::array<std::array<float, 4>, 3> a_position_cache =
|
||||
VertexLoaderManager::position_cache;
|
||||
const std::array<float, 4> a_normal_cache = VertexLoaderManager::normal_cache;
|
||||
const std::array<float, 4> a_tangent_cache = VertexLoaderManager::tangent_cache;
|
||||
const std::array<float, 4> 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<std::array<float, 4>, 3> b_position_cache =
|
||||
VertexLoaderManager::position_cache;
|
||||
const std::array<float, 4> b_normal_cache = VertexLoaderManager::normal_cache;
|
||||
const std::array<float, 4> b_tangent_cache = VertexLoaderManager::tangent_cache;
|
||||
const std::array<float, 4> 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),
|
||||
|
Reference in New Issue
Block a user