diff options
| author | Pokechu22 <Pokechu022@gmail.com> | 2021-08-09 14:17:11 -0700 |
|---|---|---|
| committer | Pokechu22 <Pokechu022@gmail.com> | 2021-08-18 10:40:54 -0700 |
| commit | 06579e4d53844e5a45ae18f8eda6c4ee69ebad2c (patch) | |
| tree | 6d216f77e54a6ee326c9905a55021fbec3cac6a3 /Source/Core/VideoCommon/VertexShaderGen.cpp | |
| parent | 2519d14e36bf47f4ef6172928db13c5f7fae14e3 (diff) | |
VertexShaderGen: Simplify color channel logic
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderGen.cpp | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderGen.cpp b/Source/Core/VideoCommon/VertexShaderGen.cpp index 4e4121b564..8f8133de63 100644 --- a/Source/Core/VideoCommon/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/VertexShaderGen.cpp @@ -441,19 +441,38 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho out.Write("}}\n"); } + // The number of colors available to TEV is determined by numColorChans. + // We have to provide the fields to match the interface, so set to zero if it's not enabled. + + // When per-pixel lighting is enabled, the vertex colors are passed through unmodified so we can + // evaluate the lighting in the same manner in the pixel shader. if (uid_data->numColorChans == 0) { if ((uid_data->components & VB_HAS_COL0) != 0) - out.Write("o.colors_0 = rawcolor0;\n"); + { + if (per_pixel_lighting) + out.Write("o.colors_0 = vertex_color_0;\n"); + else + out.Write("o.colors_0 = rawcolor0;\n"); + } else - out.Write("o.colors_0 = float4(1.0, 1.0, 1.0, 1.0);\n"); + { + out.Write("o.colors_0 = float4(0.0, 0.0, 0.0, 0.0);\n"); + } } - if (uid_data->numColorChans < 2) + if (uid_data->numColorChans <= 1) { if ((uid_data->components & VB_HAS_COL1) != 0) - out.Write("o.colors_1 = rawcolor1;\n"); + { + if (per_pixel_lighting) + out.Write("o.colors_1 = vertex_color_1;\n"); + else + out.Write("o.colors_1 = rawcolor1;\n"); + } else - out.Write("o.colors_1 = o.colors_0;\n"); + { + out.Write("o.colors_1 = float4(0.0, 0.0, 0.0, 0.0);\n"); + } } // clipPos/w needs to be done in pixel shader, not here @@ -464,22 +483,6 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho { out.Write("o.Normal = _norm0;\n" "o.WorldPos = pos.xyz;\n"); - - // Pass through the vertex colors unmodified so we can evaluate the lighting in the same manner. - if ((uid_data->components & VB_HAS_COL0) != 0) - out.Write("o.colors_0 = vertex_color_0;\n"); - - if ((uid_data->components & VB_HAS_COL1) != 0) - out.Write("o.colors_1 = vertex_color_1;\n"); - } - else - { - // The number of colors available to TEV is determined by numColorChans. - // We have to provide the fields to match the interface, so set to zero if it's not enabled. - if (uid_data->numColorChans == 0) - out.Write("o.colors_0 = float4(0.0, 0.0, 0.0, 0.0);\n"); - if (uid_data->numColorChans <= 1) - out.Write("o.colors_1 = float4(0.0, 0.0, 0.0, 0.0);\n"); } // If we can disable the incorrect depth clipping planes using depth clamping, then we can do |
