Skip to content

Commit 72d4e9f

Browse files
committed
Merge branch 'RB-10.4' into main
2 parents e7685e9 + abc0801 commit 72d4e9f

File tree

8 files changed

+127
-9
lines changed

8 files changed

+127
-9
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
os: windows-2019
7979
buildType: RELWITHDEBINFO
8080
options: .github/workflows/main/options.windows
81-
dependenciesURL: https://github.com/hypothetical-inc/gafferDependencies/releases/download/6.2.0/gafferDependencies-6.2.0-Python3-windows.zip
81+
dependenciesURL: https://github.com/hypothetical-inc/gafferDependencies/releases/download/6.2.1/gafferDependencies-6.2.1-Python3-windows.zip
8282
tests: testCore testCorePython testScene testImage testAlembic testUSD testVDB
8383
publish: false
8484

Changes

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
10.4.4.0 (relative to 10.4.3.1)
2+
========
3+
4+
Improvements
5+
------------
6+
7+
- USD :
8+
- Added loading of `float4` USD shader parameters as `Color4` parameters.
9+
- Added support for Arnold-USD's convention for representing connections to individual indices of an array.
10+
11+
Build
12+
-----
13+
14+
- Added compatibility with USD 23.02.
15+
- Updated Windows dependencies to 6.2.1.
16+
117
10.4.3.1 (relative to 10.4.3.0)
218
========
319

SConstruct

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ SConsignFile()
5656

5757
ieCoreMilestoneVersion = 10 # for announcing major milestones - may contain all of the below
5858
ieCoreMajorVersion = 4 # backwards-incompatible changes
59-
ieCoreMinorVersion = 3 # new backwards-compatible features
60-
ieCorePatchVersion = 1 # bug fixes
59+
ieCoreMinorVersion = 4 # new backwards-compatible features
60+
ieCorePatchVersion = 0 # bug fixes
6161
ieCoreVersionSuffix = "" # used for alpha/beta releases. Example: "a1", "b2", etc.
6262

6363
###########################################################################################

contrib/IECoreUSD/src/IECoreUSD/DataAlgo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ static const std::map<pxr::TfType, IECore::DataPtr (*)( const pxr::VtValue &, Ge
215215
{ TfType::Find<VtArray<GfVec2f>>(), &dataFromArray<GfVec2f> },
216216
{ TfType::Find<GfVec3f>(), &dataFromValue<GfVec3f> },
217217
{ TfType::Find<VtArray<GfVec3f>>(), &dataFromArray<GfVec3f> },
218+
{ TfType::Find<GfVec4f>(), &dataFromValue<GfVec4f> },
219+
{ TfType::Find<VtArray<GfVec4f>>(), &dataFromArray<GfVec4f> },
218220
{ TfType::Find<GfVec2d>(), &dataFromValue<GfVec2d> },
219221
{ TfType::Find<VtArray<GfVec2d>>(), &dataFromArray<GfVec2d> },
220222
{ TfType::Find<GfVec3d>(), &dataFromValue<GfVec3d> },

contrib/IECoreUSD/src/IECoreUSD/ShaderAlgo.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
#include "boost/algorithm/string/replace.hpp"
5050
#include "boost/pointer_cast.hpp"
5151

52+
#include <regex>
53+
5254
#if PXR_VERSION < 2102
5355
#define IsContainer IsNodeGraph
5456
#endif
@@ -98,6 +100,25 @@ void readAdditionalLightParameters( const pxr::UsdPrim &prim, IECore::CompoundDa
98100
#endif
99101
}
100102

103+
const std::regex g_arrayIndexFromUSDRegex( ":i([0-9]+)$" );
104+
const std::string g_arrayIndexFromUSDFormat( "[$1]" );
105+
IECore::InternedString fromUSDParameterName( const pxr::TfToken &usdName )
106+
{
107+
// USD doesn't support connections to array indices. So Arnold-USD emulates
108+
// them using its own `parameter:i<N>`syntax - see https://github.com/Autodesk/arnold-usd/pull/381.
109+
// We convert these to the regular `parameter[N]` syntax during loading.
110+
return std::regex_replace( usdName.GetString(), g_arrayIndexFromUSDRegex, g_arrayIndexFromUSDFormat );
111+
}
112+
113+
const std::regex g_arrayIndexFromCortexRegex( "\\[([0-9]+)\\]$" );
114+
const std::string g_arrayIndexFromCortexFormat( ":i$1" );
115+
pxr::TfToken toUSDParameterName( IECore::InternedString cortexName )
116+
{
117+
return pxr::TfToken(
118+
std::regex_replace( cortexName.string(), g_arrayIndexFromCortexRegex, g_arrayIndexFromCortexFormat )
119+
);
120+
}
121+
101122
IECoreScene::ShaderNetwork::Parameter readShaderNetworkWalk( const pxr::SdfPath &anchorPath, const pxr::UsdShadeOutput &output, IECoreScene::ShaderNetwork &shaderNetwork );
102123

103124
IECore::InternedString readShaderNetworkWalk( const pxr::SdfPath &anchorPath, const pxr::UsdShadeConnectableAPI &usdShader, IECoreScene::ShaderNetwork &shaderNetwork )
@@ -146,7 +167,7 @@ IECore::InternedString readShaderNetworkWalk( const pxr::SdfPath &anchorPath, co
146167
anchorPath, usdSource.GetOutput( usdSourceName ), shaderNetwork
147168
);
148169
connections.push_back( {
149-
sourceHandle, { handle, IECore::InternedString( i.GetBaseName().GetString() ) }
170+
sourceHandle, { handle, fromUSDParameterName( i.GetBaseName() ) }
150171
} );
151172
}
152173
else
@@ -160,7 +181,7 @@ IECore::InternedString readShaderNetworkWalk( const pxr::SdfPath &anchorPath, co
160181

161182
if( IECore::DataPtr d = IECoreUSD::DataAlgo::fromUSD( pxr::UsdAttribute( valueAttribute ) ) )
162183
{
163-
parameters[ i.GetBaseName().GetString() ] = d;
184+
parameters[fromUSDParameterName( i.GetBaseName() )] = d;
164185
}
165186
}
166187

@@ -244,7 +265,7 @@ pxr::UsdShadeOutput IECoreUSD::ShaderAlgo::writeShaderNetwork( const IECoreScene
244265
for( const auto &p : expandedParameters->readable() )
245266
{
246267
pxr::UsdShadeInput input = usdShader.CreateInput(
247-
pxr::TfToken( p.first.string() ),
268+
toUSDParameterName( p.first ),
248269
DataAlgo::valueTypeName( p.second.get() )
249270
);
250271
input.Set( DataAlgo::toUSD( p.second.get() ) );
@@ -278,7 +299,7 @@ pxr::UsdShadeOutput IECoreUSD::ShaderAlgo::writeShaderNetwork( const IECoreScene
278299
pxr::UsdShadeInput dest = usdShader.GetInput( pxr::TfToken( c.destination.name.string() ) );
279300
if( ! dest.GetPrim().IsValid() )
280301
{
281-
dest = usdShader.CreateInput( pxr::TfToken( c.destination.name.string() ), pxr::SdfValueTypeNames->Token );
302+
dest = usdShader.CreateInput( toUSDParameterName( c.destination.name ), pxr::SdfValueTypeNames->Token );
282303
}
283304

284305
pxr::UsdShadeShader sourceUsdShader = pxr::UsdShadeShader::Get( shaderContainer.GetStage(), shaderContainer.GetPath().AppendChild( pxr::TfToken( pxr::TfMakeValidIdentifier( c.source.shader.string() ) ) ) );

contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ IECORE_POP_DEFAULT_VISIBILITY
8282
#include "tbb/concurrent_hash_map.h"
8383

8484
#include <iostream>
85+
#include <mutex>
8586

8687
using namespace IECore;
8788
using namespace IECoreScene;

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ def testPrimVarTypes ( self ) :
283283
'test_Float2_Scalar_constant' : IECore.V2fData( imath.V2f( 0.1, 0.2 ) ),
284284
'test_Float3_Array_constant' : IECore.V3fVectorData( [imath.V3f( 1.1, 1.2, 1.3 ), imath.V3f( 2.1, 2.2, 2.3 ), imath.V3f( 3.1, 3.2, 3.3 )] ),
285285
'test_Float3_Scalar_constant' : IECore.V3fData( imath.V3f( 0.1, 0.2, 0.3 ) ),
286+
'test_Float4_Array_constant' : IECore.Color4fVectorData( [imath.Color4f( 1.1, 1.2, 1.3, 1.4 ), imath.Color4f( 2.1, 2.2, 2.3, 2.4 ), imath.Color4f( 3.1, 3.2, 3.3, 3.4 )] ),
287+
'test_Float4_Scalar_constant' : IECore.Color4fData( imath.Color4f( 0.1, 0.2, 0.3, 0.4 ) ),
286288
'test_Float_Array_constant' : IECore.FloatVectorData( [0.7, 0.8, 0.9] ),
287289
'test_Float_Scalar_constant' : IECore.FloatData( 0.6 ),
288290
'test_Half_Array_constant' : IECore.HalfVectorData( [0.0999756, 0.199951, 0.300049] ),
@@ -2482,7 +2484,7 @@ def assertAttributesValues( sphere ):
24822484

24832485
# Check that the USD file written looks as expected
24842486
stage = pxr.Usd.Stage.Open( fileName )
2485-
sphereUsd = pxr.UsdGeom.Imageable( stage.GetPrimAtPath( "/sphere" ) )
2487+
sphereUsd = pxr.UsdGeom.PrimvarsAPI( stage.GetPrimAtPath( "/sphere" ) )
24862488
self.assertEqual( sphereUsd.GetPrim().GetAttribute( "customNamespaced:testAnimated" ).Get( 0 ), 0 )
24872489
self.assertEqual( sphereUsd.GetPrimvar( "test" ).Get( 0 ), "cyan" )
24882490
self.assertEqual( sphereUsd.GetPrimvar( "user:bongo" ).Get( 0 ), "cyan" )
@@ -2491,7 +2493,7 @@ def assertAttributesValues( sphere ):
24912493
self.assertEqual( sphereUsd.GetPrim().GetAttribute( "radius" ).Get( 0 ), 10 )
24922494
self.assertEqual( sphereUsd.GetPrim().GetAttribute( "studio:foo" ).Get( 0 ), "brown" )
24932495

2494-
abUsd = pxr.UsdGeom.Imageable( stage.GetPrimAtPath( "/ab" ) )
2496+
abUsd = pxr.UsdGeom.PrimvarsAPI( stage.GetPrimAtPath( "/ab" ) )
24952497
self.assertEqual( abUsd.GetPrimvar( "bar" ).Get( 0 ), "black" )
24962498
self.assertEqual( abUsd.GetPrimvar( "bar" ).GetAttr().GetMetadata( "cortex_isConstantPrimitiveVariable" ), True )
24972499
self.assertEqual( abUsd.GetPrimvar( "notUserPrefixAttribute" ).Get( 0 ), "orange" )
@@ -3271,5 +3273,34 @@ def testPointInstancerPrimvars( self ) :
32713273
self.assertEqual( points["myColor"].interpolation, IECoreScene.PrimitiveVariable.Interpolation.Vertex )
32723274
self.assertEqual( points["myColor"].indices, None )
32733275

3276+
def testArnoldArrayInputs( self ) :
3277+
3278+
def assertExpectedArrayInputs( network ) :
3279+
3280+
inputs = network.inputConnections( "rampRGB" )
3281+
self.assertEqual( len( inputs ), 2 )
3282+
self.assertEqual( inputs[0], ( ( "noise", "out" ), ( "rampRGB", "color[0]" ) ) )
3283+
self.assertEqual( inputs[1], ( ( "flat", "out" ), ( "rampRGB", "color[1]" ) ) )
3284+
3285+
# Load original USD out of USD-Arnold.
3286+
3287+
scene = IECoreScene.SceneInterface.create(
3288+
os.path.join( os.path.dirname( __file__ ), "data", "arnoldArrayInputs.usda" ),
3289+
IECore.IndexedIO.OpenMode.Read
3290+
)
3291+
network = scene.child( "sphere" ).readAttribute( "ai:surface", 0 )
3292+
3293+
assertExpectedArrayInputs( network )
3294+
3295+
# Write our own USD from that data, to check we can round-trip it.
3296+
3297+
fileName = os.path.join( self.temporaryDirectory(), "arnoldArrayInputsRewritten.usda" )
3298+
scene = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Write )
3299+
scene.createChild( "sphere" ).writeAttribute( "ai:surface", network, 0 )
3300+
3301+
del scene
3302+
scene = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Read )
3303+
assertExpectedArrayInputs( scene.child( "sphere" ).readAttribute( "ai:surface", 0 ) )
3304+
32743305
if __name__ == "__main__":
32753306
unittest.main()
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#usda 1.0
2+
3+
def Sphere "sphere"
4+
{
5+
rel material:binding = </rampSurface>
6+
}
7+
8+
def Material "rampSurface"
9+
{
10+
token outputs:arnold:surface.connect = </rampSurface/standardSurface.outputs:surface>
11+
12+
def Shader "standardSurface"
13+
{
14+
uniform token info:id = "arnold:standard_surface"
15+
color3f inputs:base_color = (0.8, 0.8, 0.8)
16+
prepend color3f inputs:base_color.connect = </rampSurface/rampRGB.outputs:out>
17+
float inputs:indirect_specular = 0
18+
token outputs:surface
19+
}
20+
21+
def Shader "rampRGB"
22+
{
23+
uniform token info:id = "arnold:ramp_rgb"
24+
color3f[] inputs:color = [(0, 0, 0), (0.5, 0.5, 0.5)]
25+
prepend color3f inputs:color:i0.connect = </rampSurface/noise.outputs:out>
26+
prepend color3f inputs:color:i1.connect = </rampSurface/flat.outputs:out>
27+
int[] inputs:interpolation = [1, 1]
28+
float[] inputs:position = [0, 1]
29+
token inputs:type = "v"
30+
color3f outputs:out
31+
}
32+
33+
def Shader "noise"
34+
{
35+
uniform token info:id = "arnold:noise"
36+
color3f inputs:color1 = (1, 0, 0)
37+
color3f inputs:color2 = (0, 1, 0)
38+
color3f outputs:out
39+
}
40+
41+
def Shader "flat"
42+
{
43+
uniform token info:id = "arnold:flat"
44+
color3f inputs:color = (0, 0, 1)
45+
color3f outputs:out
46+
}
47+
}

0 commit comments

Comments
 (0)