Skip to content

Commit

Permalink
Merge pull request #1406 from johnhaddon/lightsSet
Browse files Browse the repository at this point in the history
USDScene : Support round-tripping of non-UsdLux lights
  • Loading branch information
johnhaddon authored Feb 15, 2024
2 parents 3590653 + 87bd62d commit 356caab
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 68 deletions.
7 changes: 6 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
10.5.x.x (relative to 10.5.6.0)
========


Improvements
------------

- DisplayDriverServer : Fixed delays connecting to the server on Windows.

Fixes
-----

- USDScene : Fixed round-tripping of `__lights` set membership for non-UsdLux lights.

Build
-----

- SConstruct : Support detection of OpenEXR versions with a patch version containing multiple digits.


10.5.6.0 (relative to 10.5.5.0)
========

Expand Down
1 change: 0 additions & 1 deletion contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ IECore::PathMatcher localSet( const pxr::UsdPrim &prim, const pxr::TfToken &name
{
result.addPath( std::vector<IECore::InternedString>() );
}
return result;
}

const size_t prefixSize = prim.GetPath().GetPathElementCount();
Expand Down
28 changes: 28 additions & 0 deletions contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3973,5 +3973,33 @@ def testReadFromStageCache( self ) :
self.assertEqual( root.childNames(), [ "sphere" ] )
self.assertIsInstance( root.child( "sphere" ).readObject( 0 ), IECoreScene.SpherePrimitive )

def testRoundTripArnoldLight( self ) :

lightShader = IECoreScene.ShaderNetwork(
shaders = {
"light" : IECoreScene.Shader( "distant_light", parameters = { "exposure" : 2.0 } )
},
output = "light",
)

root = IECoreScene.SceneInterface.create(
os.path.join( self.temporaryDirectory(), "test.usda" ),
IECore.IndexedIO.OpenMode.Write
)
light = root.createChild( "light" )
light.writeAttribute( "ai:light", lightShader, 0 )
root.writeSet( "__lights", IECore.PathMatcher( [ "/light" ] ) )
del root, light

root = IECoreScene.SceneInterface.create(
os.path.join( self.temporaryDirectory(), "test.usda" ),
IECore.IndexedIO.OpenMode.Read
)
light = root.child( "light" )
self.assertIn( "ai:light", light.attributeNames() )
self.assertEqual( light.readAttribute( "ai:light", 0 ), lightShader )
self.assertIn( "__lights", root.setNames() )
self.assertEqual( root.readSet( "__lights" ), IECore.PathMatcher( [ "/light" ] ) )

if __name__ == "__main__":
unittest.main()
108 changes: 44 additions & 64 deletions contrib/IECoreUSD/test/IECoreUSD/data/arm.usda
Original file line number Diff line number Diff line change
@@ -1,73 +1,53 @@
#usda 1.0
# Source: https://graphics.pixar.com/usd/docs/api/_usd_skel__schema_overview.html
#Source: https://graphics.pixar.com/usd/docs/api/_usd_skel__schema_overview.html
(
startTimeCode = 1
endTimeCode = 10
endTimeCode = 10
startTimeCode = 1
upAxis = "Y"
)

def SkelRoot "Model" (
prepend apiSchemas = ["SkelBindingAPI"]
prepend apiSchemas = ["SkelBindingAPI"]
)
{
def Skeleton "Skel" {
uniform token[] joints = ["Shoulder", "Shoulder/Elbow", "Shoulder/Elbow/Hand"]
uniform matrix4d[] bindTransforms = [
((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1)),
((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,2,1)),
((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,4,1))
]
uniform matrix4d[] restTransforms = [
((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1)),
((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,2,1)),
((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,2,1))
]
def SkelAnimation "Anim" {
uniform token[] joints = ["Shoulder/Elbow"]
def Skeleton "Skel" (
prepend apiSchemas = ["SkelBindingAPI"]
)
{
uniform matrix4d[] bindTransforms = [( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) ), ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 2, 1) ), ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 4, 1) )]
uniform token[] joints = ["Shoulder", "Shoulder/Elbow", "Shoulder/Elbow/Hand"]
uniform matrix4d[] restTransforms = [( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) ), ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 2, 1) ), ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 2, 1) )]
rel skel:animationSource = </Model/Skel/Anim>

float3[] translations = [(0,0,2)]
quatf[] rotations.timeSamples = {
1: [(1,0,0,0)],
10: [(0.7071, 0.7071, 0, 0)]
}
half3[] scales = [(1,1,1)]
}
def SkelAnimation "Anim"
{
uniform token[] joints = ["Shoulder/Elbow"]
quatf[] rotations.timeSamples = {
1: [(1, 0, 0, 0)],
10: [(0.7071, 0.7071, 0, 0)],
}
half3[] scales = [(1, 1, 1)]
float3[] translations = [(0, 0, 2)]
}
}

rel skel:animationSource = <Anim>
}
def Mesh "Arm" (
prepend apiSchemas = ["SkelBindingAPI"]
)
{
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
int[] faceVertexIndices = [
2, 3, 1, 0,
6, 7, 5, 4,
8, 9, 7, 6,
3, 2, 9, 8,
10, 11, 4, 5,
0, 1, 11, 10,
7, 9, 10, 5,
9, 2, 0, 10,
3, 8, 11, 1,
8, 6, 4, 11
]
point3f[] points = [
(0.5, -0.5, 4), (-0.5, -0.5, 4), (0.5, 0.5, 4), (-0.5, 0.5, 4),
(-0.5, -0.5, 0), (0.5, -0.5, 0), (-0.5, 0.5, 0), (0.5, 0.5, 0),
(-0.5, 0.5, 2), (0.5, 0.5, 2), (0.5, -0.5, 2), (-0.5, -0.5, 2)
]
rel skel:skeleton = </Model/Skel>
int[] primvars:skel:jointIndices = [
2,2,2,2, 0,0,0,0, 1,1,1,1
] (
interpolation = "vertex"
elementSize = 1
)
float[] primvars:skel:jointWeights = [
1,1,1,1, 1,1,1,1, 1,1,1,1
] (
interpolation = "vertex"
elementSize = 1
)
matrix4d primvars:skel:geomBindTransform = ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1))
}
def Mesh "Arm" (
prepend apiSchemas = ["SkelBindingAPI"]
)
{
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
int[] faceVertexIndices = [2, 3, 1, 0, 6, 7, 5, 4, 8, 9, 7, 6, 3, 2, 9, 8, 10, 11, 4, 5, 0, 1, 11, 10, 7, 9, 10, 5, 9, 2, 0, 10, 3, 8, 11, 1, 8, 6, 4, 11]
point3f[] points = [(0.5, -0.5, 4), (-0.5, -0.5, 4), (0.5, 0.5, 4), (-0.5, 0.5, 4), (-0.5, -0.5, 0), (0.5, -0.5, 0), (-0.5, 0.5, 0), (0.5, 0.5, 0), (-0.5, 0.5, 2), (0.5, 0.5, 2), (0.5, -0.5, 2), (-0.5, -0.5, 2)]
matrix4d primvars:skel:geomBindTransform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) )
int[] primvars:skel:jointIndices = [2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1] (
elementSize = 1
interpolation = "vertex"
)
float[] primvars:skel:jointWeights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] (
elementSize = 1
interpolation = "vertex"
)
rel skel:skeleton = </Model/Skel>
}
}

9 changes: 7 additions & 2 deletions contrib/IECoreUSD/test/IECoreUSD/data/shaderNameConflict.usda
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#usda 1.0
(
upAxis = "Y"
)

def Xform "shaderLocation"
def Xform "shaderLocation" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
rel material:binding = </shaderLocation/materials/testMat>
custom float arnold:surface = 7
rel material:binding = </shaderLocation/materials/testMat>

def Scope "materials"
{
Expand Down

0 comments on commit 356caab

Please sign in to comment.