Commit ee6ab927 authored by Christopher Tenter's avatar Christopher Tenter
Browse files

remove all preprocessor defines in shader generator + fix some texcoord generation code

parent 280f9a90
Pipeline #666 passed with stage
......@@ -60,7 +60,9 @@
namespace ACG
{
#define LIGHTING_CODE_FILE "ShaderGen/SG_LIGHTING.GLSL"
int ShaderProgGenerator::numRegisteredModifiers_ = 0;
std::vector<ShaderModifier*> ShaderProgGenerator::registeredModifiers_;
......@@ -69,50 +71,20 @@ namespace ACG
// VS : view space
// CS : clip space
// attribute request keywords
#define SG_REQUEST_POSVS "#define SG_REQUEST_POSVS"
#define SG_REQUEST_POSOS "#define SG_REQUEST_POSOS"
#define SG_REQUEST_TEXCOORD "#define SG_REQUEST_TEXCOORD"
#define SG_REQUEST_VERTEXCOLOR "#define SG_REQUEST_VERTEXCOLOR"
#define SG_REQUEST_NORMALVS "#define SG_REQUEST_NORMALVS"
#define SG_REQUEST_NORMALOS "#define SG_REQUEST_NORMALOS"
// renormalize normal-vec before lighting in fragment shader
#define SG_REQUEST_RENOMARLIZE "#define SG_REQUEST_RENORMARLIZE"
// generic default attribute input keywords
// these are extended by the correct input name by the generator for each stage
#define SG_INPUT_POSVS "SG_INPUT_POSVS"
#define SG_INPUT_POSOS "SG_INPUT_POSOS"
#define SG_INPUT_POSCS "SG_INPUT_POSCS"
#define SG_INPUT_NORMALVS "SG_INPUT_NORMALVS"
#define SG_INPUT_NORMALOS "SG_INPUT_NORMALOS"
#define SG_INPUT_TEXCOORD "SG_INPUT_TEXCOORD"
#define SG_INPUT_VERTEXCOLOR "SG_INPUT_VERTEXCOLOR"
#define SG_OUTPUT_POSVS "SG_OUTPUT_POSVS"
#define SG_OUTPUT_POSOS "SG_OUTPUT_POSOS"
#define SG_OUTPUT_POSCS "SG_OUTPUT_POSCS"
#define SG_OUTPUT_NORMALVS "SG_OUTPUT_NORMALVS"
#define SG_OUTPUT_NORMALOS "SG_OUTPUT_NORMALOS"
#define SG_OUTPUT_TEXCOORD "SG_OUTPUT_TEXCOORD"
#define SG_OUTPUT_VERTEXCOLOR "SG_OUTPUT_VERTEXCOLOR"
int ShaderProgGenerator::numRegisteredModifiers_ = 0;
std::vector<ShaderModifier*> ShaderProgGenerator::registeredModifiers_;
ShaderGenerator::Keywords::Keywords()
// attribute request keywords
: macro_requestPosVS("#define SG_REQUEST_POSVS"),
macro_requestPosOS("#define SG_REQUEST_POSOS"),
macro_requestTexcoord("#define SG_REQUEST_TEXCOORD"),
macro_requestVertexColor("#define SG_REQUEST_VERTEXCOLOR"),
macro_requestNormalVS("#define SG_REQUEST_NORMALVS"),
macro_requestNormalOS("#define SG_REQUEST_NORMALOS"),
// // renormalize normal-vec before lighting in fragment shader
macro_requestRenormalize("#define SG_REQUEST_RENORMARLIZE"),
// generic default attribute input keywords
// these are extended by the correct input name by the generator for each stage
macro_inputPosVS("SG_INPUT_POSVS"),
macro_inputPosOS("SG_INPUT_POSOS"),
macro_inputPosCS("SG_INPUT_POSCS"),
......@@ -234,7 +206,7 @@ void ShaderGenerator::initVertexShaderIO(const ShaderGenDesc* _desc, const Defau
addOutput("vec4", strColorOut);
}
else
addStringToList("vec4" + keywords.vs_outputVertexColor, &outputs_, _desc->vertexColorsInterpolator + " out ", ";");
addStringToList("vec4 " + keywords.vs_outputVertexColor, &outputs_, _desc->vertexColorsInterpolator + " out ", ";");
......@@ -255,7 +227,10 @@ void ShaderGenerator::initVertexShaderIO(const ShaderGenDesc* _desc, const Defau
texdim = _desc->texGenDim;
QString texcoordType;
texcoordType.sprintf("vec%i", texdim);
if (texdim > 1)
texcoordType.sprintf("vec%i", texdim);
else
texcoordType = "float";
addInput(texcoordType, keywords.vs_inputTexCoord);
addOutput(texcoordType, keywords.vs_outputTexCoord);
......@@ -366,48 +341,48 @@ void ShaderGenerator::defineIOAbstraction( const DefaultIODesc* _iodesc, bool _v
{
if (_iodesc->passPosVS_)
{
addDefine(QString(SG_INPUT_POSVS) + QString(" ") + inputPrefix_ + keywords.ioPosVS);
addIODefine(keywords.macro_inputPosVS, inputPrefix_ + keywords.ioPosVS);
if (!_fs)
addDefine(QString(SG_OUTPUT_POSVS) + QString(" ") + outputPrefix_ + keywords.ioPosVS);
addIODefine(keywords.macro_outputPosVS, outputPrefix_ + keywords.ioPosVS);
}
if (_iodesc->passPosOS_)
{
addDefine(QString(SG_INPUT_POSOS) + QString(" ") + inputPrefix_ + keywords.ioPosOS);
addIODefine(keywords.macro_inputPosOS, inputPrefix_ + keywords.ioPosOS);
if (!_fs)
addDefine(QString(SG_OUTPUT_POSOS) + QString(" ") + outputPrefix_ + keywords.ioPosOS);
addIODefine(keywords.macro_outputPosOS, outputPrefix_ + keywords.ioPosOS);
}
addDefine(QString(SG_INPUT_POSCS) + QString(" ") + inputPrefix_ + keywords.ioPosCS);
addIODefine(keywords.macro_inputPosCS, inputPrefix_ + keywords.ioPosCS);
if (!_fs)
addDefine(QString(SG_OUTPUT_POSCS) + QString(" ") + outputPrefix_ + keywords.ioPosCS);
addIODefine(keywords.macro_outputPosCS, outputPrefix_ + keywords.ioPosCS);
if (_iodesc->passNormalVS_)
{
addDefine(QString(SG_INPUT_NORMALVS) + QString(" ") + inputPrefix_ + keywords.ioNormalVS);
addIODefine(keywords.macro_inputNormalVS, inputPrefix_ + keywords.ioNormalVS);
if (!_fs)
addDefine(QString(SG_OUTPUT_NORMALVS) + QString(" ") + outputPrefix_ + keywords.ioNormalVS);
addIODefine(keywords.macro_outputNormalVS, outputPrefix_ + keywords.ioNormalVS);
}
if (_iodesc->passNormalOS_)
{
addDefine(QString(SG_INPUT_NORMALOS) + QString(" ") + inputPrefix_ + keywords.ioNormalOS);
addIODefine(keywords.macro_inputNormalOS, inputPrefix_ + keywords.ioNormalOS);
if (!_fs)
addDefine(QString(SG_OUTPUT_NORMALOS) + QString(" ") + outputPrefix_ + keywords.ioNormalOS);
addIODefine(keywords.macro_outputNormalOS, outputPrefix_ + keywords.ioNormalOS);
}
if (_iodesc->passTexCoord_)
{
addDefine(QString(SG_INPUT_TEXCOORD) + QString(" ") + inputPrefix_ + keywords.ioTexcoord);
addIODefine(keywords.macro_inputTexcoord, inputPrefix_ + keywords.ioTexcoord);
if (!_fs)
addDefine(QString(SG_OUTPUT_TEXCOORD) + QString(" ") + outputPrefix_ + keywords.ioTexcoord);
addIODefine(keywords.macro_outputTexcoord, outputPrefix_ + keywords.ioTexcoord);
}
if (_iodesc->passColor_)
{
addDefine(QString(SG_INPUT_VERTEXCOLOR) + QString(" ") + inputPrefix_ + keywords.ioColor);
addIODefine(keywords.macro_inputVertexColor, inputPrefix_ + keywords.ioColor);
if (!_fs)
addDefine(QString(SG_INPUT_VERTEXCOLOR) + QString(" ") + outputPrefix_ + keywords.ioColor);
addIODefine(keywords.macro_outputVertexColor, outputPrefix_ + keywords.ioColor);
}
}
......@@ -1016,7 +991,9 @@ void ShaderProgGenerator::loadLightingFunctions()
{
if (lightingCode_.size()) return;
QString fileName = shaderDir_ + QDir::separator() + QString(LIGHTING_CODE_FILE);
static const QString lightingCodeFile = "ShaderGen/SG_LIGHTING.GLSL";
QString fileName = shaderDir_ + QDir::separator() + QString(lightingCodeFile);
lightingCode_.push_back("// ==============================================================================");
lightingCode_.push_back(QString("// ShaderGenerator - default lighting functions imported from file: ") + fileName);
......@@ -1105,6 +1082,16 @@ void ShaderProgGenerator::buildVertexShader()
vertex_->initDefaultUniforms();
if (desc_.texGenDim && (desc_.texGenMode == GL_OBJECT_LINEAR || desc_.texGenMode == GL_EYE_LINEAR) && !desc_.texGenPerFragment)
{
// application has to provide texture projection planes
QString uniformDecl = "vec4 g_vTexGenPlane";
if (desc_.texGenDim > 1)
uniformDecl += "[" + QString::number(desc_.texGenDim) + "]";
vertex_->addUniform(uniformDecl, " // texture projection planes");
}
// apply i/o modifiers
for (size_t i = 0; i < activeMods_.size(); ++i)
activeMods_[i]->modifyVertexIO(vertex_);
......@@ -1184,7 +1171,7 @@ void ShaderProgGenerator::addVertexBeginCode(QStringList* _code)
_code->push_back("vec3 sg_vNormalOS = vec3(0.0, 1.0, 0.0);");
if (desc_.vertexColors && (desc_.colorMaterialMode == GL_AMBIENT || desc_.colorMaterialMode == GL_AMBIENT_AND_DIFFUSE))
_code->push_back("vec4 sg_cColor = vec4(g_cEmissive + g_cLightModelAmbient * " SG_INPUT_VERTEXCOLOR ".xyz, SG_ALPHA);");
_code->push_back(QString("vec4 sg_cColor = vec4(g_cEmissive + g_cLightModelAmbient * ") + ShaderGenerator::keywords.macro_inputVertexColor + QString(".xyz, SG_ALPHA);"));
else
_code->push_back("vec4 sg_cColor = vec4(g_cEmissive + g_cLightModelAmbient * g_cAmbient, SG_ALPHA);");
......@@ -1195,7 +1182,7 @@ void ShaderProgGenerator::addVertexBeginCode(QStringList* _code)
}
if (ioDesc_.inputColor_ && (desc_.shadeMode == SG_SHADE_UNLIT || desc_.colorMaterialMode == GL_EMISSION))
_code->push_back("sg_cColor = " SG_INPUT_VERTEXCOLOR ";");
_code->push_back(QString("sg_cColor = ") + ShaderGenerator::keywords.macro_inputVertexColor + QString(";"));
// texcoord generation
addTexGenCode(_code, false);
......@@ -1666,6 +1653,15 @@ void ShaderProgGenerator::buildFragmentShader()
fragment_->initFragmentShaderIO(&desc_, prevStage, &ioDesc_);
if (desc_.texGenDim && (desc_.texGenMode == GL_OBJECT_LINEAR || desc_.texGenMode == GL_EYE_LINEAR) && desc_.texGenPerFragment)
{
// application has to provide texture projection planes
QString uniformDecl = "vec4 g_vTexGenPlane";
if (desc_.texGenDim > 1)
uniformDecl += "[" + QString::number(desc_.texGenDim) + "]";
fragment_->addUniform(uniformDecl, " // texture projection planes");
}
fragment_->initDefaultUniforms();
......@@ -1778,29 +1774,29 @@ void ShaderProgGenerator::buildFragmentShader()
void ShaderProgGenerator::addFragmentBeginCode(QStringList* _code)
{
// support for projective texture mapping
_code->push_back("vec4 sg_vPosCS = " SG_INPUT_POSCS ";");
_code->push_back(QString("vec4 sg_vPosCS = ") + ShaderGenerator::keywords.macro_inputPosCS + QString(";"));
_code->push_back("vec2 sg_vScreenPos = sg_vPosCS.xy / sg_vPosCS.w * 0.5 + vec2(0.5, 0.5);");
_code->push_back("#ifdef " SG_INPUT_POSVS);
_code->push_back("vec4 sg_vPosVS = " SG_INPUT_POSVS ";");
_code->push_back(QString("#ifdef ") + ShaderGenerator::keywords.macro_inputPosVS);
_code->push_back(QString("vec4 sg_vPosVS = ") + ShaderGenerator::keywords.macro_inputPosVS + QString(";"));
_code->push_back("#endif");
_code->push_back("#ifdef " SG_INPUT_NORMALVS);
_code->push_back("vec3 sg_vNormalVS = " SG_INPUT_NORMALVS ";");
_code->push_back(QString("#ifdef ") + ShaderGenerator::keywords.macro_inputNormalVS);
_code->push_back(QString("vec3 sg_vNormalVS = ") + ShaderGenerator::keywords.macro_inputNormalVS + QString(";"));
if (renormalizeLighting_)
_code->push_back("sg_vNormalVS = normalize(sg_vNormalVS);");
_code->push_back("#endif");
if (desc_.vertexColors && (desc_.colorMaterialMode == GL_AMBIENT || desc_.colorMaterialMode == GL_AMBIENT_AND_DIFFUSE))
_code->push_back("vec4 sg_cColor = vec4(g_cEmissive + g_cLightModelAmbient * " SG_INPUT_VERTEXCOLOR ".xyz, SG_ALPHA);");
_code->push_back(QString("vec4 sg_cColor = vec4(g_cEmissive + g_cLightModelAmbient * ") + ShaderGenerator::keywords.macro_inputVertexColor + QString(".xyz, SG_ALPHA);"));
else
_code->push_back("vec4 sg_cColor = vec4(g_cEmissive + g_cLightModelAmbient * g_cAmbient, SG_ALPHA);");
if (desc_.shadeMode == SG_SHADE_GOURAUD ||
desc_.shadeMode == SG_SHADE_FLAT ||
(ioDesc_.passColor_ && (desc_.shadeMode == SG_SHADE_UNLIT || desc_.colorMaterialMode == GL_EMISSION)))
_code->push_back("sg_cColor = " SG_INPUT_VERTEXCOLOR ";");
_code->push_back(QString("sg_cColor = ") + ShaderGenerator::keywords.macro_inputVertexColor + QString(";"));
if (desc_.shadeMode == SG_SHADE_PHONG)
addLightingCode(_code);
......@@ -1833,7 +1829,7 @@ void ShaderProgGenerator::addFragmentBeginCode(QStringList* _code)
void ShaderProgGenerator::addFragmentEndCode(QStringList* _code)
{
_code->push_back("outFragment = sg_cColor;");
_code->push_back(ShaderGenerator::keywords.fs_outputFragmentColor + QString(" = sg_cColor;"));
// apply modifiers
for (size_t i = 0; i < activeMods_.size(); ++i)
......@@ -1860,10 +1856,10 @@ void ShaderProgGenerator::addLightingCode(QStringList* _code)
QString buf;
const char* vertexColorString = (ioDesc_.inputColor_ && ioDesc_.passColor_) ? SG_INPUT_VERTEXCOLOR ".xyz * " : "";
const char* diffuseVertexColor = (desc_.colorMaterialMode == GL_DIFFUSE || desc_.colorMaterialMode == GL_AMBIENT_AND_DIFFUSE) ? vertexColorString : "";
const char* ambientVertexColor = (desc_.colorMaterialMode == GL_AMBIENT || desc_.colorMaterialMode == GL_AMBIENT_AND_DIFFUSE) ? vertexColorString : "";
const char* specularVertexColor = (desc_.colorMaterialMode == GL_SPECULAR) ? vertexColorString : "";
QString vertexColorString = (ioDesc_.inputColor_ && ioDesc_.passColor_) ? (ShaderGenerator::keywords.macro_inputVertexColor + QString(".xyz * ")) : "";
QString diffuseVertexColor = (desc_.colorMaterialMode == GL_DIFFUSE || desc_.colorMaterialMode == GL_AMBIENT_AND_DIFFUSE) ? vertexColorString : "";
QString ambientVertexColor = (desc_.colorMaterialMode == GL_AMBIENT || desc_.colorMaterialMode == GL_AMBIENT_AND_DIFFUSE) ? vertexColorString : "";
QString specularVertexColor = (desc_.colorMaterialMode == GL_SPECULAR) ? vertexColorString : "";
for (int i = 0; i < desc_.numLights; ++i)
{
......@@ -1872,15 +1868,18 @@ void ShaderProgGenerator::addLightingCode(QStringList* _code)
switch (lgt)
{
case SG_LIGHT_DIRECTIONAL:
buf.sprintf("sg_cColor.xyz += LitDirLight(sg_vPosVS.xyz, sg_vNormalVS, g_vLightDir_%d, %s g_cLightAmbient_%d, %s g_cLightDiffuse_%d, %s g_cLightSpecular_%d);", i, ambientVertexColor, i, diffuseVertexColor, i, specularVertexColor, i);
// buf.sprintf("sg_cColor.xyz += LitDirLight(sg_vPosVS.xyz, sg_vNormalVS, g_vLightDir_%d, %s g_cLightAmbient_%d, %s g_cLightDiffuse_%d, %s g_cLightSpecular_%d);", i, ambientVertexColor, i, diffuseVertexColor, i, specularVertexColor, i);
buf = QString("sg_cColor.xyz += LitDirLight(sg_vPosVS.xyz, sg_vNormalVS, g_vLightDir_%1, %2 g_cLightAmbient_%1, %3 g_cLightDiffuse_%1, %4 g_cLightSpecular_%1);").arg(QString::number(i), ambientVertexColor, diffuseVertexColor, specularVertexColor);
break;
case SG_LIGHT_POINT:
buf.sprintf("sg_cColor.xyz += LitPointLight(sg_vPosVS.xyz, sg_vNormalVS, g_vLightPos_%d, %s g_cLightAmbient_%d, %s g_cLightDiffuse_%d, %s g_cLightSpecular_%d, g_vLightAtten_%d);", i, ambientVertexColor, i, diffuseVertexColor, i, specularVertexColor, i, i);
// buf.sprintf("sg_cColor.xyz += LitPointLight(sg_vPosVS.xyz, sg_vNormalVS, g_vLightPos_%d, %s g_cLightAmbient_%d, %s g_cLightDiffuse_%d, %s g_cLightSpecular_%d, g_vLightAtten_%d);", i, ambientVertexColor, i, diffuseVertexColor, i, specularVertexColor, i, i);
buf = QString("sg_cColor.xyz += LitPointLight(sg_vPosVS.xyz, sg_vNormalVS, g_vLightPos_%1, %2 g_cLightAmbient_%1, %3 g_cLightDiffuse_%1, %4 g_cLightSpecular_%1, g_vLightAtten_%1);").arg(QString::number(i), ambientVertexColor, diffuseVertexColor, specularVertexColor);
break;
case SG_LIGHT_SPOT:
buf.sprintf("sg_cColor.xyz += LitSpotLight(sg_vPosVS.xyz, sg_vNormalVS, g_vLightPos_%d, g_vLightDir_%d, %s g_cLightAmbient_%d, %s g_cLightDiffuse_%d, %s g_cLightSpecular_%d, g_vLightAtten_%d, g_vLightAngleExp_%d);", i, i, ambientVertexColor, i, diffuseVertexColor, i, specularVertexColor, i, i, i);
// buf.sprintf("sg_cColor.xyz += LitSpotLight(sg_vPosVS.xyz, sg_vNormalVS, g_vLightPos_%d, g_vLightDir_%d, %s g_cLightAmbient_%d, %s g_cLightDiffuse_%d, %s g_cLightSpecular_%d, g_vLightAtten_%d, g_vLightAngleExp_%d);", i, i, ambientVertexColor, i, diffuseVertexColor, i, specularVertexColor, i, i, i);
buf = QString("sg_cColor.xyz += LitSpotLight(sg_vPosVS.xyz, sg_vNormalVS, g_vLightPos_%1, g_vLightDir_%1, %2 g_cLightAmbient_%1, %3 g_cLightDiffuse_%1, %4 g_cLightSpecular_%1, g_vLightAtten_%1, g_vLightAngleExp_%1);").arg(QString::number(i), ambientVertexColor, diffuseVertexColor, specularVertexColor);
break;
default: break;
......@@ -1946,11 +1945,14 @@ void ShaderProgGenerator::addTexGenCode( QStringList* _code, bool _fragmentShade
texcoordVarDim = desc_.texGenDim;
QString texcoordVarInit;
texcoordVarInit.sprintf("vec%i sg_vTexCoord", texcoordVarDim);
if (texcoordVarDim == 1)
texcoordVarInit = "float sg_vTexCoord";
else
texcoordVarInit.sprintf("vec%i sg_vTexCoord", texcoordVarDim);
// init with default value: input or zero
if (ioDesc_.inputTexCoord_ && !generateTexCoord)
texcoordVarInit += "= " SG_INPUT_TEXCOORD ";";
texcoordVarInit += QString("= ") + ShaderGenerator::keywords.macro_inputTexcoord + QString(";");
else if (0 <= texcoordVarDim && texcoordVarDim <= 4)
{
QString zeroVecDefs[] =
......@@ -1981,7 +1983,22 @@ void ShaderProgGenerator::addTexGenCode( QStringList* _code, bool _fragmentShade
for (int i = 0; i < desc_.texGenDim; ++i)
{
QString assignmentInstrString;
assignmentInstrString.sprintf("sg_vTexCoord.%s = dot(" SG_INPUT_POSOS ", g_vTexGenPlane[%i]);", texGenCoordString[i], i);
assignmentInstrString = "sg_vTexCoord";
if (desc_.texGenDim > 1)
{
assignmentInstrString +=".";
assignmentInstrString += texGenCoordString[i];
}
assignmentInstrString += " = dot(";
assignmentInstrString += ShaderGenerator::keywords.macro_inputPosOS;
assignmentInstrString += ", g_vTexGenPlane";
if (desc_.texGenDim > 1)
{
assignmentInstrString += "[";
assignmentInstrString += QString::number(i);
assignmentInstrString += "]";
}
assignmentInstrString += ");";
_code->push_back(assignmentInstrString);
}
} break;
......@@ -1991,9 +2008,23 @@ void ShaderProgGenerator::addTexGenCode( QStringList* _code, bool _fragmentShade
for (int i = 0; i < desc_.texGenDim; ++i)
{
QString assignmentInstrString;
assignmentInstrString.sprintf("sg_vTexCoord.%s = dot(sg_vPosVS, g_vTexGenPlane[%i]);", texGenCoordString[i], i);
assignmentInstrString = "sg_vTexCoord";
if (desc_.texGenDim > 1)
{
assignmentInstrString += ".";
assignmentInstrString += texGenCoordString[i];
}
assignmentInstrString += " = dot(sg_vPosVS, g_vTexGenPlane";
if (desc_.texGenDim > 1)
{
assignmentInstrString += "[";
assignmentInstrString += QString::number(i);
assignmentInstrString += "]";
}
assignmentInstrString += ");";
_code->push_back(assignmentInstrString);
}
} break;
case GL_SPHERE_MAP:
......@@ -2128,32 +2159,32 @@ void ShaderProgGenerator::generateShaders()
}
// scan requested inputs from modifiers
if (dummy.hasDefine(SG_REQUEST_POSVS))
if (dummy.hasDefine(ShaderGenerator::keywords.macro_requestPosVS))
ioDesc_.passPosVS_ = true;
if (dummy.hasDefine(SG_REQUEST_TEXCOORD))
if (dummy.hasDefine(ShaderGenerator::keywords.macro_requestTexcoord))
{
ioDesc_.inputTexCoord_ = true;
ioDesc_.passTexCoord_ = true;
}
if (dummy.hasDefine(SG_REQUEST_VERTEXCOLOR))
if (dummy.hasDefine(ShaderGenerator::keywords.macro_requestVertexColor))
{
ioDesc_.inputColor_ = true;
ioDesc_.passColor_ = true;
}
if (dummy.hasDefine(SG_REQUEST_NORMALVS))
if (dummy.hasDefine(ShaderGenerator::keywords.macro_requestNormalVS))
{
ioDesc_.inputNormal_ = true;
ioDesc_.passNormalVS_ = true;
}
if (dummy.hasDefine(SG_REQUEST_NORMALOS))
if (dummy.hasDefine(ShaderGenerator::keywords.macro_requestNormalOS))
{
ioDesc_.inputNormal_ = true;
ioDesc_.passNormalOS_ = true;
}
if (dummy.hasDefine(SG_REQUEST_POSOS))
if (dummy.hasDefine(ShaderGenerator::keywords.macro_requestPosOS))
ioDesc_.passPosOS_ = true;
if (dummy.hasDefine(SG_REQUEST_RENOMARLIZE))
if (dummy.hasDefine(ShaderGenerator::keywords.macro_requestRenormalize))
renormalizeLighting_ = true;
......@@ -2311,31 +2342,31 @@ void ShaderProgGenerator::scanShaderTemplate(QStringList& _templateSrc, QString
{
// scan requested inputs
if (trimmedLine.startsWith(SG_REQUEST_POSVS))
if (trimmedLine.startsWith(ShaderGenerator::keywords.macro_requestPosVS))
ioDesc_.passPosVS_ = true;
else if (trimmedLine.startsWith(SG_REQUEST_TEXCOORD))
else if (trimmedLine.startsWith(ShaderGenerator::keywords.macro_requestTexcoord))
{
ioDesc_.inputTexCoord_ = true;
ioDesc_.passTexCoord_ = true;
}
else if (trimmedLine.startsWith(SG_REQUEST_VERTEXCOLOR))
else if (trimmedLine.startsWith(ShaderGenerator::keywords.macro_requestVertexColor))
{
ioDesc_.inputColor_ = true;
ioDesc_.passColor_ = true;
}
else if (trimmedLine.startsWith(SG_REQUEST_NORMALVS))
else if (trimmedLine.startsWith(ShaderGenerator::keywords.macro_requestNormalVS))
{
ioDesc_.inputNormal_ = true;
ioDesc_.passNormalVS_ = true;
}
else if (trimmedLine.startsWith(SG_REQUEST_NORMALOS))
else if (trimmedLine.startsWith(ShaderGenerator::keywords.macro_requestNormalOS))
{
ioDesc_.inputNormal_ = true;
ioDesc_.passNormalOS_ = true;
}
else if (trimmedLine.startsWith(SG_REQUEST_POSOS))
else if (trimmedLine.startsWith(ShaderGenerator::keywords.macro_requestPosOS))
ioDesc_.passPosOS_ = true;
else if (trimmedLine.startsWith(SG_REQUEST_RENOMARLIZE))
else if (trimmedLine.startsWith(ShaderGenerator::keywords.macro_requestRenormalize))
renormalizeLighting_ = true;
else if (trimmedLine.startsWith("SG_FRAGMENT_LIGHTING"))
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment