diff options
| author | Stenzek <stenzek@gmail.com> | 2017-01-29 22:38:48 +1000 |
|---|---|---|
| committer | Pokechu22 <Pokechu022@gmail.com> | 2020-11-20 15:54:04 -0800 |
| commit | 51724c1ccdbc141b1aed67a2efc952e884cadd35 (patch) | |
| tree | 5dfc0c64dc693141ed34291e714c448dbf4a6c6b /Source/Core/VideoCommon/UberShaderCommon.cpp | |
| parent | fa73b1a23f9b0c5104909de410f9ae533cbf8af4 (diff) | |
LightingShaderGen: Always calculate lighting for both color channels
Cel-damage depends on lighting being calculated for the first channel
even though there is no color in the vertex format (defaults to the
material color). If lighting for the channel is not enabled, the vertex
will use the default color as before.
The default value of the color is determined by the number of elements in
the vertex format. This fixes the grey cubes in Super Mario Sunshine.
If the color channel count is zero, we set the color to black before the
end of the vertex shader. It's possible that this would be undefined
behavior on hardware if a vertex color index that was greater than the
channel count was used within TEV.
Diffstat (limited to 'Source/Core/VideoCommon/UberShaderCommon.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/UberShaderCommon.cpp | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/Source/Core/VideoCommon/UberShaderCommon.cpp b/Source/Core/VideoCommon/UberShaderCommon.cpp index afd86a6943..36403d3f5b 100644 --- a/Source/Core/VideoCommon/UberShaderCommon.cpp +++ b/Source/Core/VideoCommon/UberShaderCommon.cpp @@ -103,42 +103,23 @@ void WriteVertexLighting(ShaderCode& out, APIType api_type, std::string_view wor " int4 lacc = int4(255, 255, 255, 255);\n" "\n"); - out.Write(" if ({} != 0u) {{\n", BitfieldExtract("colorreg", LitChannel().matsource)); - out.Write(" if ((components & ({}u << chan)) != 0u) // VB_HAS_COL0\n", VB_HAS_COL0); - out.Write(" mat.xyz = int3(round(((chan == 0u) ? {}.xyz : {}.xyz) * 255.0));\n", + out.Write(" if ({} != 0u)\n", BitfieldExtract("colorreg", LitChannel().matsource)); + out.Write(" mat.xyz = int3(round(((chan == 0u) ? {}.xyz : {}.xyz) * 255.0));\n", in_color_0_var, in_color_1_var); - out.Write(" else if ((components & {}u) != 0u) // VB_HAS_COLO0\n", VB_HAS_COL0); - out.Write(" mat.xyz = int3(round({}.xyz * 255.0));\n", in_color_0_var); - out.Write(" else\n" - " mat.xyz = int3(255, 255, 255);\n" - " }}\n" - "\n"); - out.Write(" if ({} != 0u) {{\n", BitfieldExtract("alphareg", LitChannel().matsource)); - out.Write(" if ((components & ({}u << chan)) != 0u) // VB_HAS_COL0\n", VB_HAS_COL0); - out.Write(" mat.w = int(round(((chan == 0u) ? {}.w : {}.w) * 255.0));\n", in_color_0_var, + out.Write(" if ({} != 0u)\n", BitfieldExtract("alphareg", LitChannel().matsource)); + out.Write(" mat.w = int(round(((chan == 0u) ? {}.w : {}.w) * 255.0));\n", in_color_0_var, in_color_1_var); - out.Write(" else if ((components & {}u) != 0u) // VB_HAS_COLO0\n", VB_HAS_COL0); - out.Write(" mat.w = int(round({}.w * 255.0));\n", in_color_0_var); - out.Write(" else\n" - " mat.w = 255;\n" - " }} else {{\n" + out.Write(" else\n" " mat.w = " I_MATERIALS " [chan + 2u].w;\n" - " }}\n" "\n"); out.Write(" if ({} != 0u) {{\n", BitfieldExtract("colorreg", LitChannel().enablelighting)); - out.Write(" if ({} != 0u) {{\n", BitfieldExtract("colorreg", LitChannel().ambsource)); - out.Write(" if ((components & ({}u << chan)) != 0u) // VB_HAS_COL0\n", VB_HAS_COL0); - out.Write(" lacc.xyz = int3(round(((chan == 0u) ? {}.xyz : {}.xyz) * 255.0));\n", + out.Write(" if ({} != 0u)\n", BitfieldExtract("colorreg", LitChannel().ambsource)); + out.Write(" lacc.xyz = int3(round(((chan == 0u) ? {}.xyz : {}.xyz) * 255.0));\n", in_color_0_var, in_color_1_var); - out.Write(" else if ((components & {}u) != 0u) // VB_HAS_COLO0\n", VB_HAS_COL0); - out.Write(" lacc.xyz = int3(round({}.xyz * 255.0));\n", in_color_0_var); - out.Write(" else\n" - " lacc.xyz = int3(255, 255, 255);\n" - " }} else {{\n" + out.Write(" else\n" " lacc.xyz = " I_MATERIALS " [chan].xyz;\n" - " }}\n" "\n"); out.Write(" uint light_mask = {} | ({} << 4u);\n", BitfieldExtract("colorreg", LitChannel().lightMask0_3), |
