feat(materialx): Update source search path handling in shader generation

This commit is contained in:
2026-01-06 16:21:43 +00:00
parent 620e9a4b7a
commit 9f2faa389d

View File

@@ -57,6 +57,13 @@ ShaderPaths MaterialXShaderGenerator::Generate(const MaterialXConfig& config,
if (!libraryPath.empty()) {
searchPath.append(mx::FilePath(libraryPath.string()));
}
mx::FileSearchPath sourceSearchPath = searchPath;
if (!libraryPath.empty() && libraryPath.filename() == "libraries") {
std::filesystem::path libraryRoot = libraryPath.parent_path();
if (!libraryRoot.empty()) {
sourceSearchPath.append(mx::FilePath(libraryRoot.string()));
}
}
if (logger_) {
logger_->Trace("MaterialXShaderGenerator", "Generate",
"libraryPath=" + libraryPath.string() +
@@ -74,7 +81,7 @@ ShaderPaths MaterialXShaderGenerator::Generate(const MaterialXConfig& config,
mx::ShaderGeneratorPtr generator = mx::VkShaderGenerator::create();
mx::GenContext context(generator);
context.registerSourceCodeSearchPath(searchPath);
context.registerSourceCodeSearchPath(sourceSearchPath);
mx::ShaderPtr shader;
if (config.useConstantColor) {