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:
@ -558,7 +558,7 @@ void VertexManagerBase::Flush()
|
||||
pixel_shader_manager.constants.time_ms = seconds_elapsed * 1000;
|
||||
}
|
||||
|
||||
CalculateBinormals(VertexLoaderManager::GetCurrentVertexFormat());
|
||||
CalculateNormals(VertexLoaderManager::GetCurrentVertexFormat());
|
||||
// Calculate ZSlope for zfreeze
|
||||
const auto used_textures = UsedTextures();
|
||||
std::vector<std::string> texture_names;
|
||||
@ -699,6 +699,7 @@ void VertexManagerBase::DoState(PointerWrap& p)
|
||||
}
|
||||
|
||||
p.Do(m_zslope);
|
||||
p.Do(VertexLoaderManager::normal_cache);
|
||||
p.Do(VertexLoaderManager::tangent_cache);
|
||||
p.Do(VertexLoaderManager::binormal_cache);
|
||||
}
|
||||
@ -769,7 +770,7 @@ void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format)
|
||||
m_zslope.dirty = true;
|
||||
}
|
||||
|
||||
void VertexManagerBase::CalculateBinormals(NativeVertexFormat* format)
|
||||
void VertexManagerBase::CalculateNormals(NativeVertexFormat* format)
|
||||
{
|
||||
const PortableVertexDeclaration vert_decl = format->GetVertexDeclaration();
|
||||
|
||||
@ -794,6 +795,16 @@ void VertexManagerBase::CalculateBinormals(NativeVertexFormat* format)
|
||||
vertex_shader_manager.constants.cached_binormal = VertexLoaderManager::binormal_cache;
|
||||
vertex_shader_manager.dirty = true;
|
||||
}
|
||||
|
||||
if (vert_decl.normals[0].enable)
|
||||
return;
|
||||
|
||||
VertexLoaderManager::normal_cache[3] = 0;
|
||||
if (vertex_shader_manager.constants.cached_normal != VertexLoaderManager::normal_cache)
|
||||
{
|
||||
vertex_shader_manager.constants.cached_normal = VertexLoaderManager::normal_cache;
|
||||
vertex_shader_manager.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void VertexManagerBase::UpdatePipelineConfig()
|
||||
|
Reference in New Issue
Block a user