summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexShaderManager.cpp
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2017-01-29 22:38:48 +1000
committerPokechu22 <Pokechu022@gmail.com>2020-11-20 15:54:04 -0800
commit51724c1ccdbc141b1aed67a2efc952e884cadd35 (patch)
tree5dfc0c64dc693141ed34291e714c448dbf4a6c6b /Source/Core/VideoCommon/VertexShaderManager.cpp
parentfa73b1a23f9b0c5104909de410f9ae533cbf8af4 (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/VertexShaderManager.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexShaderManager.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp
index aa57161d71..04cb3b2f6f 100644
--- a/Source/Core/VideoCommon/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexShaderManager.cpp
@@ -452,7 +452,6 @@ void VertexShaderManager::SetConstants()
constants.xfmem_pack1[i][3] = xfmem.alpha[i].hex;
}
constants.xfmem_numColorChans = xfmem.numChan.numColorChans;
-
dirty = true;
}
}
@@ -617,6 +616,17 @@ void VertexShaderManager::SetVertexFormat(u32 components)
constants.components = components;
dirty = true;
}
+
+ // The default alpha channel seems to depend on the number of components in the vertex format.
+ // If the vertex attribute has an alpha channel, zero is used, otherwise one.
+ const u32 color_chan_alpha =
+ (g_main_cp_state.vtx_attr[g_main_cp_state.last_id].g0.Color0Elements ^ 1) |
+ ((g_main_cp_state.vtx_attr[g_main_cp_state.last_id].g0.Color1Elements ^ 1) << 1);
+ if (color_chan_alpha != constants.color_chan_alpha)
+ {
+ constants.color_chan_alpha = color_chan_alpha;
+ dirty = true;
+ }
}
void VertexShaderManager::SetTexMatrixInfoChanged(int index)