summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2021-08-09 14:17:26 -0700
committerPokechu22 <Pokechu022@gmail.com>2021-08-18 10:40:54 -0700
commitc3dec343918ff44e90886daf71a6bf0c49033de1 (patch)
treebf1f8227b726a9e45c4ebd02eaa3ec3a89641b6b /Source/Core/VideoCommon
parent06579e4d53844e5a45ae18f8eda6c4ee69ebad2c (diff)
UberShaderVertex: Simplify color channel logic
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/UberShaderVertex.cpp51
1 files changed, 24 insertions, 27 deletions
diff --git a/Source/Core/VideoCommon/UberShaderVertex.cpp b/Source/Core/VideoCommon/UberShaderVertex.cpp
index ceafb09219..bb8732546a 100644
--- a/Source/Core/VideoCommon/UberShaderVertex.cpp
+++ b/Source/Core/VideoCommon/UberShaderVertex.cpp
@@ -214,20 +214,36 @@ ShaderCode GenVertexShader(APIType api_type, const ShaderHostConfig& host_config
if (num_texgen > 0)
GenVertexShaderTexGens(api_type, num_texgen, out);
+ out.Write("// The number of colors available to TEV is determined by numColorChans.\n"
+ "// We have to provide the fields to match the interface, so set to zero\n"
+ "// if it's not enabled.\n");
+
+ const char* color_prefix;
+ if (per_pixel_lighting)
+ {
+ out.Write("\n// Since per-pixel lighting is enabled, the vertex colors are passed through\n"
+ "// unmodified so we can evaluate the lighting in the pixel shader.\n");
+ color_prefix = "vertex_color_";
+ }
+ else
+ {
+ color_prefix = "rawcolor";
+ }
+
out.Write("if (xfmem_numColorChans == 0u) {{\n"
- " if ((components & {}u) != 0u)\n"
- " o.colors_0 = rawcolor0;\n"
+ " if ((components & {}u) != 0u) // VB_HAS_COL0\n"
+ " o.colors_0 = {}0;\n"
" else\n"
" o.colors_0 = float4(1.0, 1.0, 1.0, 1.0);\n"
"}}\n",
- VB_HAS_COL0);
- out.Write("if (xfmem_numColorChans < 2u) {{\n"
- " if ((components & {}u) != 0u)\n"
- " o.colors_1 = rawcolor1;\n"
+ VB_HAS_COL0, color_prefix);
+ out.Write("if (xfmem_numColorChans <= 1u) {{\n"
+ " if ((components & {}u) != 0u) // VB_HAS_COL1\n"
+ " o.colors_1 = {}1;\n"
" else\n"
" o.colors_1 = o.colors_0;\n"
"}}\n",
- VB_HAS_COL1);
+ VB_HAS_COL1, color_prefix);
if (!host_config.fast_depth_calc)
{
@@ -238,26 +254,7 @@ ShaderCode GenVertexShader(APIType api_type, const ShaderHostConfig& host_config
if (per_pixel_lighting)
{
out.Write("o.Normal = _norm0;\n"
- "o.WorldPos = pos.xyz;\n"
- "// Pass through the vertex colors unmodified so we can evaluate the lighting\n"
- "// in the same manner.\n");
- out.Write("if ((components & {}u) != 0u) // VB_HAS_COL0\n"
- " o.colors_0 = vertex_color_0;\n",
- VB_HAS_COL0);
- out.Write("if ((components & {}u) != 0u) // VB_HAS_COL1\n"
- " o.colors_1 = vertex_color_1;\n",
- VB_HAS_COL1);
- }
- else
- {
- out.Write("// The number of colors available to TEV is determined by numColorChans.\n"
- "// We have to provide the fields to match the interface, so set to zero\n"
- "// if it's not enabled.\n"
- "if (xfmem_numColorChans == 0u)\n"
- " o.colors_0 = float4(0.0, 0.0, 0.0, 0.0);\n"
- "if (xfmem_numColorChans <= 1u)\n"
- " o.colors_1 = float4(0.0, 0.0, 0.0, 0.0);\n"
- "\n");
+ "o.WorldPos = pos.xyz;\n");
}
// If we can disable the incorrect depth clipping planes using depth clamping, then we can do