Skip to content

Commit

Permalink
GafferCycles :
Browse files Browse the repository at this point in the history
- Refactor the problematic reset code as we now only allow scene/session parameters to be set before rendering starts.
- This will also avoid a mutex lock issue with Windows.
- Remove render states and just have an m_rendering bool
- Removed `removeOSLShaders()`, Cycles seems more hardy at not crashing when this happens now
  • Loading branch information
boberfly committed Mar 31, 2023
1 parent 3c1cc5f commit 8307715
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 227 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Fixes
- SceneReader : Fixed reading of USD primitives containing `primvars:normals`. These are now correctly loaded as a primitive variable called N, taking precedence over the UsdGeomPointBased normals attribute.
- SceneWriter : Fixed writing of indexed normals to USD files, so that the indexing is retained on load. Note that this means that normals are now always written as `primvars:normals` and never via the UsdGeomPointBased `normals` attribute.
- CompoundDataPlugValueWidget : Fixed bug which prevented the addition of new plugs when an existing plug had an input connection. This affected the ContextVariables, CustomOptions and CustomAttributes nodes, among others.
- Cycles : Refactor the problematic reset code, we now only allow scene/session parameters to be set before rendering starts (#5101). Fixes (#5234)

API
---
Expand Down
58 changes: 58 additions & 0 deletions python/GafferCyclesTest/IECoreCyclesPreviewTest/RendererTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1823,5 +1823,63 @@ def testUnsupportedShaderParameters( self ) :
"Unsupported socket type `transform` for socket `ob_tfm` on node .*"
)

def testOSLInSVMShadingSystem( self ) :

renderer = GafferScene.Private.IECoreScenePreview.Renderer.create(
"Cycles",
GafferScene.Private.IECoreScenePreview.Renderer.RenderType.Interactive,
)

renderer.option( "cycles:shadingsystem", IECore.StringData( "SVM" ) )

renderer.output(
"testOutput",
IECoreScene.Output(
"test",
"ieDisplay",
"rgba",
{
"driverType" : "ImageDisplayDriver",
"handle" : "testOSLInSVMShadingSystem",
}
)
)

plane = renderer.object(
"/plane",
IECoreScene.MeshPrimitive.createPlane(
imath.Box2f( imath.V2f( -1 ), imath.V2f( 1 ) ),
),
renderer.attributes( IECore.CompoundObject ( {
"cycles:surface" : IECoreScene.ShaderNetwork(
shaders = {
"output" : IECoreScene.Shader(
"Surface/Constant", "osl:shader",
{ "Cs" : imath.Color3f( 0, 1, 0 ) }
),
},
output = "output",
)
} ) )
)
## \todo Default camera is facing down +ve Z but should be facing
# down -ve Z.
plane.transform( imath.M44f().translate( imath.V3f( 0, 0, 1 ) ) )

renderer.render()
time.sleep( 2 )

image = IECoreImage.ImageDisplayDriver.storedImage( "testOSLInSVMShadingSystem" )
self.assertIsInstance( image, IECoreImage.ImagePrimitive )

# Slightly off-centre, to avoid triangle edge artifact in centre of image.
testPixel = self.__colorAtUV( image, imath.V2f( 0.55 ) )
# Shader should be black and not crash.
self.assertEqual( testPixel.r, 0 )
self.assertEqual( testPixel.g, 0 )
self.assertEqual( testPixel.b, 0 )

del plane

if __name__ == "__main__":
unittest.main()
Loading

0 comments on commit 8307715

Please sign in to comment.