Add master mulColor to programmable shader output

This commit is contained in:
Jack Andersen 2017-02-09 23:00:23 -10:00
parent e07e82f798
commit 154a44e21f
3 changed files with 26 additions and 18 deletions

View File

@ -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";
}

View File

@ -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";
}

View File

@ -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"