From 51724c1ccdbc141b1aed67a2efc952e884cadd35 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 29 Jan 2017 22:38:48 +1000 Subject: 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. --- Source/Core/VideoCommon/PixelShaderGen.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp') 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 -- cgit v1.2.3