VideoCommon: Handle emboss texgen with only a single normal

Fixes a large number of effects in Rogue Squadron 2 and 3.
This commit is contained in:
Pokechu22
2022-04-13 22:03:34 -07:00
parent 39b2854b98
commit 2a5c77f43f
14 changed files with 138 additions and 62 deletions

View File

@ -25,6 +25,7 @@
#include "VideoCommon/Statistics.h"
#include "VideoCommon/VertexLoaderBase.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoConfig.h"
#include "VideoCommon/XFMemory.h"
@ -90,10 +91,7 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_
TransformUnit::TransformPosition(&m_vertex, outVertex);
outVertex->normal = {};
if (VertexLoaderManager::g_current_components & VB_HAS_NORMAL)
{
TransformUnit::TransformNormal(
&m_vertex, (VertexLoaderManager::g_current_components & VB_HAS_BINORMAL) != 0, outVertex);
}
TransformUnit::TransformNormal(&m_vertex, outVertex);
TransformUnit::TransformColor(&m_vertex, outVertex);
TransformUnit::TransformTexCoord(&m_vertex, outVertex);
@ -230,6 +228,18 @@ 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[1].enable)
{
m_vertex.normal[1][0] = VertexShaderManager::constants.cached_tangent[0];
m_vertex.normal[1][1] = VertexShaderManager::constants.cached_tangent[1];
m_vertex.normal[1][2] = VertexShaderManager::constants.cached_tangent[2];
}
if (!vdec.normals[2].enable)
{
m_vertex.normal[2][0] = VertexShaderManager::constants.cached_binormal[0];
m_vertex.normal[2][1] = VertexShaderManager::constants.cached_binormal[1];
m_vertex.normal[2][2] = VertexShaderManager::constants.cached_binormal[2];
}
ParseColorAttributes(&m_vertex, src, vdec);