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

Imagers only updates in the render delegate #1410

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions common/constant_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ ASTR(region_min_y);
ASTR(render_device);
ASTR(render_settings);
ASTR(repeat);
ASTR(request_imager_update);
ASTR(rotation);
ASTR(roughness);
ASTR(scale);
Expand Down
22 changes: 20 additions & 2 deletions render_delegate/node_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ void HdArnoldNodeGraph::Sync(HdSceneDelegate* sceneDelegate, HdRenderParam* rend
auto value = sceneDelegate->GetMaterialResource(GetId());
auto nodeGraphChanged = false;
if (value.IsHolding<HdMaterialNetworkMap>()) {
param.Interrupt();

// If this nodeGraph is an imager graph, and it's been modified, we don't want
// to stop the render (#1320)
if (!_isImagerGraph)
param.Interrupt();
// Mark all nodes as unused before any translation happens.
SetNodesUnused();
const auto& map = value.UncheckedGet<HdMaterialNetworkMap>();
Expand All @@ -457,7 +461,10 @@ void HdArnoldNodeGraph::Sync(HdSceneDelegate* sceneDelegate, HdRenderParam* rend
}
// No need to interrupt earlier as we don't know if there is a valid network passed to the function or
// not.
param.Interrupt();

// As above, we don't interrupt if this is an imager graph
if (!_isImagerGraph)
param.Interrupt();
// We are remapping the preview surface nodes to ones that are supported
// in Arnold. This way we can keep the export code untouched,
// and handle connection / node exports separately.
Expand All @@ -478,6 +485,12 @@ void HdArnoldNodeGraph::Sync(HdSceneDelegate* sceneDelegate, HdRenderParam* rend
}
}
ClearUnusedNodes();
// If this is an imager graph, we need to tell Arnold that the imagers were updated.
// This will trigger only the computation of the imager graph, without necessarily
// restarting a render (#1320)
if (_isImagerGraph) {
AiRenderSetHintBool(_renderDelegate->GetRenderSession(), str::request_imager_update, true);
}
}
// We only mark the material dirty if one of the terminals have changed, but ignore the initial sync, because we
// expect Hydra to do the initial assignment correctly.
Expand Down Expand Up @@ -582,6 +595,7 @@ AtNode* HdArnoldNodeGraph::ReadMaterialNetwork(const HdMaterialNetwork& network)
if (AiNodeEntryGetType(AiNodeGetNodeEntry(inputNode)) == AI_NODE_DRIVER) {
// imagers are chained with the input parameter
AiNodeSetPtr(outputNode, str::input, inputNode);
_isImagerGraph = true;
} else {
// Arnold shader nodes can only have one output... but you can connect to sub components of them.
// USD doesn't yet have component connections / swizzling, but it's nodes can have multiple
Expand Down Expand Up @@ -849,6 +863,10 @@ const HdArnoldNodeGraph* HdArnoldNodeGraph::GetNodeGraph(HdRenderIndex* renderIn
return reinterpret_cast<const HdArnoldNodeGraph*>(renderIndex->GetSprim(HdPrimTypeTokens->material, id));
}

void HdArnoldNodeGraph::SetImagerGraph()
{
_isImagerGraph = true;
}


PXR_NAMESPACE_CLOSE_SCOPE
8 changes: 8 additions & 0 deletions render_delegate/node_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ class HdArnoldNodeGraph : public HdMaterial {
/// @return Pointer to the requested HdArnoldNodeGraph
HDARNOLD_API
static const HdArnoldNodeGraph* GetNodeGraph(HdRenderIndex* renderIndex, const SdfPath& id);

/// Notify this node graph that it's meant to be used as an imager graph.
/// In this case, when an interactive change happens, we don't want to restart
/// a full render, but instead we directly update the arnold imagers and then
/// notify Arnold that the imagers were updated (#1320)
HDARNOLD_API
void SetImagerGraph();

protected:
/// Utility struct to store translated nodes.
Expand Down Expand Up @@ -281,6 +288,7 @@ class HdArnoldNodeGraph : public HdMaterial {
ArnoldNodeGraph _nodeGraph; ///< Storing arnold shaders for terminals.
HdArnoldRenderDelegate* _renderDelegate; ///< Pointer to the Render Delegate.
bool _wasSyncedOnce = false; ///< Whether or not the material has been synced at least once.
bool _isImagerGraph = false; ///< Whether or not this is an imager graph
};

PXR_NAMESPACE_CLOSE_SCOPE
7 changes: 5 additions & 2 deletions render_delegate/render_delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,9 +1483,12 @@ std::vector<AtNode*> HdArnoldRenderDelegate::GetAovShaders(HdRenderIndex* render

AtNode* HdArnoldRenderDelegate::GetImager(HdRenderIndex* renderIndex)
{
const HdArnoldNodeGraph *nodeGraph = HdArnoldNodeGraph::GetNodeGraph(renderIndex, _imager);
if (nodeGraph)
HdArnoldNodeGraph *nodeGraph = (HdArnoldNodeGraph *)HdArnoldNodeGraph::GetNodeGraph(renderIndex, _imager);
if (nodeGraph) {
// Notify this nodeGraph that it's being used as an imager graph
nodeGraph->SetImagerGraph();
return nodeGraph->GetTerminal(str::t_input);
}
return nullptr;
}

Expand Down