| 822 | |
| 823 | |
| 824 | void HnMaterialNetwork::ProcessInputParameter(const pxr::HdMaterialNetwork2& Network, |
| 825 | const pxr::HdMaterialNode2& Node, |
| 826 | const pxr::TfToken& ParamName, |
| 827 | pxr::SdfPathSet& VisitedNodes) |
| 828 | { |
| 829 | pxr::SdrRegistry& ShaderReg = pxr::SdrRegistry::GetInstance(); |
| 830 | |
| 831 | // Resolve what is connected to this param (eg. primvar, texture, nothing) |
| 832 | // and then make the correct HdSt_MaterialParam for it. |
| 833 | auto const& conn_it = Node.inputConnections.find(ParamName); |
| 834 | if (conn_it != Node.inputConnections.end()) |
| 835 | { |
| 836 | const std::vector<pxr::HdMaterialConnection2>& Connections = conn_it->second; |
| 837 | if (!Connections.empty()) |
| 838 | { |
| 839 | // Find the node that is connected to this input |
| 840 | const pxr::HdMaterialConnection2& Conn = Connections.front(); |
| 841 | auto const& up_it = Network.nodes.find(Conn.upstreamNode); |
| 842 | |
| 843 | if (up_it != Network.nodes.end()) |
| 844 | { |
| 845 | const pxr::SdfPath& UpstreamPath = up_it->first; |
| 846 | const pxr::TfToken& UpstreamOutputName = Conn.upstreamOutputName; |
| 847 | const pxr::HdMaterialNode2& UpstreamNode = up_it->second; |
| 848 | |
| 849 | pxr::SdrShaderNodeConstPtr UpstreamSdr = |
| 850 | ShaderReg.GetShaderNodeByIdentifier( |
| 851 | UpstreamNode.nodeTypeId, |
| 852 | {pxr::HioGlslfxTokens->glslfx, HnMaterialPrivateTokens->mtlx}); |
| 853 | |
| 854 | if (UpstreamSdr) |
| 855 | { |
| 856 | pxr::TfToken SdrRole{UpstreamSdr->GetRole()}; |
| 857 | if (SdrRole == pxr::SdrNodeRole->Texture) |
| 858 | { |
| 859 | AddTextureParam( |
| 860 | Network, |
| 861 | UpstreamNode, |
| 862 | Node, |
| 863 | UpstreamPath, |
| 864 | UpstreamOutputName, |
| 865 | ParamName, |
| 866 | VisitedNodes); |
| 867 | return; |
| 868 | } |
| 869 | else if (SdrRole == pxr::SdrNodeRole->Primvar) |
| 870 | { |
| 871 | AddPrimvarReaderParam( |
| 872 | Network, |
| 873 | UpstreamNode, |
| 874 | UpstreamPath, |
| 875 | ParamName, |
| 876 | VisitedNodes); |
| 877 | return; |
| 878 | } |
| 879 | else if (SdrRole == pxr::SdrNodeRole->Field) |
| 880 | { |
| 881 | AddFieldReaderParam( |
nothing calls this directly
no outgoing calls
no test coverage detected