summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/PixelShaderGen.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/PixelShaderGen.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/PixelShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index b51fee3acb..30bd725cb7 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -203,9 +203,6 @@ PixelShaderUid GetPixelShaderUid()
if (g_ActiveConfig.bEnablePixelLighting)
{
- // The lighting shader only needs the two color bits of the 23bit component bit array.
- uid_data->components =
- (VertexLoaderManager::g_current_components & (VB_HAS_COL0 | VB_HAS_COL1)) >> VB_COL_SHIFT;
uid_data->numColorChans = xfmem.numChan.numColorChans;
GetLightingShaderUid(uid_data->lighting);
}
@@ -768,8 +765,11 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
// out.SetConstantsUsed(C_PLIGHT_COLORS, C_PLIGHT_COLORS+7); // TODO: Can be optimized further
// out.SetConstantsUsed(C_PLIGHTS, C_PLIGHTS+31); // TODO: Can be optimized further
// out.SetConstantsUsed(C_PMATERIALS, C_PMATERIALS+3);
- GenerateLightingShaderCode(out, uid_data->lighting, uid_data->components << VB_COL_SHIFT,
- "colors_", "col");
+ GenerateLightingShaderCode(out, uid_data->lighting, "colors_", "col");
+ if (uid_data->numColorChans == 0)
+ out.Write("col0 = float4(0.0, 0.0, 0.0, 0.0);\n");
+ if (uid_data->numColorChans <= 1)
+ out.Write("col1 = float4(0.0, 0.0, 0.0, 0.0);\n");
}
// HACK to handle cases where the tex gen is not enabled