summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexManagerBase.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2022-04-13 22:03:34 -0700
committerPokechu22 <Pokechu022@gmail.com>2022-04-22 16:54:38 -0700
commit2a5c77f43ff1d69e78f12f13435a38c5eb2ed854 (patch)
tree5fe9bb681e4b8d4471f7efee278c96a24556b33b /Source/Core/VideoCommon/VertexManagerBase.cpp
parent39b2854b981aadec1576254ad5e4d91dc21c9709 (diff)
VideoCommon: Handle emboss texgen with only a single normal
Fixes a large number of effects in Rogue Squadron 2 and 3.
Diffstat (limited to 'Source/Core/VideoCommon/VertexManagerBase.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index a93a9b34f1..bb23a468ea 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -453,6 +453,7 @@ void VertexManagerBase::Flush()
}
}
+ CalculateBinormals(VertexLoaderManager::GetCurrentVertexFormat());
// Calculate ZSlope for zfreeze
VertexShaderManager::SetConstants();
if (!bpmem.genMode.zfreeze)
@@ -595,6 +596,31 @@ void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format)
m_zslope.dirty = true;
}
+void VertexManagerBase::CalculateBinormals(NativeVertexFormat* format)
+{
+ const PortableVertexDeclaration vert_decl = format->GetVertexDeclaration();
+
+ // Only update the binormal/tangent vertex shader constants if the vertex format lacks binormals
+ // (VertexLoaderManager::binormal_cache gets updated by the vertex loader when binormals are
+ // present, though)
+ if (vert_decl.normals[1].enable)
+ return;
+
+ VertexLoaderManager::tangent_cache[3] = 0;
+ VertexLoaderManager::binormal_cache[3] = 0;
+
+ if (VertexShaderManager::constants.cached_tangent != VertexLoaderManager::tangent_cache)
+ {
+ VertexShaderManager::constants.cached_tangent = VertexLoaderManager::tangent_cache;
+ VertexShaderManager::dirty = true;
+ }
+ if (VertexShaderManager::constants.cached_binormal != VertexLoaderManager::binormal_cache)
+ {
+ VertexShaderManager::constants.cached_binormal = VertexLoaderManager::binormal_cache;
+ VertexShaderManager::dirty = true;
+ }
+}
+
void VertexManagerBase::UpdatePipelineConfig()
{
NativeVertexFormat* vertex_format = VertexLoaderManager::GetCurrentVertexFormat();