Commit 7d6bbd88 authored by Christopher Tenter's avatar Christopher Tenter
Browse files

add ShaderMods to shader generator description

parent de50b89d
...@@ -891,15 +891,31 @@ void ShaderProgGenerator::init( const ShaderGenDesc* _desc, const unsigned int* ...@@ -891,15 +891,31 @@ void ShaderProgGenerator::init( const ShaderGenDesc* _desc, const unsigned int*
void ShaderProgGenerator::init( const ShaderGenDesc* _desc, ShaderModifier* const* _modifiers, unsigned int _numActiveMods ) void ShaderProgGenerator::init( const ShaderGenDesc* _desc, ShaderModifier* const* _modifiers, unsigned int _numActiveMods )
{ {
if (_modifiers && _numActiveMods) // mods provided by renderer are passed via parameters _modifiers, _numActiveMods
// mods provided by individual render objects are passed via ShaderGenDesc* _desc
// combine them
size_t numDescMods = _desc->shaderMods.size();
size_t numTotalMods = _numActiveMods + numDescMods;
if (numTotalMods)
{ {
activeMods_.resize(_numActiveMods); activeMods_.resize(numTotalMods);
for (unsigned int i = 0; i < _numActiveMods; ++i) for (size_t i = 0; i < numDescMods; ++i)
activeMods_[i] = _modifiers[i]; {
unsigned int modID = _desc->shaderMods[i];
activeMods_[i] = registeredModifiers_[modID];
}
if (_modifiers && _numActiveMods)
{
for (unsigned int i = 0; i < _numActiveMods; ++i)
activeMods_[i + numDescMods] = _modifiers[i];
}
} }
if (shaderDir_.isEmpty()) if (shaderDir_.isEmpty())
std::cout << "error: call ShaderProgGenerator::setShaderDir() first!" << std::endl; std::cout << "error: call ShaderProgGenerator::setShaderDir() first!" << std::endl;
else else
......
...@@ -154,6 +154,9 @@ public: ...@@ -154,6 +154,9 @@ public:
QString geometryTemplateFile; QString geometryTemplateFile;
QString fragmentTemplateFile; QString fragmentTemplateFile;
// optionally specify shader mod ids
std::vector<unsigned int> shaderMods;
// preprocessor macros for the shaders // preprocessor macros for the shaders
// these are added to all shaders directly after the #version directive // these are added to all shaders directly after the #version directive
QStringList macros; QStringList macros;
...@@ -303,6 +306,9 @@ public: ...@@ -303,6 +306,9 @@ public:
return false; return false;
} }
if (shaderMods != _rhs.shaderMods)
return false;
if (numLights) if (numLights)
return memcmp(lightTypes, _rhs.lightTypes, numLights * sizeof(ShaderGenLightType)) == 0; return memcmp(lightTypes, _rhs.lightTypes, numLights * sizeof(ShaderGenLightType)) == 0;
......
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