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/VideoBackends/Software/SWVertexLoader.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoBackends/Software/SWVertexLoader.cpp') diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp index cfb05d096b..2e6e748a38 100644 --- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp +++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp @@ -81,9 +81,7 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_ // transform this vertex so that it can be used for rasterization (outVertex) OutputVertexData* outVertex = m_setup_unit.GetVertex(); TransformUnit::TransformPosition(&m_vertex, outVertex); - outVertex->normal = {}; - if (VertexLoaderManager::g_current_components & VB_HAS_NORMAL) - TransformUnit::TransformNormal(&m_vertex, outVertex); + TransformUnit::TransformNormal(&m_vertex, outVertex); TransformUnit::TransformColor(&m_vertex, outVertex); TransformUnit::TransformTexCoord(&m_vertex, outVertex); @@ -209,6 +207,14 @@ void SWVertexLoader::ParseVertex(const PortableVertexDeclaration& vdec, int inde { ReadVertexAttribute(&m_vertex.normal[i][0], src, vdec.normals[i], 0, 3, false); } + if (!vdec.normals[0].enable) + { + auto& system = Core::System::GetInstance(); + auto& vertex_shader_manager = system.GetVertexShaderManager(); + m_vertex.normal[0][0] = vertex_shader_manager.constants.cached_normal[0]; + m_vertex.normal[0][1] = vertex_shader_manager.constants.cached_normal[1]; + m_vertex.normal[0][2] = vertex_shader_manager.constants.cached_normal[2]; + } if (!vdec.normals[1].enable) { auto& system = Core::System::GetInstance(); -- cgit v1.2.3