mirror of https://github.com/AxioDL/metaforce.git
addColor term for standard shader model
This commit is contained in:
parent
d88c9cc21b
commit
b6af26fa91
|
@ -234,6 +234,7 @@ std::string GLSL::makeFrag(size_t blockCount, const char** blockNames, bool alph
|
||||||
"const vec4 colorReg1 = vec4(1.0);\n"
|
"const vec4 colorReg1 = vec4(1.0);\n"
|
||||||
"const vec4 colorReg2 = vec4(1.0);\n"
|
"const vec4 colorReg2 = vec4(1.0);\n"
|
||||||
"const vec4 mulColor = vec4(1.0);\n"
|
"const vec4 mulColor = vec4(1.0);\n"
|
||||||
|
"const vec4 addColor = vec4(0.0);\n"
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
std::string texMapDecl;
|
std::string texMapDecl;
|
||||||
|
@ -274,9 +275,10 @@ std::string GLSL::makeFrag(size_t blockCount, const char** blockNames, bool alph
|
||||||
std::string reflectionExpr = GenerateReflectionExpr(reflectionType);
|
std::string reflectionExpr = GenerateReflectionExpr(reflectionType);
|
||||||
|
|
||||||
if (m_alphaExpr.size())
|
if (m_alphaExpr.size())
|
||||||
retval += " colorOut = vec4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr + ") * mulColor;\n";
|
retval += " colorOut = vec4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr +
|
||||||
|
") * mulColor + addColor;\n";
|
||||||
else
|
else
|
||||||
retval += " colorOut = vec4(" + m_colorExpr + " + " + reflectionExpr + ", 1.0) * mulColor;\n";
|
retval += " colorOut = vec4(" + m_colorExpr + " + " + reflectionExpr + ", 1.0) * mulColor + addColor;\n";
|
||||||
|
|
||||||
return retval + (alphaTest ? GenerateAlphaTest() : "") + "}\n";
|
return retval + (alphaTest ? GenerateAlphaTest() : "") + "}\n";
|
||||||
}
|
}
|
||||||
|
@ -293,6 +295,7 @@ std::string GLSL::makeFrag(size_t blockCount, const char** blockNames, bool alph
|
||||||
"const vec4 colorReg1 = vec4(1.0);\n"
|
"const vec4 colorReg1 = vec4(1.0);\n"
|
||||||
"const vec4 colorReg2 = vec4(1.0);\n"
|
"const vec4 colorReg2 = vec4(1.0);\n"
|
||||||
"const vec4 mulColor = vec4(1.0);\n"
|
"const vec4 mulColor = vec4(1.0);\n"
|
||||||
|
"const vec4 addColor = vec4(0.0);\n"
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
std::string postSrc;
|
std::string postSrc;
|
||||||
|
@ -351,9 +354,10 @@ std::string GLSL::makeFrag(size_t blockCount, const char** blockNames, bool alph
|
||||||
|
|
||||||
if (m_alphaExpr.size())
|
if (m_alphaExpr.size())
|
||||||
retval += " colorOut = " + postEntry + "(vec4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr +
|
retval += " colorOut = " + postEntry + "(vec4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr +
|
||||||
")) * mulColor;\n";
|
")) * mulColor + addColor;\n";
|
||||||
else
|
else
|
||||||
retval += " colorOut = " + postEntry + "(vec4(" + m_colorExpr + " + " + reflectionExpr + ", 1.0)) * mulColor;\n";
|
retval += " colorOut = " + postEntry + "(vec4(" + m_colorExpr + " + " + reflectionExpr +
|
||||||
|
", 1.0)) * mulColor + addColor;\n";
|
||||||
|
|
||||||
return retval + (alphaTest ? GenerateAlphaTest() : "") + "}\n";
|
return retval + (alphaTest ? GenerateAlphaTest() : "") + "}\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,8 @@ std::string HLSL::makeFrag(size_t blockCount, const char** blockNames, bool alph
|
||||||
"static const float4 colorReg0 = float4(1.0, 1.0, 1.0, 1.0);\n"
|
"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 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";
|
"static const float4 mulColor = float4(1.0, 1.0, 1.0, 1.0);\n"
|
||||||
|
"static const float4 addColor = float4(0.0, 0.0, 0.0, 0.0);\n";
|
||||||
|
|
||||||
std::string texMapDecl;
|
std::string texMapDecl;
|
||||||
if (m_texMapEnd)
|
if (m_texMapEnd)
|
||||||
|
@ -270,9 +271,10 @@ std::string HLSL::makeFrag(size_t blockCount, const char** blockNames, bool alph
|
||||||
|
|
||||||
retval += " float4 colorOut;\n";
|
retval += " float4 colorOut;\n";
|
||||||
if (m_alphaExpr.size())
|
if (m_alphaExpr.size())
|
||||||
retval += " colorOut = float4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr + ") * mulColor;\n";
|
retval += " colorOut = float4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr +
|
||||||
|
") * mulColor + addColor;\n";
|
||||||
else
|
else
|
||||||
retval += " colorOut = float4(" + m_colorExpr + " + " + reflectionExpr + ", 1.0) * mulColor;\n";
|
retval += " colorOut = float4(" + m_colorExpr + " + " + reflectionExpr + ", 1.0) * mulColor + addColor;\n";
|
||||||
|
|
||||||
return retval + (alphaTest ? GenerateAlphaTest() : "") + " return colorOut;\n}\n";
|
return retval + (alphaTest ? GenerateAlphaTest() : "") + " return colorOut;\n}\n";
|
||||||
}
|
}
|
||||||
|
@ -288,7 +290,8 @@ std::string HLSL::makeFrag(size_t blockCount, const char** blockNames, bool alph
|
||||||
"static const float4 colorReg0 = float4(1.0, 1.0, 1.0, 1.0);\n"
|
"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 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";
|
"static const float4 mulColor = float4(1.0, 1.0, 1.0, 1.0);\n"
|
||||||
|
"static const float4 addColor = float4(0.0, 0.0, 0.0, 0.0);\n";
|
||||||
|
|
||||||
std::string postSrc;
|
std::string postSrc;
|
||||||
if (!post.m_source.empty())
|
if (!post.m_source.empty())
|
||||||
|
@ -345,10 +348,10 @@ std::string HLSL::makeFrag(size_t blockCount, const char** blockNames, bool alph
|
||||||
retval += " float4 colorOut;\n";
|
retval += " float4 colorOut;\n";
|
||||||
if (m_alphaExpr.size())
|
if (m_alphaExpr.size())
|
||||||
retval += " colorOut = " + postEntry + "(" + (postEntry.size() ? "vtf, " : "") + "float4(" + m_colorExpr +
|
retval += " colorOut = " + postEntry + "(" + (postEntry.size() ? "vtf, " : "") + "float4(" + m_colorExpr +
|
||||||
" + " + reflectionExpr + ", " + m_alphaExpr + ")) * mulColor;\n";
|
" + " + reflectionExpr + ", " + m_alphaExpr + ")) * mulColor + addColor;\n";
|
||||||
else
|
else
|
||||||
retval += " colorOut = " + postEntry + "(" + (postEntry.size() ? "vtf, " : "") + "float4(" + m_colorExpr +
|
retval += " colorOut = " + postEntry + "(" + (postEntry.size() ? "vtf, " : "") + "float4(" + m_colorExpr +
|
||||||
" + " + reflectionExpr + ", 1.0)) * mulColor;\n";
|
" + " + reflectionExpr + ", 1.0)) * mulColor + addColor;\n";
|
||||||
|
|
||||||
return retval + (alphaTest ? GenerateAlphaTest() : "") + " return colorOut;\n}\n";
|
return retval + (alphaTest ? GenerateAlphaTest() : "") + " return colorOut;\n}\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,13 +270,15 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp
|
||||||
" float4 colorReg0 = block0.colorReg0;\n"
|
" float4 colorReg0 = block0.colorReg0;\n"
|
||||||
" float4 colorReg1 = block0.colorReg1;\n"
|
" float4 colorReg1 = block0.colorReg1;\n"
|
||||||
" float4 colorReg2 = block0.colorReg2;\n"
|
" float4 colorReg2 = block0.colorReg2;\n"
|
||||||
" float4 mulColor = block0.mulColor;\n";
|
" float4 mulColor = block0.mulColor;\n"
|
||||||
|
" float4 addColor = block0.addColor;\n";
|
||||||
} else {
|
} else {
|
||||||
retval +=
|
retval +=
|
||||||
" float4 colorReg0 = float4(1.0, 1.0, 1.0, 1.0);\n"
|
" 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 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";
|
" float4 mulColor = float4(1.0, 1.0, 1.0, 1.0);\n"
|
||||||
|
" float4 addColor = float4(0.0, 0.0, 0.0, 0.0);\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_lighting) {
|
if (m_lighting) {
|
||||||
|
@ -295,9 +297,10 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp
|
||||||
std::string reflectionExpr = GenerateReflectionExpr(reflectionType);
|
std::string reflectionExpr = GenerateReflectionExpr(reflectionType);
|
||||||
|
|
||||||
if (m_alphaExpr.size())
|
if (m_alphaExpr.size())
|
||||||
retval += " out.color = float4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr + ") * mulColor;\n";
|
retval += " out.color = float4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr +
|
||||||
|
") * mulColor + addColor;\n";
|
||||||
else
|
else
|
||||||
retval += " out.color = float4(" + m_colorExpr + " + " + reflectionExpr + ", 1.0) * mulColor;\n";
|
retval += " out.color = float4(" + m_colorExpr + " + " + reflectionExpr + ", 1.0) * mulColor + addColor;\n";
|
||||||
|
|
||||||
return retval + (alphaTest ? GenerateAlphaTest() : "") +
|
return retval + (alphaTest ? GenerateAlphaTest() : "") +
|
||||||
" //out.depth = 1.0 - float(int((1.0 - vtf.mvpPos.z) * 16777216.0)) / 16777216.0;\n"
|
" //out.depth = 1.0 - float(int((1.0 - vtf.mvpPos.z) * 16777216.0)) / 16777216.0;\n"
|
||||||
|
@ -382,13 +385,15 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp
|
||||||
" float4 colorReg0 = block0.colorReg0;\n"
|
" float4 colorReg0 = block0.colorReg0;\n"
|
||||||
" float4 colorReg1 = block0.colorReg1;\n"
|
" float4 colorReg1 = block0.colorReg1;\n"
|
||||||
" float4 colorReg2 = block0.colorReg2;\n"
|
" float4 colorReg2 = block0.colorReg2;\n"
|
||||||
" float4 mulColor = block0.mulColor;\n";
|
" float4 mulColor = block0.mulColor;\n"
|
||||||
|
" float4 addColor = block0.addColor;\n";
|
||||||
} else {
|
} else {
|
||||||
retval +=
|
retval +=
|
||||||
" float4 colorReg0 = float4(1.0, 1.0, 1.0, 1.0);\n"
|
" 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 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";
|
" float4 mulColor = float4(1.0, 1.0, 1.0, 1.0);\n"
|
||||||
|
" float4 addColor = float4(0.0, 0.0, 0.0, 0.0);\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_lighting) {
|
if (m_lighting) {
|
||||||
|
@ -417,7 +422,7 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp
|
||||||
? (extTexCall.size() ? ("samp, clampSamp," + extTexCall + ", ") : "")
|
? (extTexCall.size() ? ("samp, clampSamp," + extTexCall + ", ") : "")
|
||||||
: ""))
|
: ""))
|
||||||
: "") +
|
: "") +
|
||||||
"float4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr + ")) * mulColor;\n";
|
"float4(" + m_colorExpr + " + " + reflectionExpr + ", " + m_alphaExpr + ")) * mulColor + addColor;\n";
|
||||||
} else {
|
} else {
|
||||||
retval += " out.color = " + postEntry + "(" +
|
retval += " out.color = " + postEntry + "(" +
|
||||||
(postEntry.size() ? ("vtf, " + (blockCall.size() ? (blockCall + ", ") : "") +
|
(postEntry.size() ? ("vtf, " + (blockCall.size() ? (blockCall + ", ") : "") +
|
||||||
|
@ -425,7 +430,7 @@ std::string Metal::makeFrag(size_t blockCount, const char** blockNames, bool alp
|
||||||
? (extTexCall.size() ? ("samp, clampSamp," + extTexCall + ", ") : "")
|
? (extTexCall.size() ? ("samp, clampSamp," + extTexCall + ", ") : "")
|
||||||
: ""))
|
: ""))
|
||||||
: "") +
|
: "") +
|
||||||
"float4(" + m_colorExpr + " + " + reflectionExpr + ", 1.0)) * mulColor;\n";
|
"float4(" + m_colorExpr + " + " + reflectionExpr + ", 1.0)) * mulColor + addColor;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval + (alphaTest ? GenerateAlphaTest() : "") +
|
return retval + (alphaTest ? GenerateAlphaTest() : "") +
|
||||||
|
|
Loading…
Reference in New Issue