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:
Pokechu22
2024-09-24 23:46:45 -07:00
parent 35ec2e97a8
commit 937bb2aa2e
15 changed files with 140 additions and 83 deletions

View File

@ -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<float>(&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();