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; resolvedKey.attributes = prgKey.attributes;
BOOST_FOREACH(const ShaderKey& shaderKey, prgKey.shaders) 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; 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); string fileName = SGModelLib::findDataFile(shaderName, options);
if (fileName.empty()) if (fileName.empty())
{ {

View File

@ -130,8 +130,12 @@ Effect* makeEffect(const string& name,
string effectFileName; string effectFileName;
// Use getPropertyRoot() because the SGReaderWriterOptions might not have a // Use getPropertyRoot() because the SGReaderWriterOptions might not have a
// valid property tree // 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 += "Compositor/";
}
effectFileName += name; effectFileName += name;
effectFileName += ".eff"; effectFileName += ".eff";
string absFileName string absFileName

View File

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