| 415 | // corresponding value on given SdrNode. |
| 416 | template <typename T> |
| 417 | T ResolveParameter(const pxr::HdMaterialNode2& Node, |
| 418 | const pxr::SdrShaderNodeConstPtr& SdrNode, |
| 419 | const pxr::TfToken& Name, |
| 420 | const T& DefaultValue) |
| 421 | { |
| 422 | // First consult node parameters... |
| 423 | { |
| 424 | const auto param_it = Node.parameters.find(Name); |
| 425 | if (param_it != Node.parameters.end()) |
| 426 | { |
| 427 | const pxr::VtValue& Value = param_it->second; |
| 428 | if (Value.IsHolding<T>()) |
| 429 | { |
| 430 | return Value.UncheckedGet<T>(); |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | // Then fallback to SdrNode. |
| 436 | if (SdrNode) |
| 437 | { |
| 438 | if (const pxr::SdrShaderPropertyConstPtr Input = SdrNode->GetShaderInput(Name)) |
| 439 | { |
| 440 | const pxr::VtValue& Value = Input->GetDefaultValue(); |
| 441 | if (Value.IsHolding<T>()) |
| 442 | { |
| 443 | return Value.UncheckedGet<T>(); |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | return DefaultValue; |
| 449 | } |
| 450 | |
| 451 | std::string ResolveAssetPath(const pxr::VtValue& Value) |
| 452 | { |
no outgoing calls
no test coverage detected