MCPcopy Create free account
hub / github.com/DiligentGraphics/DiligentFX / AddFieldReaderParam

Method AddFieldReaderParam

Hydrogent/src/HnMaterialNetwork.cpp:1194–1237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1192}
1193
1194void HnMaterialNetwork::AddFieldReaderParam(const pxr::HdMaterialNetwork2& Network,
1195 const pxr::HdMaterialNode2& Node,
1196 const pxr::SdfPath& NodePath,
1197 const pxr::TfToken& ParamName,
1198 pxr::SdfPathSet& VisitedNodes)
1199{
1200 if (!VisitedNodes.emplace(NodePath).second)
1201 return;
1202
1203 // Volume Fields act more like a primvar then a texture.
1204 // There is a `Volume` prim with 'fields' that may point to a
1205 // OpenVDB file. We have to find the 'inputs:fieldname' on the
1206 // HWFieldReader in the material network to know what 'field' to use.
1207 // See also HdStVolume and HdStField for how volume textures are
1208 // inserted into Storm.
1209
1210 HnMaterialParameter Param{HnMaterialParameter::ParamType::FieldRedirect, ParamName};
1211
1212 // XXX Why HnMaterialPrivateTokens->fieldname:
1213 // Hard-coding the name of the attribute of HwFieldReader identifying
1214 // the field name for now.
1215 // The equivalent of the generic mechanism Sdr provides for primvars
1216 // is missing for fields: UsdPrimvarReader.inputs:varname is tagged with
1217 // SdrMetadata as primvarProperty="1" so that we can use
1218 // SdrNode->GetAdditionalPrimvarProperties to know what attribute to use.
1219 const pxr::TfToken& VarName = HnMaterialPrivateTokens->fieldname;
1220
1221 auto const& param_it = Node.parameters.find(VarName);
1222 if (param_it != Node.parameters.end())
1223 {
1224 pxr::VtValue FieldName = param_it->second;
1225 if (FieldName.IsHolding<pxr::TfToken>())
1226 {
1227 // Stashing name of field in _samplerCoords.
1228 Param.SamplerCoords.push_back(FieldName.UncheckedGet<pxr::TfToken>());
1229 }
1230 else if (FieldName.IsHolding<std::string>())
1231 {
1232 Param.SamplerCoords.push_back(pxr::TfToken{FieldName.UncheckedGet<std::string>()});
1233 }
1234 }
1235
1236 m_Parameters.emplace_back(std::move(Param));
1237}
1238
1239void HnMaterialNetwork::AddTransform2dParam(const pxr::HdMaterialNetwork2& Network,
1240 const pxr::HdMaterialNode2& Node,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected