diff --git a/hecl/lib/Backend/GLSL.cpp b/hecl/lib/Backend/GLSL.cpp index 65431f2c9..2484a7621 100644 --- a/hecl/lib/Backend/GLSL.cpp +++ b/hecl/lib/Backend/GLSL.cpp @@ -198,6 +198,7 @@ std::string GLSL::makeFrag(const char* glslVer, bool alphaTest, lightingSrc = "const vec4 colorReg0 = vec4(1.0);\n" "const vec4 colorReg1 = vec4(1.0);\n" "const vec4 colorReg2 = vec4(1.0);\n" + "const vec4 mulColor = vec4(1.0);\n" "\n"; std::string texMapDecl; @@ -232,9 +233,9 @@ std::string GLSL::makeFrag(const char* glslVer, bool alphaTest, sampIdx++, sampling.mapIdx, sampling.tcgIdx); if (m_alphaExpr.size()) - retval += " colorOut = vec4(" + m_colorExpr + ", " + m_alphaExpr + ");\n"; + retval += " colorOut = vec4(" + m_colorExpr + ", " + m_alphaExpr + ") * mulColor;\n"; else - retval += " colorOut = vec4(" + m_colorExpr + ", 1.0);\n"; + retval += " colorOut = vec4(" + m_colorExpr + ", 1.0) * mulColor;\n"; return retval + (alphaTest ? GenerateAlphaTest() : "") + "}\n"; } @@ -251,6 +252,7 @@ std::string GLSL::makeFrag(const char* glslVer, bool alphaTest, lightingSrc = "const vec4 colorReg0 = vec4(1.0);\n" "const vec4 colorReg1 = vec4(1.0);\n" "const vec4 colorReg2 = vec4(1.0);\n" + "const vec4 mulColor = vec4(1.0);\n" "\n"; std::string postSrc; @@ -300,9 +302,9 @@ std::string GLSL::makeFrag(const char* glslVer, bool alphaTest, sampIdx++, sampling.mapIdx, sampling.tcgIdx); if (m_alphaExpr.size()) - retval += " colorOut = " + postEntry + "(vec4(" + m_colorExpr + ", " + m_alphaExpr + "));\n"; + retval += " colorOut = " + postEntry + "(vec4(" + m_colorExpr + ", " + m_alphaExpr + ")) * mulColor;\n"; else - retval += " colorOut = " + postEntry + "(vec4(" + m_colorExpr + ", 1.0));\n"; + retval += " colorOut = " + postEntry + "(vec4(" + m_colorExpr + ", 1.0)) * mulColor;\n"; return retval + (alphaTest ? GenerateAlphaTest() : "") + "}\n"; } diff --git a/hecl/lib/Backend/HLSL.cpp b/hecl/lib/Backend/HLSL.cpp index 66514b6f6..4d6f78318 100644 --- a/hecl/lib/Backend/HLSL.cpp +++ b/hecl/lib/Backend/HLSL.cpp @@ -188,7 +188,8 @@ std::string HLSL::makeFrag(bool alphaTest, const ShaderFunction& lighting) const else lightingSrc = "static const float4 colorReg0 = float4(1.0, 1.0, 1.0, 1.0);\n" "static const float4 colorReg1 = float4(1.0, 1.0, 1.0, 1.0);\n" - "static const float4 colorReg2 = float4(1.0, 1.0, 1.0, 1.0);\n"; + "static const float4 colorReg2 = float4(1.0, 1.0, 1.0, 1.0);\n" + "static const float4 mulColor = float4(1.0, 1.0, 1.0, 1.0);\n"; std::string texMapDecl; if (m_texMapEnd) @@ -218,9 +219,9 @@ std::string HLSL::makeFrag(bool alphaTest, const ShaderFunction& lighting) const retval += " float4 colorOut;\n"; if (m_alphaExpr.size()) - retval += " colorOut = float4(" + m_colorExpr + ", " + m_alphaExpr + ");\n"; + retval += " colorOut = float4(" + m_colorExpr + ", " + m_alphaExpr + ") * mulColor;\n"; else - retval += " colorOut = float4(" + m_colorExpr + ", 1.0);\n"; + retval += " colorOut = float4(" + m_colorExpr + ", 1.0) * mulColor;\n"; return retval + (alphaTest ? GenerateAlphaTest() : "") + " return colorOut;\n}\n"; } @@ -235,7 +236,8 @@ std::string HLSL::makeFrag(bool alphaTest, const ShaderFunction& lighting, else lightingSrc = "static const float4 colorReg0 = float4(1.0, 1.0, 1.0, 1.0);\n" "static const float4 colorReg1 = float4(1.0, 1.0, 1.0, 1.0);\n" - "static const float4 colorReg2 = float4(1.0, 1.0, 1.0, 1.0);\n"; + "static const float4 colorReg2 = float4(1.0, 1.0, 1.0, 1.0);\n" + "static const float4 mulColor = float4(1.0, 1.0, 1.0, 1.0);\n"; std::string postSrc; if (post.m_source) @@ -281,9 +283,9 @@ std::string HLSL::makeFrag(bool alphaTest, const ShaderFunction& lighting, retval += " float4 colorOut;\n"; if (m_alphaExpr.size()) - retval += " colorOut = " + postEntry + "(" + (postEntry.size() ? "vtf, " : "") + "float4(" + m_colorExpr + ", " + m_alphaExpr + "));\n"; + retval += " colorOut = " + postEntry + "(" + (postEntry.size() ? "vtf, " : "") + "float4(" + m_colorExpr + ", " + m_alphaExpr + ")) * mulColor;\n"; else - retval += " colorOut = " + postEntry + "(" + (postEntry.size() ? "vtf, " : "") + "float4(" + m_colorExpr + ", 1.0));\n"; + retval += " colorOut = " + postEntry + "(" + (postEntry.size() ? "vtf, " : "") + "float4(" + m_colorExpr + ", 1.0)) * mulColor;\n"; return retval + (alphaTest ? GenerateAlphaTest() : "") + " return colorOut;\n}\n"; } diff --git a/hecl/lib/Backend/Metal.cpp b/hecl/lib/Backend/Metal.cpp index 5fa6c44ff..1ead7c7aa 100644 --- a/hecl/lib/Backend/Metal.cpp +++ b/hecl/lib/Backend/Metal.cpp @@ -233,13 +233,15 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp { retval += " float4 colorReg0 = block0.colorReg0;\n" " float4 colorReg1 = block0.colorReg1;\n" - " float4 colorReg2 = block0.colorReg2;\n"; + " float4 colorReg2 = block0.colorReg2;\n" + " float4 mulColor = block0.mulColor;\n"; } else { retval += " float4 colorReg0 = float4(1.0, 1.0, 1.0, 1.0);\n" " float4 colorReg1 = float4(1.0, 1.0, 1.0, 1.0);\n" - " float4 colorReg2 = float4(1.0, 1.0, 1.0, 1.0);\n"; + " float4 colorReg2 = float4(1.0, 1.0, 1.0, 1.0);\n" + " float4 mulColor = float4(1.0, 1.0, 1.0, 1.0);\n"; } if (m_lighting) @@ -256,9 +258,9 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp sampIdx++, sampling.mapIdx, sampling.tcgIdx); if (m_alphaExpr.size()) - retval += " out.color = float4(" + m_colorExpr + ", " + m_alphaExpr + ");\n"; + retval += " out.color = float4(" + m_colorExpr + ", " + m_alphaExpr + ") * mulColor;\n"; else - retval += " out.color = float4(" + m_colorExpr + ", 1.0);\n"; + retval += " out.color = float4(" + m_colorExpr + ", 1.0) * mulColor;\n"; return retval + (alphaTest ? GenerateAlphaTest() : "") + " //out.depth = 1.0 - float(int((1.0 - vtf.mvpPos.z) * 16777216.0)) / 16777216.0;\n" @@ -323,13 +325,15 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp { retval += " float4 colorReg0 = block0.colorReg0;\n" " float4 colorReg1 = block0.colorReg1;\n" - " float4 colorReg2 = block0.colorReg2;\n"; + " float4 colorReg2 = block0.colorReg2;\n" + " float4 mulColor = block0.mulColor;\n"; } else { retval += " float4 colorReg0 = float4(1.0, 1.0, 1.0, 1.0);\n" " float4 colorReg1 = float4(1.0, 1.0, 1.0, 1.0);\n" - " float4 colorReg2 = float4(1.0, 1.0, 1.0, 1.0);\n"; + " float4 colorReg2 = float4(1.0, 1.0, 1.0, 1.0);\n" + " float4 mulColor = float4(1.0, 1.0, 1.0, 1.0);\n"; } if (m_lighting) @@ -347,10 +351,10 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp if (m_alphaExpr.size()) retval += " out.color = " + postEntry + "(" + (postEntry.size() ? ("vtf, " + (blockCall.size() ? (blockCall + ", ") : "") + (extTexCall.size() ? (extTexCall + ", ") : "")) : "") + - "float4(" + m_colorExpr + ", " + m_alphaExpr + "));\n"; + "float4(" + m_colorExpr + ", " + m_alphaExpr + ")) * mulColor;\n"; else retval += " out.color = " + postEntry + "(" + (postEntry.size() ? ("vtf, " + (blockCall.size() ? (blockCall + ", ") : "") + (extTexCall.size() ? (extTexCall + ", ") : "")) : "") + - "float4(" + m_colorExpr + ", 1.0));\n"; + "float4(" + m_colorExpr + ", 1.0)) * mulColor;\n"; return retval + (alphaTest ? GenerateAlphaTest() : "") + " //out.depth = 1.0 - float(int((1.0 - vtf.mvpPos.z) * 16777216.0)) / 16777216.0;\n"