Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use SdfPathVector for aov_shaders #1322

Merged
merged 3 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions common/common_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ void ArnoldUsdCheckForSdfPathValue(const VtValue& value, F&& f)
}
}

template <typename F>
ARCH_HIDDEN
void ArnoldUsdCheckForSdfPathVectorValue(const VtValue& value, F&& f)
{
if (value.IsArrayValued()) {
f({});
} else if (value.IsHolding<std::string>()) {
// Split with space
const auto s = value.UncheckedGet<std::string>();
SdfPathVector paths;
for (const auto &path: TfStringTokenize(s)) {
paths.emplace_back(path);
}
f(paths);
}
}

ARCH_HIDDEN
int ArnoldUsdGetLogVerbosityFromFlags(int flags);

Expand Down
20 changes: 14 additions & 6 deletions render_delegate/render_delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ void HdArnoldRenderDelegate::_SetRenderSetting(const TfToken& _key, const VtValu
} else if (key == str::t_atmosphere) {
ArnoldUsdCheckForSdfPathValue(value, [&](const SdfPath& p) { _atmosphere = p; });
} else if (key == str::t_aov_shaders) {
ArnoldUsdCheckForSdfPathValue(value, [&](const SdfPath& p) { _aov_shaders = p; });
ArnoldUsdCheckForSdfPathVectorValue(value, [&](const SdfPathVector& p) { _aov_shaders = p; });
} else if (key == str::t_imager) {
ArnoldUsdCheckForSdfPathValue(value, [&](const SdfPath& p) { _imager = p; });
} else if (key == str::t_subdiv_dicing_camera) {
Expand Down Expand Up @@ -817,7 +817,10 @@ VtValue HdArnoldRenderDelegate::GetRenderSetting(const TfToken& _key) const
} else if (key == str::t_atmosphere) {
return VtValue(_atmosphere.GetString());
} else if (key == str::t_aov_shaders) {
return VtValue(_aov_shaders.GetString());
// There should be a function in common_utils.cpp
std::vector<std::string> pathsAsString;
std::transform(_aov_shaders.begin(), _aov_shaders.end(), std::back_inserter(pathsAsString), [](const auto &p){return p.GetString();});
return VtValue(TfStringJoin(pathsAsString));
} else if (key == str::t_imager) {
return VtValue(_imager.GetString());
} else if (key == str::t_subdiv_dicing_camera) {
Expand Down Expand Up @@ -1460,10 +1463,15 @@ AtNode* HdArnoldRenderDelegate::GetAtmosphere(HdRenderIndex* renderIndex)

std::vector<AtNode*> HdArnoldRenderDelegate::GetAovShaders(HdRenderIndex* renderIndex)
{
const HdArnoldNodeGraph *nodeGraph = HdArnoldNodeGraph::GetNodeGraph(renderIndex, _aov_shaders);
if (nodeGraph)
return nodeGraph->GetTerminals(_tokens->aovShadersArray);
return std::vector<AtNode *>();
std::vector<AtNode *> nodes;
for (const auto &materialPath: _aov_shaders) {
const HdArnoldNodeGraph *nodeGraph = HdArnoldNodeGraph::GetNodeGraph(renderIndex, materialPath);
if (nodeGraph) {
const auto &terminals = nodeGraph->GetTerminals(_tokens->aovShadersArray);
std::copy(terminals.begin(), terminals.end(), std::back_inserter(nodes));
}
}
return nodes;
}

AtNode* HdArnoldRenderDelegate::GetImager(HdRenderIndex* renderIndex)
Expand Down
2 changes: 1 addition & 1 deletion render_delegate/render_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ class HdArnoldRenderDelegate final : public HdRenderDelegate {
SdfPath _id; ///< Path of the Render Delegate.
SdfPath _background; ///< Path to the background shader.
SdfPath _atmosphere; ///< Path to the atmosphere shader.
SdfPath _aov_shaders; ///< Path to the aov shaders.
SdfPathVector _aov_shaders; ///< Path to the aov shaders.
SdfPath _imager; ///< Path to the root imager node.
SdfPath _subdiv_dicing_camera; ///< Path to the subdiv dicing camera
AtUniverse* _universe; ///< Universe used by the Render Delegate.
Expand Down