Exemplo n.º 1
0
    def testOneCamera(self):

        s = Gaffer.ScriptNode()

        s["camera"] = GafferScene.Camera("Camera")

        s["options"] = GafferScene.StandardOptions("StandardOptions")
        s["options"]["in"].setInput(s["camera"]["out"])
        s["options"]["options"]["renderCamera"]["value"].setValue('/camera')
        s["options"]["options"]["renderCamera"]["enabled"].setValue(True)

        s["render"] = GafferAppleseed.AppleseedRender()
        s["render"]["in"].setInput(s["options"]["out"])
        s["render"]["mode"].setValue(s["render"].Mode.SceneDescriptionMode)

        projectFilename = self.temporaryDirectory() + "/test.appleseed"
        s["render"]["fileName"].setValue(projectFilename)
        s["render"]["task"].execute()

        reader = asr.ProjectFileReader()
        options = asr.ProjectFileReaderOptions.OmitReadingMeshFiles
        project = reader.read(projectFilename, appleseedProjectSchemaPath(),
                              options)
        scene = project.get_scene()

        self.assertEqual(len(scene.cameras()), 1)
        camera = scene.cameras()[0]
        self.assertEqual(camera.get_name(), "/camera")

        frame = project.get_frame()
        self.assertEqual(frame.get_parameters()["camera"], camera.get_name())
Exemplo n.º 2
0
    def testCapsules(self):

        s = Gaffer.ScriptNode()

        s["sphere"] = GafferScene.Sphere("sphere")
        s["sphere1"] = GafferScene.Sphere("sphere1")

        s["group"] = GafferScene.Group("group")
        s["group"]["in"][0].setInput(s["sphere"]["out"])
        s["group"]["in"][1].setInput(s["sphere1"]["out"])

        s["path_filter"] = GafferScene.PathFilter("path_filter")
        s["path_filter"]["paths"].setValue(IECore.StringVectorData(['*']))

        s["encapsulate"] = GafferScene.Encapsulate("encapsulate")
        s["encapsulate"]["in"].setInput(s["group"]["out"])
        s["encapsulate"]["filter"].setInput(s["path_filter"]["out"])

        s["duplicate"] = GafferScene.Duplicate("duplicate")
        s["duplicate"]["in"].setInput(s["encapsulate"]["out"])
        s["duplicate"]["target"].setValue('group')
        s["duplicate"]["copies"].setValue(2)

        s["render"] = GafferAppleseed.AppleseedRender()
        s["render"]["in"].setInput(s["duplicate"]["out"])
        s["render"]["mode"].setValue(s["render"].Mode.SceneDescriptionMode)

        projectFilename = self.temporaryDirectory() + "/test.appleseed"

        s["render"]["fileName"].setValue(projectFilename)
        s["render"]["task"].execute()

        reader = asr.ProjectFileReader()
        options = asr.ProjectFileReaderOptions.OmitReadingMeshFiles
        project = reader.read(projectFilename, appleseedProjectSchemaPath(),
                              options)
        scene = project.get_scene()
        mainAssembly = scene.assemblies().get_by_name("assembly")

        # Check that we have 3 instances of 1 capsule.
        self.assertEqual(len(mainAssembly.assemblies()), 1)
        self.assertEqual(len(mainAssembly.assembly_instances()), 3)

        capsuleAssemblyName = mainAssembly.assemblies().keys()[0]
        capsuleAssembly = mainAssembly.assemblies()[capsuleAssemblyName]

        # Check that we have 2 instances of 1 sphere inside the capsule.
        self.assertEqual(len(capsuleAssembly.assemblies()), 1)
        self.assertEqual(len(capsuleAssembly.assembly_instances()), 2)
    def testAutoInstancingVaryingAttributes(self):

        s = Gaffer.ScriptNode()

        s["sphere"] = GafferScene.Sphere("Sphere")
        s["sphere1"] = GafferScene.Sphere("Sphere1")
        s["sphere2"] = GafferScene.Sphere("Sphere2")
        s["sphere3"] = GafferScene.Sphere("Sphere3")
        s["sphere4"] = GafferScene.Sphere("Sphere4")

        s["attributes"] = GafferAppleseed.AppleseedAttributes()
        s["attributes"]["in"].setInput(s["sphere4"]["out"])

        s["attributes"]["attributes"]["shadingSamples"]["enabled"].setValue(
            True)
        s["attributes"]["attributes"]["shadingSamples"]["value"].setValue(3)

        s["group"] = GafferScene.Group("Group")
        s["group"]["in"][0].setInput(s["sphere"]["out"])
        s["group"]["in"][1].setInput(s["sphere1"]["out"])
        s["group"]["in"][2].setInput(s["sphere2"]["out"])
        s["group"]["in"][3].setInput(s["sphere3"]["out"])
        s["group"]["in"][4].setInput(s["attributes"]["out"])

        s["render"] = GafferAppleseed.AppleseedRender()
        s["render"]["in"].setInput(s["group"]["out"])
        s["render"]["mode"].setValue(s["render"].Mode.SceneDescriptionMode)

        projectFilename = self.temporaryDirectory() + "/test.appleseed"
        s["render"]["fileName"].setValue(projectFilename)
        s["render"]["task"].execute()

        reader = asr.ProjectFileReader()
        options = asr.ProjectFileReaderOptions.OmitReadingMeshFiles
        project = reader.read(projectFilename, appleseedProjectSchemaPath(),
                              options)
        scene = project.get_scene()
        mainAssembly = scene.assemblies().get_by_name("assembly")

        self.assertEqual(len(mainAssembly.assemblies()), 1)
        self.assertEqual(len(mainAssembly.assembly_instances()), 4)
        self.assertEqual(len(mainAssembly.objects()), 1)
        self.assertEqual(len(mainAssembly.object_instances()), 1)
Exemplo n.º 4
0
    def testRectLightVisibilityAttributes(self):

        s = Gaffer.ScriptNode()

        s["diffuse_edf"] = GafferAppleseed.AppleseedLight("diffuse_edf")
        s["diffuse_edf"].loadShader("diffuse_edf")

        s["AppleseedAttributes"] = GafferAppleseed.AppleseedAttributes(
            "AppleseedAttributes")
        s["AppleseedAttributes"]["in"].setInput(s["diffuse_edf"]["out"])
        s["AppleseedAttributes"]["attributes"]["cameraVisibility"][
            "value"].setValue(False)
        s["AppleseedAttributes"]["attributes"]["cameraVisibility"][
            "enabled"].setValue(True)
        s["AppleseedAttributes"]["attributes"]["cameraVisibility"][
            "value"].setValue(False)
        s["AppleseedAttributes"]["attributes"]["cameraVisibility"][
            "enabled"].setValue(True)
        s["AppleseedAttributes"]["attributes"]["lightVisibility"][
            "value"].setValue(False)
        s["AppleseedAttributes"]["attributes"]["lightVisibility"][
            "enabled"].setValue(True)
        s["AppleseedAttributes"]["attributes"]["shadowVisibility"][
            "value"].setValue(False)
        s["AppleseedAttributes"]["attributes"]["shadowVisibility"][
            "enabled"].setValue(True)
        s["AppleseedAttributes"]["attributes"]["diffuseVisibility"][
            "value"].setValue(False)
        s["AppleseedAttributes"]["attributes"]["diffuseVisibility"][
            "enabled"].setValue(True)
        s["AppleseedAttributes"]["attributes"]["specularVisibility"][
            "value"].setValue(False)
        s["AppleseedAttributes"]["attributes"]["specularVisibility"][
            "enabled"].setValue(True)
        s["AppleseedAttributes"]["attributes"]["glossyVisibility"][
            "value"].setValue(False)
        s["AppleseedAttributes"]["attributes"]["glossyVisibility"][
            "enabled"].setValue(True)

        s["render"] = GafferAppleseed.AppleseedRender("AppleseedRender")
        s["render"]["in"].setInput(s["AppleseedAttributes"]["out"])
        s["render"]["mode"].setValue(s["render"].Mode.SceneDescriptionMode)

        projectFilename = self.temporaryDirectory() + "/test.appleseed"
        s["render"]["fileName"].setValue(projectFilename)
        s["render"]["task"].execute()

        reader = asr.ProjectFileReader()
        options = asr.ProjectFileReaderOptions.OmitReadingMeshFiles
        project = reader.read(projectFilename, appleseedProjectSchemaPath(),
                              options)
        scene = project.get_scene()
        mainAssembly = scene.assemblies().get_by_name("assembly")

        objInstance = mainAssembly.object_instances()[0]
        params = objInstance.get_parameters()

        visFlags = params['visibility']
        self.assertFalse(visFlags['camera'])
        self.assertFalse(visFlags['diffuse'])
        self.assertFalse(visFlags['glossy'])
        self.assertFalse(visFlags['light'])
        self.assertFalse(visFlags['shadow'])
        self.assertFalse(visFlags['specular'])