Hypershade-style pin display modes for material graph nodes

Each node gets an All/Conn toggle: connected-only mode hides
unconnected pins behind collapsed connector nubs on the title row;
dragging a link onto (or from) a nub opens a menu to pick which hidden
pin to wire, and the pin appears once connected. The toggle is drawn
and hit-tested geometrically, and its tooltip is deferred to after
NE::End() so it lands at the cursor. A new Preferences > Material
checkbox opts into persisting the per-node mode as USD customData
(uiShowAllPins); otherwise it stays session-only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-10 23:02:56 +08:00
parent 22406fbe63
commit c7edd145df
6 changed files with 331 additions and 7 deletions
+5
View File
@@ -138,6 +138,7 @@ ShaderGraphSnapshot MaterialManager::GetShaderGraph(const pxr::SdfPath& material
if (!materialPrim.IsValid()) return snapshot;
static const pxr::TfToken kUiPositionKey("uiPosition");
static const pxr::TfToken kUiShowAllPinsKey("uiShowAllPins");
// Seed with every shader under the material, recursing into nested node
// graphs (usdMtlx nests a material's nodes inside UsdShadeNodeGraph
@@ -179,6 +180,10 @@ ShaderGraphSnapshot MaterialManager::GetShaderGraph(const pxr::SdfPath& material
node.hasAuthoredPosition = true;
}
pxr::VtValue showAllValue = child.GetCustomDataByKey(kUiShowAllPinsKey);
if (showAllValue.IsHolding<bool>())
node.showAllPins = showAllValue.UncheckedGet<bool>();
// Prefer the full Sdr-defined pin set (so unauthored pins can still be
// dragged to create a connection); fall back to authored attributes
// only for shader types the registry doesn't know about.
+6
View File
@@ -48,6 +48,12 @@ struct ShaderGraphNode {
/// False when no uiPosition custom data is authored (typical for networks
/// referenced from .mtlx) — the editor auto-lays such nodes out instead.
bool hasAuthoredPosition = false;
/// Hypershade-style pin display mode, read from customData when the
/// "keep graph node view settings in USD" preference authored it; true
/// (show every pin) when unauthored. False hides unconnected pins,
/// collapsing them into a single connectable "more pins" nub per side
/// (see MaterialEditorPanel) until a new connection reveals one by name.
bool showAllPins = true;
std::vector<ShaderPinInfo> inputs;
std::vector<ShaderPinInfo> outputs;
};