summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2022-04-22 12:50:44 -0700
committerPokechu22 <Pokechu022@gmail.com>2022-04-22 16:54:36 -0700
commit04fdadd9d5f9588055fb54571410febfa710b86d (patch)
tree556444ad28b1c72d71364539a1f69722420ac50a /Source/Core
parent88134a6786b102dbb9b473fa42d748ae9c64af91 (diff)
VideoCommon: Rename norm0/norm1/norm2 to normal/tangent/binormal
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp5
-rw-r--r--Source/Core/VideoBackends/D3D12/DX12VertexFormat.cpp3
-rw-r--r--Source/Core/VideoBackends/OGL/OGLNativeVertexFormat.cpp2
-rw-r--r--Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp6
-rw-r--r--Source/Core/VideoBackends/Software/SWVertexLoader.cpp4
-rw-r--r--Source/Core/VideoBackends/Vulkan/VKVertexFormat.cpp2
-rw-r--r--Source/Core/VideoCommon/LightingShaderGen.cpp7
-rw-r--r--Source/Core/VideoCommon/NativeVertexFormat.h7
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp2
-rw-r--r--Source/Core/VideoCommon/UberShaderVertex.cpp71
-rw-r--r--Source/Core/VideoCommon/VertexLoaderBase.cpp4
-rw-r--r--Source/Core/VideoCommon/VertexShaderGen.cpp68
-rw-r--r--Source/Core/VideoCommon/VertexShaderGen.h6
13 files changed, 96 insertions, 91 deletions
diff --git a/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp b/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp
index b7aeab512c..b4da7fc354 100644
--- a/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp
+++ b/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp
@@ -115,11 +115,12 @@ D3DVertexFormat::D3DVertexFormat(const PortableVertexDeclaration& vtx_decl)
for (int i = 0; i < 3; i++)
{
+ static constexpr std::array<const char*, 3> NAMES = {"NORMAL", "TANGENT", "BINORMAL"};
format = &vtx_decl.normals[i];
if (format->enable)
{
- m_elems[m_num_elems].SemanticName = "NORMAL";
- m_elems[m_num_elems].SemanticIndex = i;
+ m_elems[m_num_elems].SemanticName = NAMES[i];
+ m_elems[m_num_elems].SemanticIndex = 0;
m_elems[m_num_elems].AlignedByteOffset = format->offset;
m_elems[m_num_elems].Format = VarToD3D(format->type, format->components, format->integer);
m_elems[m_num_elems].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
diff --git a/Source/Core/VideoBackends/D3D12/DX12VertexFormat.cpp b/Source/Core/VideoBackends/D3D12/DX12VertexFormat.cpp
index bd818d1a66..2d1a3028e0 100644
--- a/Source/Core/VideoBackends/D3D12/DX12VertexFormat.cpp
+++ b/Source/Core/VideoBackends/D3D12/DX12VertexFormat.cpp
@@ -92,7 +92,8 @@ void DXVertexFormat::MapAttributes()
{
if (m_decl.normals[i].enable)
{
- AddAttribute("NORMAL", i, 0,
+ static constexpr std::array<const char*, 3> NAMES = {"NORMAL", "TANGENT", "BINORMAL"};
+ AddAttribute(NAMES[i], 0, 0,
VarToDXGIFormat(m_decl.normals[i].type, m_decl.normals[i].components,
m_decl.normals[i].integer),
m_decl.normals[i].offset);
diff --git a/Source/Core/VideoBackends/OGL/OGLNativeVertexFormat.cpp b/Source/Core/VideoBackends/OGL/OGLNativeVertexFormat.cpp
index d21a40ebc1..1913b6dcd3 100644
--- a/Source/Core/VideoBackends/OGL/OGLNativeVertexFormat.cpp
+++ b/Source/Core/VideoBackends/OGL/OGLNativeVertexFormat.cpp
@@ -68,7 +68,7 @@ GLVertexFormat::GLVertexFormat(const PortableVertexDeclaration& vtx_decl)
SetPointer(SHADER_POSITION_ATTRIB, vertex_stride, vtx_decl.position);
for (int i = 0; i < 3; i++)
- SetPointer(SHADER_NORM0_ATTRIB + i, vertex_stride, vtx_decl.normals[i]);
+ SetPointer(SHADER_NORMAL_ATTRIB + i, vertex_stride, vtx_decl.normals[i]);
for (int i = 0; i < 2; i++)
SetPointer(SHADER_COLOR0_ATTRIB + i, vertex_stride, vtx_decl.colors[i]);
diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
index 659882d015..817f894296 100644
--- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
+++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
@@ -139,9 +139,9 @@ void SHADER::SetProgramBindings(bool is_compute)
glBindAttribLocation(glprogid, SHADER_COLOR0_ATTRIB, "rawcolor0");
glBindAttribLocation(glprogid, SHADER_COLOR1_ATTRIB, "rawcolor1");
- glBindAttribLocation(glprogid, SHADER_NORM0_ATTRIB, "rawnorm0");
- glBindAttribLocation(glprogid, SHADER_NORM1_ATTRIB, "rawnorm1");
- glBindAttribLocation(glprogid, SHADER_NORM2_ATTRIB, "rawnorm2");
+ glBindAttribLocation(glprogid, SHADER_NORMAL_ATTRIB, "rawnormal");
+ glBindAttribLocation(glprogid, SHADER_TANGENT_ATTRIB, "rawtangent");
+ glBindAttribLocation(glprogid, SHADER_BINORMAL_ATTRIB, "rawbinormal");
}
for (int i = 0; i < 8; i++)
diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp
index 287fcf4a4b..7d9b64f01d 100644
--- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp
+++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp
@@ -89,10 +89,10 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_
OutputVertexData* outVertex = m_setup_unit.GetVertex();
TransformUnit::TransformPosition(&m_vertex, outVertex);
outVertex->normal = {};
- if (VertexLoaderManager::g_current_components & VB_HAS_NRM0)
+ if (VertexLoaderManager::g_current_components & VB_HAS_NORMAL)
{
TransformUnit::TransformNormal(
- &m_vertex, (VertexLoaderManager::g_current_components & VB_HAS_NRM2) != 0, outVertex);
+ &m_vertex, (VertexLoaderManager::g_current_components & VB_HAS_BINORMAL) != 0, outVertex);
}
TransformUnit::TransformColor(&m_vertex, outVertex);
TransformUnit::TransformTexCoord(&m_vertex, outVertex);
diff --git a/Source/Core/VideoBackends/Vulkan/VKVertexFormat.cpp b/Source/Core/VideoBackends/Vulkan/VKVertexFormat.cpp
index 5f53547066..6aa5ea14f1 100644
--- a/Source/Core/VideoBackends/Vulkan/VKVertexFormat.cpp
+++ b/Source/Core/VideoBackends/Vulkan/VKVertexFormat.cpp
@@ -73,7 +73,7 @@ void VertexFormat::MapAttributes()
for (uint32_t i = 0; i < 3; i++)
{
if (m_decl.normals[i].enable)
- AddAttribute(SHADER_NORM0_ATTRIB + i, 0,
+ AddAttribute(SHADER_NORMAL_ATTRIB + i, 0,
VarToVkFormat(m_decl.normals[i].type, m_decl.normals[i].components,
m_decl.normals[i].integer),
m_decl.normals[i].offset);
diff --git a/Source/Core/VideoCommon/LightingShaderGen.cpp b/Source/Core/VideoCommon/LightingShaderGen.cpp
index a9ff3119bc..5b34e3c89f 100644
--- a/Source/Core/VideoCommon/LightingShaderGen.cpp
+++ b/Source/Core/VideoCommon/LightingShaderGen.cpp
@@ -27,11 +27,11 @@ static void GenerateLightShader(ShaderCode& object, const LightingUidData& uid_d
case AttenuationFunc::Dir:
object.Write("ldir = normalize(" LIGHT_POS ".xyz - pos.xyz);\n", LIGHT_POS_PARAMS(index));
object.Write("attn = 1.0;\n");
- object.Write("if (length(ldir) == 0.0)\n\t ldir = _norm0;\n");
+ object.Write("if (length(ldir) == 0.0)\n\t ldir = _normal;\n");
break;
case AttenuationFunc::Spec:
object.Write("ldir = normalize(" LIGHT_POS ".xyz - pos.xyz);\n", LIGHT_POS_PARAMS(index));
- object.Write("attn = (dot(_norm0, ldir) >= 0.0) ? max(0.0, dot(_norm0, " LIGHT_DIR
+ object.Write("attn = (dot(_normal, ldir) >= 0.0) ? max(0.0, dot(_normal, " LIGHT_DIR
".xyz)) : 0.0;\n",
LIGHT_DIR_PARAMS(index));
object.Write("cosAttn = " LIGHT_COSATT ".xyz;\n", LIGHT_COSATT_PARAMS(index));
@@ -64,7 +64,8 @@ static void GenerateLightShader(ShaderCode& object, const LightingUidData& uid_d
break;
case DiffuseFunc::Sign:
case DiffuseFunc::Clamp:
- object.Write("lacc.{} += int{}(round(attn * {}dot(ldir, _norm0)) * float{}(" LIGHT_COL ")));\n",
+ object.Write("lacc.{} += int{}(round(attn * {}dot(ldir, _normal)) * float{}(" LIGHT_COL
+ ")));\n",
swizzle, swizzle_components, diffusefunc != DiffuseFunc::Sign ? "max(0.0," : "(",
swizzle_components, LIGHT_COL_PARAMS(index, swizzle));
break;
diff --git a/Source/Core/VideoCommon/NativeVertexFormat.h b/Source/Core/VideoCommon/NativeVertexFormat.h
index 7bbf0bd38c..94dc1a0fa2 100644
--- a/Source/Core/VideoCommon/NativeVertexFormat.h
+++ b/Source/Core/VideoCommon/NativeVertexFormat.h
@@ -25,10 +25,9 @@ enum
VB_HAS_TEXMTXIDXALL = (0xff << 2),
// VB_HAS_POS=0, // Implied, it always has pos! don't bother testing
- VB_HAS_NRM0 = (1 << 10),
- VB_HAS_NRM1 = (1 << 11),
- VB_HAS_NRM2 = (1 << 12),
- VB_HAS_NRMALL = (7 << 10),
+ VB_HAS_NORMAL = (1 << 10),
+ VB_HAS_TANGENT = (1 << 11),
+ VB_HAS_BINORMAL = (1 << 12),
VB_COL_SHIFT = 13,
VB_HAS_COL0 = (1 << 13),
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index 837001c118..82de68a290 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -1132,7 +1132,7 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
if (per_pixel_lighting)
{
- out.Write("\tfloat3 _norm0 = normalize(Normal.xyz);\n\n"
+ out.Write("\tfloat3 _normal = normalize(Normal.xyz);\n\n"
"\tfloat3 pos = WorldPos;\n");
out.Write("\tint4 lacc;\n"
diff --git a/Source/Core/VideoCommon/UberShaderVertex.cpp b/Source/Core/VideoCommon/UberShaderVertex.cpp
index b21798b6f9..91568a4cec 100644
--- a/Source/Core/VideoCommon/UberShaderVertex.cpp
+++ b/Source/Core/VideoCommon/UberShaderVertex.cpp
@@ -57,9 +57,9 @@ ShaderCode GenVertexShader(APIType api_type, const ShaderHostConfig& host_config
{
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawpos;\n", SHADER_POSITION_ATTRIB);
out.Write("ATTRIBUTE_LOCATION({}) in uint4 posmtx;\n", SHADER_POSMTX_ATTRIB);
- out.Write("ATTRIBUTE_LOCATION({}) in float3 rawnorm0;\n", SHADER_NORM0_ATTRIB);
- out.Write("ATTRIBUTE_LOCATION({}) in float3 rawnorm1;\n", SHADER_NORM1_ATTRIB);
- out.Write("ATTRIBUTE_LOCATION({}) in float3 rawnorm2;\n", SHADER_NORM2_ATTRIB);
+ out.Write("ATTRIBUTE_LOCATION({}) in float3 rawnormal;\n", SHADER_NORMAL_ATTRIB);
+ out.Write("ATTRIBUTE_LOCATION({}) in float3 rawtangent;\n", SHADER_TANGENT_ATTRIB);
+ out.Write("ATTRIBUTE_LOCATION({}) in float3 rawbinormal;\n", SHADER_BINORMAL_ATTRIB);
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawcolor0;\n", SHADER_COLOR0_ATTRIB);
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawcolor1;\n", SHADER_COLOR1_ATTRIB);
for (int i = 0; i < 8; ++i)
@@ -106,9 +106,9 @@ ShaderCode GenVertexShader(APIType api_type, const ShaderHostConfig& host_config
out.Write("VS_OUTPUT main(\n");
// inputs
- out.Write(" float3 rawnorm0 : NORMAL0,\n"
- " float3 rawnorm1 : NORMAL1,\n"
- " float3 rawnorm2 : NORMAL2,\n"
+ out.Write(" float3 rawnormal : NORMAL,\n"
+ " float3 rawtangent : TANGENT,\n"
+ " float3 rawbinormal : BINORMAL,\n"
" float4 rawcolor0 : COLOR0,\n"
" float4 rawcolor1 : COLOR1,\n");
for (int i = 0; i < 8; ++i)
@@ -131,7 +131,7 @@ ShaderCode GenVertexShader(APIType api_type, const ShaderHostConfig& host_config
"float3 N1;\n"
"float3 N2;\n"
"\n"
- "if ((components & {}u) != 0u) {{// VB_HAS_POSMTXIDX\n",
+ "if ((components & {}u) != 0u) {{ // VB_HAS_POSMTXIDX\n",
VB_HAS_POSMTXIDX);
out.Write(" // Vertex format has a per-vertex matrix\n"
" int posidx = int(posmtx.r);\n"
@@ -159,21 +159,22 @@ ShaderCode GenVertexShader(APIType api_type, const ShaderHostConfig& host_config
"[1], pos), dot(" I_PROJECTION "[2], pos), dot(" I_PROJECTION "[3], pos));\n"
"\n"
"// Only the first normal gets normalized (TODO: why?)\n"
- "float3 _norm0 = float3(0.0, 0.0, 0.0);\n"
- "if ((components & {}u) != 0u) // VB_HAS_NRM0\n",
- VB_HAS_NRM0);
- out.Write(
- " _norm0 = normalize(float3(dot(N0, rawnorm0), dot(N1, rawnorm0), dot(N2, rawnorm0)));\n"
- "\n"
- "float3 _norm1 = float3(0.0, 0.0, 0.0);\n"
- "if ((components & {}u) != 0u) // VB_HAS_NRM1\n",
- VB_HAS_NRM1);
- out.Write(" _norm1 = float3(dot(N0, rawnorm1), dot(N1, rawnorm1), dot(N2, rawnorm1));\n"
+ "float3 _normal = float3(0.0, 0.0, 0.0);\n"
+ "if ((components & {}u) != 0u) // VB_HAS_NORMAL\n",
+ VB_HAS_NORMAL);
+ out.Write(" _normal = normalize(float3(dot(N0, rawnormal), dot(N1, rawnormal), dot(N2, "
+ "rawnormal)));\n"
+ "\n"
+ "float3 _tangent = float3(0.0, 0.0, 0.0);\n"
+ "if ((components & {}u) != 0u) // VB_HAS_TANGENT\n",
+ VB_HAS_TANGENT);
+ out.Write(" _tangent = float3(dot(N0, rawtangent), dot(N1, rawtangent), dot(N2, rawtangent));\n"
"\n"
- "float3 _norm2 = float3(0.0, 0.0, 0.0);\n"
- "if ((components & {}u) != 0u) // VB_HAS_NRM2\n",
- VB_HAS_NRM2);
- out.Write(" _norm2 = float3(dot(N0, rawnorm2), dot(N1, rawnorm2), dot(N2, rawnorm2));\n"
+ "float3 _binormal = float3(0.0, 0.0, 0.0);\n"
+ "if ((components & {}u) != 0u) // VB_HAS_BINORMAL\n",
+ VB_HAS_BINORMAL);
+ out.Write(" _binormal = float3(dot(N0, rawbinormal), dot(N1, rawbinormal), dot(N2, "
+ "rawbinormal));\n"
"\n");
// Hardware Lighting
@@ -209,7 +210,7 @@ ShaderCode GenVertexShader(APIType api_type, const ShaderHostConfig& host_config
"}}\n"
"\n");
- WriteVertexLighting(out, api_type, "pos.xyz", "_norm0", "vertex_color_0", "vertex_color_1",
+ WriteVertexLighting(out, api_type, "pos.xyz", "_normal", "vertex_color_0", "vertex_color_1",
"o.colors_0", "o.colors_1");
// Texture Coordinates
@@ -247,7 +248,7 @@ ShaderCode GenVertexShader(APIType api_type, const ShaderHostConfig& host_config
if (per_pixel_lighting)
{
- out.Write("o.Normal = _norm0;\n"
+ out.Write("o.Normal = _normal;\n"
"o.WorldPos = pos.xyz;\n");
}
@@ -394,19 +395,19 @@ static void GenVertexShaderTexGens(APIType api_type, u32 num_texgen, ShaderCode&
out.Write(" coord.xyz = rawpos.xyz;\n");
out.Write(" break;\n\n");
out.Write(" case {:s}:\n", SourceRow::Normal);
- out.Write(
- " coord.xyz = ((components & {}u /* VB_HAS_NRM0 */) != 0u) ? rawnorm0.xyz : coord.xyz;",
- VB_HAS_NRM0);
+ out.Write(" coord.xyz = ((components & {}u /* VB_HAS_NORMAL */) != 0u) ? rawnormal.xyz : "
+ "coord.xyz;",
+ VB_HAS_NORMAL);
out.Write(" break;\n\n");
out.Write(" case {:s}:\n", SourceRow::BinormalT);
- out.Write(
- " coord.xyz = ((components & {}u /* VB_HAS_NRM1 */) != 0u) ? rawnorm1.xyz : coord.xyz;",
- VB_HAS_NRM1);
+ out.Write(" coord.xyz = ((components & {}u /* VB_HAS_TANGENT */) != 0u) ? rawtangent.xyz : "
+ "coord.xyz;",
+ VB_HAS_TANGENT);
out.Write(" break;\n\n");
out.Write(" case {:s}:\n", SourceRow::BinormalB);
- out.Write(
- " coord.xyz = ((components & {}u /* VB_HAS_NRM2 */) != 0u) ? rawnorm2.xyz : coord.xyz;",
- VB_HAS_NRM2);
+ out.Write(" coord.xyz = ((components & {}u /* VB_HAS_BINORMAL */) != 0u) ? rawbinormal.xyz : "
+ "coord.xyz;",
+ VB_HAS_BINORMAL);
out.Write(" break;\n\n");
for (u32 i = 0; i < 8; i++)
{
@@ -449,10 +450,10 @@ static void GenVertexShaderTexGens(APIType api_type, u32 num_texgen, ShaderCode&
out.Write(" case {}u: output_tex.xyz = o.tex{}; break;\n", i, i);
out.Write(" default: output_tex.xyz = float3(0.0, 0.0, 0.0); break;\n"
" }}\n");
- out.Write(" if ((components & {}u) != 0u) {{ // VB_HAS_NRM1 | VB_HAS_NRM2\n",
- VB_HAS_NRM1 | VB_HAS_NRM2); // Should this be VB_HAS_NRM1 | VB_HAS_NRM2
+ out.Write(" if ((components & {}u) != 0u) {{ // VB_HAS_TANGENT | VB_HAS_BINORMAL\n",
+ VB_HAS_TANGENT | VB_HAS_BINORMAL);
out.Write(" float3 ldir = normalize(" I_LIGHTS "[light].pos.xyz - pos.xyz);\n"
- " output_tex.xyz += float3(dot(ldir, _norm1), dot(ldir, _norm2), 0.0);\n"
+ " output_tex.xyz += float3(dot(ldir, _tangent), dot(ldir, _binormal), 0.0);\n"
" }}\n"
" }}\n"
" break;\n\n");
diff --git a/Source/Core/VideoCommon/VertexLoaderBase.cpp b/Source/Core/VideoCommon/VertexLoaderBase.cpp
index 12f33bf038..2b6c3cdd21 100644
--- a/Source/Core/VideoCommon/VertexLoaderBase.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderBase.cpp
@@ -151,9 +151,9 @@ u32 VertexLoaderBase::GetVertexComponents(const TVtxDesc& vtx_desc, const VAT& v
// Vertices always have positions; thus there is no VB_HAS_POS as it would always be set
if (vtx_desc.low.Normal != VertexComponentFormat::NotPresent)
{
- components |= VB_HAS_NRM0;
+ components |= VB_HAS_NORMAL;
if (vtx_attr.g0.NormalElements == NormalComponentCount::NBT)
- components |= VB_HAS_NRM1 | VB_HAS_NRM2;
+ components |= VB_HAS_TANGENT | VB_HAS_BINORMAL;
}
for (u32 i = 0; i < vtx_desc.low.Color.Size(); i++)
{
diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp
index b00c8017e1..50ef13a9d7 100644
--- a/Source/Core/VideoCommon/VertexShaderGen.cpp
+++ b/Source/Core/VideoCommon/VertexShaderGen.cpp
@@ -39,7 +39,7 @@ VertexShaderUid GetVertexShaderUid()
switch (texinfo.texgentype)
{
case TexGenType::EmbossMap: // calculate tex coords into bump map
- if ((uid_data->components & (VB_HAS_NRM1 | VB_HAS_NRM2)) != 0)
+ if ((uid_data->components & (VB_HAS_TANGENT | VB_HAS_BINORMAL)) != 0)
{
// transform the light dir into tangent space
texinfo.embosslightshift = xfmem.texMtxInfo[i].embosslightshift;
@@ -105,12 +105,12 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawpos;\n", SHADER_POSITION_ATTRIB);
if ((uid_data->components & VB_HAS_POSMTXIDX) != 0)
out.Write("ATTRIBUTE_LOCATION({}) in uint4 posmtx;\n", SHADER_POSMTX_ATTRIB);
- if ((uid_data->components & VB_HAS_NRM0) != 0)
- out.Write("ATTRIBUTE_LOCATION({}) in float3 rawnorm0;\n", SHADER_NORM0_ATTRIB);
- if ((uid_data->components & VB_HAS_NRM1) != 0)
- out.Write("ATTRIBUTE_LOCATION({}) in float3 rawnorm1;\n", SHADER_NORM1_ATTRIB);
- if ((uid_data->components & VB_HAS_NRM2) != 0)
- out.Write("ATTRIBUTE_LOCATION({}) in float3 rawnorm2;\n", SHADER_NORM2_ATTRIB);
+ if ((uid_data->components & VB_HAS_NORMAL) != 0)
+ out.Write("ATTRIBUTE_LOCATION({}) in float3 rawnormal;\n", SHADER_NORMAL_ATTRIB);
+ if ((uid_data->components & VB_HAS_TANGENT) != 0)
+ out.Write("ATTRIBUTE_LOCATION({}) in float3 rawtangent;\n", SHADER_TANGENT_ATTRIB);
+ if ((uid_data->components & VB_HAS_BINORMAL) != 0)
+ out.Write("ATTRIBUTE_LOCATION({}) in float3 rawbinormal;\n", SHADER_BINORMAL_ATTRIB);
if ((uid_data->components & VB_HAS_COL0) != 0)
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawcolor0;\n", SHADER_COLOR0_ATTRIB);
@@ -169,12 +169,12 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
out.Write("VS_OUTPUT main(\n");
// inputs
- if ((uid_data->components & VB_HAS_NRM0) != 0)
- out.Write(" float3 rawnorm0 : NORMAL0,\n");
- if ((uid_data->components & VB_HAS_NRM1) != 0)
- out.Write(" float3 rawnorm1 : NORMAL1,\n");
- if ((uid_data->components & VB_HAS_NRM2) != 0)
- out.Write(" float3 rawnorm2 : NORMAL2,\n");
+ if ((uid_data->components & VB_HAS_NORMAL) != 0)
+ out.Write(" float3 rawnormal : NORMAL,\n");
+ if ((uid_data->components & VB_HAS_TANGENT) != 0)
+ out.Write(" float3 rawtangent : TANGENT,\n");
+ if ((uid_data->components & VB_HAS_BINORMAL) != 0)
+ out.Write(" float3 rawbinormal : BINORMAL,\n");
if ((uid_data->components & VB_HAS_COL0) != 0)
out.Write(" float4 rawcolor0 : COLOR0,\n");
if ((uid_data->components & VB_HAS_COL1) != 0)
@@ -227,7 +227,7 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
"float4 P0 = " I_TRANSFORMMATRICES "[posidx];\n"
"float4 P1 = " I_TRANSFORMMATRICES "[posidx + 1];\n"
"float4 P2 = " I_TRANSFORMMATRICES "[posidx + 2];\n");
- if ((uid_data->components & VB_HAS_NRMALL) != 0)
+ if ((uid_data->components & VB_HAS_NORMAL) != 0)
{
out.Write("int normidx = posidx & 31;\n"
"float3 N0 = " I_NORMALMATRICES "[normidx].xyz;\n"
@@ -241,7 +241,7 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
out.Write("float4 P0 = " I_POSNORMALMATRIX "[0];\n"
"float4 P1 = " I_POSNORMALMATRIX "[1];\n"
"float4 P2 = " I_POSNORMALMATRIX "[2];\n");
- if ((uid_data->components & VB_HAS_NRMALL) != 0)
+ if ((uid_data->components & VB_HAS_NORMAL) != 0)
{
out.Write("float3 N0 = " I_POSNORMALMATRIX "[3].xyz;\n"
"float3 N1 = " I_POSNORMALMATRIX "[4].xyz;\n"
@@ -251,23 +251,25 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
out.Write("// Multiply the position vector by the position matrix\n"
"float4 pos = float4(dot(P0, rawpos), dot(P1, rawpos), dot(P2, rawpos), 1.0);\n");
- if ((uid_data->components & VB_HAS_NRM0) != 0)
+ if ((uid_data->components & VB_HAS_NORMAL) != 0)
{
// Only the first normal gets normalized (TODO: why?)
- out.Write("float3 _norm0 = normalize(float3(dot(N0, rawnorm0), dot(N1, rawnorm0), dot(N2, "
- "rawnorm0)));\n");
+ out.Write("float3 _normal = normalize(float3(dot(N0, rawnormal), dot(N1, rawnormal), dot(N2, "
+ "rawnormal)));\n");
}
else
{
- out.Write("float3 _norm0 = float3(0.0, 0.0, 0.0);\n");
+ out.Write("float3 _normal = float3(0.0, 0.0, 0.0);\n");
}
- if ((uid_data->components & VB_HAS_NRM1) != 0)
+ if ((uid_data->components & VB_HAS_TANGENT) != 0)
{
- out.Write("float3 _norm1 = float3(dot(N0, rawnorm1), dot(N1, rawnorm1), dot(N2, rawnorm1));\n");
+ out.Write("float3 _tangent = float3(dot(N0, rawtangent), dot(N1, rawtangent), dot(N2, "
+ "rawtangent));\n");
}
- if ((uid_data->components & VB_HAS_NRM2) != 0)
+ if ((uid_data->components & VB_HAS_BINORMAL) != 0)
{
- out.Write("float3 _norm2 = float3(dot(N0, rawnorm2), dot(N1, rawnorm2), dot(N2, rawnorm2));\n");
+ out.Write("float3 _binormal = float3(dot(N0, rawbinormal), dot(N1, rawbinormal), dot(N2, "
+ "rawbinormal));\n");
}
out.Write("o.pos = float4(dot(" I_PROJECTION "[0], pos), dot(" I_PROJECTION
@@ -293,24 +295,24 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
out.Write("coord.xyz = rawpos.xyz;\n");
break;
case SourceRow::Normal:
- if ((uid_data->components & VB_HAS_NRM0) != 0)
+ if ((uid_data->components & VB_HAS_NORMAL) != 0)
{
- out.Write("coord.xyz = rawnorm0.xyz;\n");
+ out.Write("coord.xyz = rawnormal.xyz;\n");
}
break;
case SourceRow::Colors:
ASSERT(texinfo.texgentype == TexGenType::Color0 || texinfo.texgentype == TexGenType::Color1);
break;
case SourceRow::BinormalT:
- if ((uid_data->components & VB_HAS_NRM1) != 0)
+ if ((uid_data->components & VB_HAS_TANGENT) != 0)
{
- out.Write("coord.xyz = rawnorm1.xyz;\n");
+ out.Write("coord.xyz = rawtangent.xyz;\n");
}
break;
case SourceRow::BinormalB:
- if ((uid_data->components & VB_HAS_NRM2) != 0)
+ if ((uid_data->components & VB_HAS_BINORMAL) != 0)
{
- out.Write("coord.xyz = rawnorm2.xyz;\n");
+ out.Write("coord.xyz = rawbinormal.xyz;\n");
}
break;
default:
@@ -339,14 +341,14 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
{
case TexGenType::EmbossMap: // calculate tex coords into bump map
- if ((uid_data->components & (VB_HAS_NRM1 | VB_HAS_NRM2)) != 0)
+ if ((uid_data->components & (VB_HAS_TANGENT | VB_HAS_BINORMAL)) != 0)
{
// transform the light dir into tangent space
out.Write("ldir = normalize(" LIGHT_POS ".xyz - pos.xyz);\n",
LIGHT_POS_PARAMS(texinfo.embosslightshift));
out.Write(
- "o.tex{}.xyz = o.tex{}.xyz + float3(dot(ldir, _norm1), dot(ldir, _norm2), 0.0);\n", i,
- texinfo.embosssourceshift);
+ "o.tex{}.xyz = o.tex{}.xyz + float3(dot(ldir, _tangent), dot(ldir, _binormal), 0.0);\n",
+ i, texinfo.embosssourceshift);
}
else
{
@@ -464,7 +466,7 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
if (per_pixel_lighting)
{
- out.Write("o.Normal = _norm0;\n"
+ out.Write("o.Normal = _normal;\n"
"o.WorldPos = pos.xyz;\n");
}
diff --git a/Source/Core/VideoCommon/VertexShaderGen.h b/Source/Core/VideoCommon/VertexShaderGen.h
index 5f2a73848c..028404c6e8 100644
--- a/Source/Core/VideoCommon/VertexShaderGen.h
+++ b/Source/Core/VideoCommon/VertexShaderGen.h
@@ -17,9 +17,9 @@ enum : int
{
SHADER_POSITION_ATTRIB = 0,
SHADER_POSMTX_ATTRIB = 1,
- SHADER_NORM0_ATTRIB = 2,
- SHADER_NORM1_ATTRIB = 3,
- SHADER_NORM2_ATTRIB = 4,
+ SHADER_NORMAL_ATTRIB = 2,
+ SHADER_TANGENT_ATTRIB = 3,
+ SHADER_BINORMAL_ATTRIB = 4,
SHADER_COLOR0_ATTRIB = 5,
SHADER_COLOR1_ATTRIB = 6,