Skip to content

Commit 4b7231f

Browse files
committed
Merge branch 'RB-10.6'
2 parents 74f44af + a760d07 commit 4b7231f

3 files changed

Lines changed: 83 additions & 4 deletions

File tree

Changes

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
10.7.x.x (relative to 10.7.0.0a12)
22
========
33

4+
Improvements
5+
------------
6+
7+
- USDScene : Added `IECOREUSD_WRITE_CONFORMANT_RENDERMAN_ATTRIBUTES` environment variable. If set to a value of `1`, this causes "ri:" prefixed attributes to be written as expected by `usdRiPxr` [^1].
8+
49
Fixes
510
-----
611

712
- PointInstancer : Fixed signature for `setPrototypes()` function.
813

14+
[^1]: To be omitted from the notes for the final 10.7.0.0 release.
15+
916
10.7.0.0a12 (relative to 10.7.0.0a11)
1017
===========
1118

@@ -236,11 +243,19 @@ Breaking Changes
236243
- Removed deprecated functions componentConnectionAdapterLabel, convertOSLComponentConnections, collapseSplineParameters, expandSplineParameters.
237244
- Switch support for Spline parameters to support for Ramp parameters.
238245

239-
10.6.x.x (relative to 10.6.6.0)
246+
10.6.x.x (relative to 10.6.7.0)
240247
========
241248

242249

243250

251+
10.6.7.0 (relative to 10.6.6.0)
252+
========
253+
254+
Improvements
255+
------------
256+
257+
- USDScene : Added `IECOREUSD_WRITE_CONFORMANT_RENDERMAN_ATTRIBUTES` environment variable. If set to a value of `1`, this causes "ri:" prefixed attributes to be written as expected by `usdRiPxr`.
258+
244259
10.6.6.0 (relative to 10.6.5.0)
245260
========
246261

contrib/IECoreUSD/src/IECoreUSD/AttributeAlgo.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,19 @@ static const pxr::TfToken g_cortexPrimitiveVariableMetadataTokenDeprecated( "IEC
5555
static const std::string g_primVarPrefix = "primvars:";
5656
static const std::string g_primVarUserPrefix = "primvars:user:";
5757
static const std::string g_renderPrefix = "render:";
58+
static const std::string g_riPrefix = "ri:";
59+
static const std::string g_riAttributesPrefix = "ri:attributes:";
5860
static const std::string g_userPrefix = "user:";
5961

62+
bool writeConformantRenderManAttributes()
63+
{
64+
if( const char *e = getenv( "IECOREUSD_WRITE_CONFORMANT_RENDERMAN_ATTRIBUTES" ) )
65+
{
66+
return strcmp( e, "0" );
67+
}
68+
return false;
69+
}
70+
6071
}
6172

6273
bool IECoreUSD::AttributeAlgo::isCortexAttribute( const pxr::UsdGeomPrimvar &primVar )
@@ -122,12 +133,19 @@ pxr::TfToken IECoreUSD::AttributeAlgo::cortexPrimitiveVariableMetadataTokenDepre
122133

123134
IECoreUSD::AttributeAlgo::Name IECoreUSD::AttributeAlgo::nameToUSD( std::string name )
124135
{
136+
if( boost::starts_with( name, g_riPrefix ) && writeConformantRenderManAttributes() )
137+
{
138+
return { pxr::TfToken( g_riAttributesPrefix + name.substr( g_riPrefix.size() ) ), true };
139+
}
140+
125141
bool isPrimvar = false;
126142

127143
// The long term plan is to convert only "render:" prefixed attributes to primvars, and it will
128144
// be the client's responsibility to ensure everything important gets prefixed with "render:".
129145
// But for the moment, Gaffer doesn't do this yet, so we support the two most important prefixes
130-
// for Gaffer currently: "user:" and "ai:"
146+
// for Gaffer currently: "user:" and "ai:".
147+
/// \todo I don't think the `render:` plan is working out - it may well be better to just map
148+
/// all Cortex attributes to primvars.
131149
if( boost::starts_with( name, "render:" ) || boost::starts_with( name, "user:" ) || boost::starts_with( name, "ai:" ) )
132150
{
133151
isPrimvar = true;
@@ -170,7 +188,12 @@ IECoreUSD::AttributeAlgo::Name IECoreUSD::AttributeAlgo::nameToUSD( std::string
170188
IECore::InternedString IECoreUSD::AttributeAlgo::nameFromUSD( IECoreUSD::AttributeAlgo::Name name )
171189
{
172190
std::string nameStr = name.name;
173-
if( nameStr == "arnold:displacement" )
191+
192+
if( boost::starts_with( nameStr, g_riAttributesPrefix ) )
193+
{
194+
return g_riPrefix + nameStr.substr( g_riAttributesPrefix.size() );
195+
}
196+
else if( nameStr == "arnold:displacement" )
174197
{
175198
// Special case where the whole name is different, not just prefix
176199
nameStr = "ai:disp_map";
@@ -198,7 +221,9 @@ IECore::InternedString IECoreUSD::AttributeAlgo::nameFromUSD( IECoreUSD::Attribu
198221

199222
// The long term plan is to always prefix primitive variables converted to attributes with "render:".
200223
// But for the moment, Gaffer doesn't support this, so we skip the prefix for the two most important prefixes
201-
// for Gaffer currently: "user:" and "ai:"
224+
// for Gaffer currently: "user:" and "ai:".
225+
/// \todo I don't think the `render:` plan is working out - it may well be better to just map
226+
/// all Cortex attributes to primvars.
202227
if ( !boost::starts_with( nameStr, g_userPrefix ) && !boost::starts_with( nameStr, "ai:" ) && name.isPrimvar )
203228
{
204229
nameStr = "render:" + nameStr;

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5040,5 +5040,44 @@ def testOSLShaderForHDPrman( self ) :
50405040
self.assertEqual( loadedShaderNetwork.getShader( "scale" ).name, "floatAttribute" )
50415041
self.assertEqual( loadedShaderNetwork.getShader( "scale" ).type, "osl:shader" )
50425042

5043+
def testRenderManAttributeRoundTrip( self ) :
5044+
5045+
self.addCleanup( os.environ.__delitem__, "IECOREUSD_WRITE_CONFORMANT_RENDERMAN_ATTRIBUTES" )
5046+
5047+
for conformant in True, False :
5048+
5049+
with self.subTest( conformant = conformant ) :
5050+
5051+
os.environ["IECOREUSD_WRITE_CONFORMANT_RENDERMAN_ATTRIBUTES"] = str( int( conformant ) )
5052+
5053+
fileName = os.path.join( self.temporaryDirectory(), f"renderManAttributes{conformant}.usda" )
5054+
5055+
# Test writing to USD.
5056+
5057+
scene = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Write )
5058+
child = scene.createChild( "test" )
5059+
child.writeAttribute( "ri:trace:maxdiffusedepth", IECore.IntData( 2 ), 0 )
5060+
del scene, child
5061+
5062+
stage = pxr.Usd.Stage.Open( fileName )
5063+
5064+
if conformant :
5065+
primVars = pxr.UsdGeom.PrimvarsAPI( stage.GetPrimAtPath( "/test" ) )
5066+
diffuseDepth = primVars.GetPrimvar( "ri:attributes:trace:maxdiffusedepth" )
5067+
self.assertTrue( diffuseDepth.IsDefined() )
5068+
self.assertEqual( diffuseDepth.GetInterpolation(), "constant" )
5069+
self.assertTrue( diffuseDepth.HasAuthoredValue() )
5070+
self.assertTrue( diffuseDepth.Get( 0 ), 2 )
5071+
else :
5072+
diffuseDepth = stage.GetPrimAtPath( "/test" ).GetAttribute( "ri:trace:maxdiffusedepth" )
5073+
self.assertEqual( diffuseDepth.Get( 0 ), 2 )
5074+
5075+
# Test loading back to Cortex.
5076+
5077+
scene = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Read )
5078+
child = scene.child( "test" )
5079+
self.assertEqual( child.attributeNames(), [ "ri:trace:maxdiffusedepth" ] )
5080+
self.assertEqual( child.readAttribute( "ri:trace:maxdiffusedepth", 0 ), IECore.IntData( 2 ) )
5081+
50435082
if __name__ == "__main__":
50445083
unittest.main()

0 commit comments

Comments
 (0)