Compositor: Shaders are looked for in $FG_ROOT/Compositor/Shaders when the compositor is enabled.

Fixed Compositor/ always being added to the effect filename. Now it is only added when the base folder is Effects/.
This commit is contained in:
Fernando García Liñán 2019-10-26 01:53:30 +02:00
parent 0a7514c47b
commit 02b61b145a
3 changed files with 20 additions and 11 deletions

View File

@ -918,8 +918,13 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
resolvedKey.attributes = prgKey.attributes;
BOOST_FOREACH(const ShaderKey& shaderKey, prgKey.shaders)
{
const string& shaderName = shaderKey.first;
// FIXME orig: const string& shaderName = shaderKey.first;
string shaderName = shaderKey.first;
Shader::Type stype = (Shader::Type)shaderKey.second;
if (getPropertyRoot()->getBoolValue("/sim/version/compositor-support", false) &&
shaderName.substr(0, shaderName.find("/")) == "Shaders") {
shaderName = "Compositor/" + shaderName;
}
string fileName = SGModelLib::findDataFile(shaderName, options);
if (fileName.empty())
{

View File

@ -130,8 +130,12 @@ Effect* makeEffect(const string& name,
string effectFileName;
// Use getPropertyRoot() because the SGReaderWriterOptions might not have a
// valid property tree
if (getPropertyRoot()->getBoolValue("/sim/version/compositor-support", false))
if (getPropertyRoot()->getBoolValue("/sim/version/compositor-support", false) &&
name.substr(0, name.find("/")) == "Effects") {
// Temporarily append the Compositor/ directory to every effect that should
// be inside Effects/.
effectFileName += "Compositor/";
}
effectFileName += name;
effectFileName += ".eff";
string absFileName

View File

@ -112,15 +112,15 @@ PassBuilder::build(Compositor *compositor, const SGPropertyNode *root,
camera->setClearStencil(root->getIntValue("clear-stencil", 0));
GLbitfield clear_mask = 0;
if (root->getBoolValue("clear-color-bit", true))
clear_mask |= GL_COLOR_BUFFER_BIT;
if (root->getBoolValue("clear-accum-bit", false))
clear_mask |= GL_ACCUM_BUFFER_BIT;
if (root->getBoolValue("clear-depth-bit", true))
clear_mask |= GL_DEPTH_BUFFER_BIT;
if (root->getBoolValue("clear-stencil-bit", false))
clear_mask |= GL_STENCIL_BUFFER_BIT;
// Default clear mask is GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, as in OSG
std::stringstream ss;
std::string bit;
// Default clear mask as in OSG
ss << root->getStringValue("clear-mask", "color depth");
while (ss >> bit) {
if (bit == "color") clear_mask |= GL_COLOR_BUFFER_BIT;
else if (bit == "depth") clear_mask |= GL_DEPTH_BUFFER_BIT;
else if (bit == "stencil") clear_mask |= GL_STENCIL_BUFFER_BIT;
}
camera->setClearMask(clear_mask);
PropertyList p_bindings = root->getChildren("binding");