MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / convertTextureCoords

Method convertTextureCoords

Source/Modules/USDUtils/ConvertedInput.cpp:108–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106} // namespace
107
108bool ConvertedInput::convertTextureCoords(const UsdShadeShader& shader, Falcor::Transform& xform)
109{
110 UsdShadeConnectableAPI source;
111 TfToken sourceName;
112 UsdShadeAttributeType sourceType;
113 UsdShadeInput stInput(getSourceInput(shader.GetInput(gStToken), source, sourceName, sourceType));
114 if (!stInput)
115 {
116 return false;
117 }
118
119 TfToken id = getAttribute(source.GetPrim().GetAttribute(UsdShadeTokens->infoId), TfToken());
120 if (id == gTransform2dToken)
121 {
122 if (UsdShadeInput scaleInput = source.GetInput(gScaleToken); scaleInput)
123 {
124 float2 scaleVec;
125 if (getFloat2Value(scaleInput, scaleVec))
126 {
127 xform.setScaling(float3(scaleVec.x, scaleVec.y, 1.f));
128 }
129 }
130
131 if (UsdShadeInput rotateInput = source.GetInput(gRotationToken); rotateInput)
132 {
133 float degrees;
134 if (rotateInput.Get<float>(&degrees, UsdTimeCode::EarliestTime()))
135 {
136 xform.setRotationEulerDeg(float3(0.f, 0.f, degrees));
137 }
138 }
139
140 if (UsdShadeInput translateInput = source.GetInput(gTranslationToken); translateInput)
141 {
142 float2 translateVec;
143 if (getFloat2Value(translateInput, translateVec))
144 {
145 xform.setTranslation(float3(translateVec.x, translateVec.y, 0.f));
146 }
147 }
148 xform.setCompositionOrder(Transform::CompositionOrder::ScaleRotateTranslate);
149 }
150 else if (id != gFloat2PrimvarReaderToken)
151 {
152 logWarning(
153 "UsdUVTexture node '{}' defines an st primvar reader '{}' of an unexpected type: '{}'.",
154 shader.GetPrim().GetPath().GetString(),
155 source.GetPrim().GetPath().GetString(),
156 id.GetString()
157 );
158 }
159 return true;
160}
161
162ConvertedInput ConvertedInput::convertTexture(
163 const UsdShadeInput& input,

Callers

nothing calls this directly

Calls 7

getSourceInputFunction · 0.85
getFloat2ValueFunction · 0.85
setScalingMethod · 0.80
setRotationEulerDegMethod · 0.80
setTranslationMethod · 0.80
getAttributeFunction · 0.70
logWarningFunction · 0.50

Tested by

no test coverage detected