def testOSLShaders(self): swizzle = GafferOSL.OSLShader() swizzle.loadShader("MaterialX/mx_swizzle_color_float") swizzle["parameters"]["in"].setValue(imath.Color3f(0, 0, 1)) swizzle["parameters"]["channels"].setValue("b") pack = GafferOSL.OSLShader() pack.loadShader("MaterialX/mx_pack_color") pack["parameters"]["in1"].setInput(swizzle["out"]["out"]) ball = GafferArnold.ArnoldShaderBall() ball["shader"].setInput(pack["out"]) outputs = GafferScene.Outputs() outputs.addOutput( "beauty", IECoreScene.Output("test", "ieDisplay", "rgba", { "driverType": "ImageDisplayDriver", "handle": "myLovelySphere", })) outputs["in"].setInput(ball["out"]) render = GafferArnold.ArnoldRender() render["in"].setInput(outputs["out"]) render["task"].execute() image = IECoreImage.ImageDisplayDriver.storedImage("myLovelySphere") self.assertTrue(isinstance(image, IECoreImage.ImagePrimitive)) self.assertEqual(self.__color4fAtUV(image, imath.V2f(0.5)), imath.Color4f(1, 0, 0, 1))
def __arnoldShaderBall(): result = GafferArnold.ArnoldShaderBall() # Reserve some cores for the rest of the UI result["threads"]["enabled"].setValue(True) result["threads"]["value"].setValue(-3) return result
def testOSLShaders( self ) : purple = GafferOSL.OSLShader() purple.loadShader( "Maths/MixColor" ) purple["parameters"]["a"].setValue( imath.Color3f( 0.5, 0, 1 ) ) green = GafferOSL.OSLShader() green.loadShader( "Maths/MixColor" ) green["parameters"]["a"].setValue( imath.Color3f( 0, 1, 0 ) ) mix = GafferOSL.OSLShader() mix.loadShader( "Maths/MixColor" ) # test component connections mix["parameters"]["a"][2].setInput( purple["out"]["out"][2] ) # test color connections mix["parameters"]["b"].setInput( green["out"]["out"] ) mix["parameters"]["m"].setValue( 0.5 ) ball = GafferArnold.ArnoldShaderBall() ball["shader"].setInput( mix["out"] ) catalogue = GafferImage.Catalogue() outputs = GafferScene.Outputs() outputs.addOutput( "beauty", IECoreScene.Output( "test", "ieDisplay", "rgba", { "driverType" : "ClientDisplayDriver", "displayHost" : "localhost", "displayPort" : str( catalogue.displayDriverServer().portNumber() ), "remoteDisplayType" : "GafferImage::GafferDisplayDriver", } ) ) outputs["in"].setInput( ball["out"] ) render = GafferArnold.ArnoldRender() render["in"].setInput( outputs["out"] ) with GafferTest.ParallelAlgoTest.UIThreadCallHandler() as handler : render["task"].execute() handler.waitFor( 0.1 ) #Just need to let the catalogue update self.assertEqual( self.__color4fAtUV( catalogue, imath.V2f( 0.5 ) ), imath.Color4f( 0, 0.5, 0.5, 1 ) )
def test( self ) : n = GafferArnold.ArnoldShaderBall() self.assertSceneValid( n["out"] )