diff options
Diffstat (limited to 'Source/Core/VideoCommon/LightingShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/LightingShaderGen.cpp | 62 |
1 files changed, 5 insertions, 57 deletions
diff --git a/Source/Core/VideoCommon/LightingShaderGen.cpp b/Source/Core/VideoCommon/LightingShaderGen.cpp index e4b8f16716..d84ff49e4d 100644 --- a/Source/Core/VideoCommon/LightingShaderGen.cpp +++ b/Source/Core/VideoCommon/LightingShaderGen.cpp @@ -78,7 +78,7 @@ static void GenerateLightShader(ShaderCode& object, const LightingUidData& uid_d // materials name is I_MATERIALS in vs and I_PMATERIALS in ps // inColorName is color in vs and colors_ in ps // dest is o.colors_ in vs and colors_ in ps -void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data, int components, +void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data, std::string_view in_color_name, std::string_view dest) { for (u32 j = 0; j < NUM_XF_COLOR_CHANNELS; j++) @@ -87,43 +87,16 @@ void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_d const bool colormatsource = !!(uid_data.matsource & (1 << j)); if (colormatsource) // from vertex - { - if ((components & (VB_HAS_COL0 << j)) != 0) - object.Write("int4 mat = int4(round({}{} * 255.0));\n", in_color_name, j); - else if ((components & VB_HAS_COL0) != 0) - object.Write("int4 mat = int4(round({}0 * 255.0));\n", in_color_name); - else - object.Write("int4 mat = int4(255, 255, 255, 255);\n"); - } + object.Write("int4 mat = int4(round({}{} * 255.0));\n", in_color_name, j); else // from color - { object.Write("int4 mat = {}[{}];\n", I_MATERIALS, j + 2); - } if ((uid_data.enablelighting & (1 << j)) != 0) { if ((uid_data.ambsource & (1 << j)) != 0) // from vertex - { - if ((components & (VB_HAS_COL0 << j)) != 0) - { - object.Write("lacc = int4(round({}{} * 255.0));\n", in_color_name, j); - } - else if ((components & VB_HAS_COL0) != 0) - { - object.Write("lacc = int4(round({}0 * 255.0));\n", in_color_name); - } - else - { - // TODO: this isn't verified. Here we want to read the ambient from the vertex, - // but the vertex itself has no color. So we don't know which value to read. - // Returning 1.0 is the same as disabled lightning, so this could be fine - object.Write("lacc = int4(255, 255, 255, 255);\n"); - } - } + object.Write("lacc = int4(round({}{} * 255.0));\n", in_color_name, j); else // from color - { object.Write("lacc = {}[{}];\n", I_MATERIALS, j); - } } else { @@ -135,42 +108,17 @@ void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_d if (alphamatsource != colormatsource) { if (alphamatsource) // from vertex - { - if ((components & (VB_HAS_COL0 << j)) != 0) - object.Write("mat.w = int(round({}{}.w * 255.0));\n", in_color_name, j); - else if ((components & VB_HAS_COL0) != 0) - object.Write("mat.w = int(round({}0.w * 255.0));\n", in_color_name); - else - object.Write("mat.w = 255;\n"); - } + object.Write("mat.w = int(round({}{}.w * 255.0));\n", in_color_name, j); else // from color - { object.Write("mat.w = {}[{}].w;\n", I_MATERIALS, j + 2); - } } if ((uid_data.enablelighting & (1 << (j + 2))) != 0) { if ((uid_data.ambsource & (1 << (j + 2))) != 0) // from vertex - { - if ((components & (VB_HAS_COL0 << j)) != 0) - { - object.Write("lacc.w = int(round({}{}.w * 255.0));\n", in_color_name, j); - } - else if ((components & VB_HAS_COL0) != 0) - { - object.Write("lacc.w = int(round({}0.w * 255.0));\n", in_color_name); - } - else - { - // TODO: The same for alpha: We want to read from vertex, but the vertex has no color - object.Write("lacc.w = 255;\n"); - } - } + object.Write("lacc.w = int(round({}{}.w * 255.0));\n", in_color_name, j); else // from color - { object.Write("lacc.w = {}[{}].w;\n", I_MATERIALS, j); - } } else { |
