def filmSetOutputChannel(self, type): # Stop the rendering self.session.Stop() self.session = None # Delete old channel outputs self.config.Delete("film.outputs") # Set the new channel outputs self.config.Parse(pyluxcore.Properties().Set( pyluxcore.Property( "film.outputs.1.type", ["RGB_IMAGEPIPELINE"])).Set( pyluxcore.Property( "film.outputs.1.filename", ["luxball_RGB_IMAGEPIPELINE.png"])).Set( pyluxcore.Property( "film.outputs.2.type", [str(type)])).Set( pyluxcore.Property( "film.outputs.2.filename", ["luxball_SELECTED_OUTPUT.exr"]))) self.selectedFilmChannel = type # Re-start the rendering self.session = pyluxcore.RenderSession(self.config) self.session.Start() print("Film channel selected: %s" % (str(type)))
def LuxCoreNetNode(argv): parser = argparse.ArgumentParser(description="PyLuxCoreNetNode") parser.add_argument("-b", "--broadcast-address", metavar="BROADCAST_ADDRESS", default="<broadcast>", help="broadcast address to use ('none' to disable)") parser.add_argument("-t", "--broadcast-period", metavar="SECS", type=float, default=3.0, help="broadcast period") parser.add_argument("-a", "--address", metavar="IP_ADDRESS", default="", help="ip address to use") parser.add_argument("-p", "--port", metavar="PORT", type=int, default=renderfarm.DEFAULT_PORT, help="port to use") parser.add_argument("-D", "--define", metavar=("PROP_NAME", "VALUE"), nargs=2, action="append", help="assign a value to a property") # Parse command line arguments args = parser.parse_args(argv) cmdLineProp = pyluxcore.Properties() if (args.define): for (name, value) in args.define: cmdLineProp.Set(pyluxcore.Property(name, value)) renderFarmNode = renderfarmnode.RenderFarmNode(args.address, args.port, args.broadcast_address, args.broadcast_period, cmdLineProp) renderFarmNode.Start() renderFarmNode.Wait() logger.info("Done.")
def test_Properties_ToString(self): props = pyluxcore.Properties() props.Set(pyluxcore.Property("test1.prop1", "aa")) props.Set(pyluxcore.Property("test1.prop2", "bb")) props.Set(pyluxcore.Property("test2.prop1.aa", "cc")) self.assertEqual(props.ToString(), 'test1.prop1 = "aa"\ntest1.prop2 = "bb"\ntest2.prop1.aa = "cc"\n')
def luxBallMatGlossyImageMap(self): # Begin scene editing self.session.BeginSceneEdit() # Define check map imageMap = array('f', [0.0] * (128 * 128 * 3)) for y in range(128): for x in range(128): offset = (x + y * 128) * 3 if (x % 64 < 32) ^ (y % 64 < 32): imageMap[offset] = 1.0 imageMap[offset] = 1.0 imageMap[offset] = 1.0 else: imageMap[offset] = 1.0 imageMap[offset] = 0.0 imageMap[offset] = 0.0 ######################################################################## # NOTICE THE DIFFERENT BEHAVIOR REQUIRED BY PYTHON 2.7 ######################################################################## self.scene.DefineImageMap( "check_map", buffer(imageMap) if sys.version_info < (3, 0, 0) else imageMap, 2.2, 3, 128, 128) # Edit the material self.scene.Parse(pyluxcore.Properties().Set( pyluxcore.Property("scene.textures.tex.type", ["imagemap"])).Set( pyluxcore.Property("scene.textures.tex.file", [ "check_map" ])).Set(pyluxcore.Property( "scene.textures.tex.gain", [0.6])).Set( pyluxcore.Property( "scene.textures.tex.mapping.uvscale", [16, -16])).Set( pyluxcore.Property( "scene.materials.shell.type", ["glossy2"])).Set( pyluxcore.Property( "scene.materials.shell.kd", ["tex"])).Set( pyluxcore.Property( "scene.materials.shell.ks", [0.25, 0.0, 0.0])). Set( pyluxcore.Property( "scene.materials.shell.uroughness", [0.05])).Set( pyluxcore.Property( "scene.materials.shell.vroughness", [0.05]))) # To remove unreferenced constant textures defined implicitly self.scene.RemoveUnusedTextures() # To remove all unreferenced image maps (note: the order of call does matter) self.scene.RemoveUnusedImageMaps() # End scene editing self.session.EndSceneEdit() print("LuxBall material set to: Glossy with image map")
def ExtractConfiguration(): print( "Extracting Film configuration example (requires scenes directory)...") # Load the configuration from file props = pyluxcore.Properties("scenes/luxball/luxball-hdr-comp.cfg") # Change the render engine to PATHCPU props.Set(pyluxcore.Property("renderengine.type", ["PATHCPU"])) config = pyluxcore.RenderConfig(props) session = pyluxcore.RenderSession(config) # Extract the RenderConfig properties (redundant here) props = session.GetRenderConfig().GetProperties() ids = set() for i in props.GetAllUniqueSubNames("film.outputs"): if props.Get(i + ".type").GetString() == "MATERIAL_ID_MASK": ids.add(props.Get(i + ".id").GetInt()) for i in ids: print("MATERIAL_ID_MASK ID => %d" % i) print("Done.")
def test_Film_ConvTest(self): # Load the configuration from file props = pyluxcore.Properties("resources/scenes/simple/simple.cfg") # Change the render engine to PATHCPU props.Set(pyluxcore.Property("renderengine.type", ["PATHCPU"])) props.Set(pyluxcore.Property("sampler.type", ["RANDOM"])) props.Set(GetDefaultEngineProperties("PATHCPU")) # Replace halt condition props.Delete("batch.haltdebug") # Run at full speed props.Delete("native.threads.count") props.Set(pyluxcore.Property("batch.haltthreshold", 0.075)) props.Set(pyluxcore.Property("batch.haltthreshold.step", 16)) config = pyluxcore.RenderConfig(props) session = pyluxcore.RenderSession(config) session.Start() while True: time.sleep(0.5) # Update statistics (and run the convergence test) session.UpdateStats() if session.HasDone(): # Time to stop the rendering break session.Stop() image = GetImagePipelineImage(session.GetFilm()) CheckResult(self, image, "Film_ConvTest", False)
def SimpleRender(): # Load the configuration from file props = pyluxcore.Properties("scenes/luxball/luxball-hdr.cfg") # Change the render engine props.Set(pyluxcore.Property("renderengine.type", ["PATHOCL"])) props.Set(pyluxcore.Property("opencl.devices.select", ["01000"])) props.Set(pyluxcore.Property("film.hw.enable", ["0"])) props.Set(pyluxcore.Property("opencl.native.threads.count", [0])) config = pyluxcore.RenderConfig(props) session = pyluxcore.RenderSession(config) session.Start() startTime = time.time() while True: time.sleep(1) elapsedTime = time.time() - startTime if elapsedTime > 1.0: # Time to stop the rendering break session.Stop()
def test_Properties_GetAllNamesRE(self): props = pyluxcore.Properties() props.Set(pyluxcore.Property("test1.prop1", "aa")) props.Set(pyluxcore.Property("test1.prop2", "bb")) props.Set(pyluxcore.Property("test2.prop1", "cc")) self.assertEqual(props.GetAllNamesRE(".*\\.prop1"), ["test1.prop1", "test2.prop1"])
def LoadFilm(filmFileName, hasPixelNormalizedChannel, hasScreenNormalizedChannel): fileExt = os.path.splitext(filmFileName)[1] if (fileExt == ".cfg"): # It is a properties file # At least, one of the 2 options must be enabled if (not hasPixelNormalizedChannel) and ( not hasScreenNormalizedChannel): raise TypeError( "At least CHANNEL_RADIANCE_PER_PIXEL_NORMALIZED or CHANNEL_RADIANCE_PER_SCREEN_NORMALIZED must be enabled." "The film would have no content: " + filmFileName) props = pyluxcore.Properties(filmFileName) return pyluxcore.Film(props, hasPixelNormalizedChannel, hasScreenNormalizedChannel) elif (fileExt == ".flm"): # It is a stand alone film return pyluxcore.Film(filmFileName) elif (fileExt == ".rsm"): # It is a resume rendering file (config, startState, startFilm) = pyluxcore.RenderConfig.LoadResumeFile(filmFileName) return startFilm else: raise TypeError("Unknown film file type: " + filmFileName)
def luxBallMatGlass(self): # Begin scene editing self.session.BeginSceneEdit() # Edit the material self.scene.Parse(pyluxcore.Properties().Set( pyluxcore.Property("scene.materials.shell.type", ["glass"])).Set( pyluxcore.Property( "scene.materials.shell.kr", [0.69, 0.78, 1.0])).Set( pyluxcore.Property( "scene.materials.shell.kt", [0.69, 0.78, 1.0])).Set( pyluxcore.Property( "scene.materials.shell.ioroutside", [1.0])).Set( pyluxcore.Property( "scene.materials.shell.iorinside", [1.45]))) # To remove unreferenced constant textures defined implicitly self.scene.RemoveUnusedTextures() # To remove all unreferenced image maps (note: the order of call does matter) self.scene.RemoveUnusedImageMaps() # End scene editing self.session.EndSceneEdit() print("LuxBall material set to: Glass")
def SimpleRender(): # Load the configuration from file props = pyluxcore.Properties("scenes/luxball/luxball-hdr.cfg") # Change the render engine to PATHCPU props.Set(pyluxcore.Property("renderengine.type", ["PATHCPU"])) #props.Set(pyluxcore.Property("opencl.devices.select", ["0100"])) config = pyluxcore.RenderConfig(props) session = pyluxcore.RenderSession(config) session.Start() startTime = time.time() while True: time.sleep(1) elapsedTime = time.time() - startTime if elapsedTime > 1.0: # Time to stop the rendering break session.Stop() # Save the rendered image session.GetFilm().Save()
def TestSceneEditRendering(cls, params): engineType = params[0] samplerType = params[1] renderConfigAdditionalProps = params[2] isDeterministic = params[3] # Create the rendering configuration cfgProps = pyluxcore.Properties() cfgProps.SetFromFile("resources/scenes/simple/simple.cfg") # Set the rendering engine cfgProps.Set(pyluxcore.Property("renderengine.type", engineType)) # Set the sampler cfgProps.Set(pyluxcore.Property("sampler.type", samplerType)) cfgProps.Set(renderConfigAdditionalProps) cfgProps.Set(LuxCoreTest.customConfigProps) config = pyluxcore.RenderConfig(cfgProps) # Run the rendering StandardAnimTest( cls, "SceneEditRendering_" + engineType + ("" if not samplerType else ("_" + samplerType)), config, 5, isDeterministic)
def LoadFilm(): print("Film loading...") t1 = Clock() film = pyluxcore.Film("simple.flm") t2 = Clock() print("Film load time: %s secs" % (t2 - t1)) # Define the new image pipeline props = pyluxcore.Properties() props.SetFromString(""" film.imagepipeline.0.type = TONEMAP_LINEAR film.imagepipeline.0.scale = 1.0 film.imagepipeline.1.type = CAMERA_RESPONSE_FUNC film.imagepipeline.1.name = Ektachrome_320TCD film.imagepipeline.2.type = GAMMA_CORRECTION film.imagepipeline.2.value = 2.2 """) film.Parse(props) # Save the tonemapped AOV print("RGB_TONEMAPPED saving...") film.SaveOutput("simple.png", pyluxcore.FilmOutputType.RGB_IMAGEPIPELINE, pyluxcore.Properties()) # Animate radiance groups for i in range(0, 20): props = pyluxcore.Properties() props.SetFromString(""" film.radiancescales.0.globalscale = """ + str(0.025 + (19 - i) * (3.0 / 19.0)) + """ film.radiancescales.1.globalscale = """ + str(0.025 + i * (3.0 / 19.0)) + """ """) film.Parse(props) print("Frame " + str(i) + " saving...") film.SaveOutput("simple" + str(i) + ".png", pyluxcore.FilmOutputType.RGB_IMAGEPIPELINE, pyluxcore.Properties()) print("Film saving...") t1 = Clock() film.SaveFilm("simple2.flm") t2 = Clock() print("Film save time: %s secs" % (t2 - t1)) print("Done.")
def test_Properties_IsDefined(self): props = pyluxcore.Properties() props.Set(pyluxcore.Property("test1.prop1", "aa")) props.Set(pyluxcore.Property("test1.prop2", "bb")) props.Set(pyluxcore.Property("test2.prop1.aa", "cc")) self.assertEqual(props.IsDefined("test1.prop2"), True) self.assertEqual(props.IsDefined("test1.prop2.aa"), False)
def test_Properties_SetFromFile(self): props = pyluxcore.Properties() props.SetFromFile("resources/test.properties") self.assertEqual(props.GetSize(), 4) self.assertEqual(props.Get("test1.prop1.aa").Get(), ["aa"]) self.assertEqual(props.Get("test1.prop1.bb").Get(), ["aa", "bb"]) self.assertEqual(props.Get("test1.prop2.aa").Get(), ["aa"]) self.assertEqual(props.Get("test2.prop1.aa").Get(), ["aa"])
def test_Scene_RemoveUnusedMeshes(self): editProps = pyluxcore.Properties() editProps.SetFromString(""" scene.objects.box2.ply = resources/scenes/simple/simple-mat-cube1.ply scene.objects.box2.material = mat_sphere """) self.RunRemoveUnusedTest("Scene_RemoveUnusedMeshes", False, False, False, True, editProps)
def test_Scene_RemoveUnusedMaterials(self): editProps = pyluxcore.Properties() editProps.SetFromString(""" scene.materials.mat_sphere.type = matte scene.materials.mat_sphere.kd = 0.0 0.0 0.75 """) self.RunRemoveUnusedTest("Scene_RemoveUnusedMaterials", False, False, True, False, editProps)
def test_Scene_RemoveUnusedTextures(self): editProps = pyluxcore.Properties() editProps.SetFromString(""" scene.textures.imagemap.type = constfloat3 scene.textures.imagemap.value = 0.0 0.75 0.0 """) self.RunRemoveUnusedTest("Scene_RemoveUnusedTextures", False, True, False, False, editProps)
def test_Properties_HaveNamesRE(self): props = pyluxcore.Properties() props.Set(pyluxcore.Property("test1.prop1", "aa")) props.Set(pyluxcore.Property("test1.prop2", "bb")) props.Set(pyluxcore.Property("test2.prop1.aa", "cc")) self.assertEqual(props.HaveNamesRE(".*\\.aa"), True) self.assertEqual(props.HaveNamesRE(".*\\.prop1"), True) self.assertEqual(props.HaveNamesRE("test3.*"), False)
def test_Properties_Clear(self): props = pyluxcore.Properties() props.Set(pyluxcore.Property("test1.prop1", "aa")) props.Set(pyluxcore.Property("test1.prop2", "bb")) props.Set(pyluxcore.Property("test2.prop1", "cc")) self.assertEqual(props.GetSize(), 3) props.Clear() self.assertEqual(props.GetSize(), 0)
def test_Properties_SetFromString(self): props = pyluxcore.Properties() props.SetFromString( "# comment 1\ntest1.prop1 = 1 2.0 aa \"quoted\"\n # comment 2\ntest2.prop2 = 1 2.0 'quoted' bb\ntest2.prop3 = 1" ) self.assertEqual( props.Get("test1.prop1").Get(), ["1", "2.0", "aa", "quoted"]) self.assertEqual( props.Get("test2.prop2").Get(), ["1", "2.0", "quoted", "bb"]) self.assertEqual(props.Get("test2.prop3").Get(), ["1"])
def BuildPlane(objectName, materialName): prefix = "scene.objects." + objectName + "." props = pyluxcore.Properties() props.SetFromString( prefix + "material = " + materialName + "\n" + prefix + "vertices = -1.0 -1.0 0.0 -1.0 1.0 0.0 1.0 1.0 0.0 1.0 -1.0 0.0\n" + prefix + "faces = 0 1 2 2 3 0\n" + prefix + "uvs = 0.0 0.0 0.0 1.0 1.0 1.0 1.0 0.0\n") return props
def CreateConfig(self, type): # Load the configuration from file props = pyluxcore.Properties("resources/scenes/simple/simple.cfg") # Change the render engine to PATHCPU props.Set(pyluxcore.Property("renderengine.type", ["PATHCPU"])) props.Set(pyluxcore.Property("sampler.type", ["RANDOM"])) props.Set(GetDefaultEngineProperties("PATHCPU")) config = pyluxcore.RenderConfig(props) scene = config.GetScene() # Delete the red and green boxes scene.DeleteObject("box1") scene.DeleteObject("box2") # Create the base object props = pyluxcore.Properties() if (type == "Normal"): props.SetFromString(""" scene.objects.box1.ply = resources/scenes/simple/simple-mat-cube1.ply scene.objects.box1.material = redmatte """) elif (type == "Instance"): props.SetFromString(""" scene.objects.box1.ply = resources/scenes/simple/simple-mat-cube1.ply scene.objects.box1.material = redmatte scene.objects.box1.transformation = 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 -0.5 0.0 0.0 1.0 """) elif (type == "Motion"): props.SetFromString(""" scene.objects.box1.ply = resources/scenes/simple/simple-mat-cube1.ply scene.objects.box1.material = redmatte scene.objects.box1.motion.0.time = 0.0 scene.objects.box1.motion.0.transformation = 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 -0.25 0.0 0.0 1.0 scene.objects.box1.motion.1.time = 1.0 scene.objects.box1.motion.1.transformation = 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.25 0.0 0.0 1.0 """) else: self.assertFalse() scene.Parse(props) return config
def load_stuff(self): self.session = None self.config = None self.scene = None self.ui.renBtn.setEnabled(True) self.ui.stopBtn.setEnabled(False) self.ui.pauBtn.setEnabled(False) self.ui.renderView.clear() cmdLineProp = pyluxcore.Properties() self.configProps = pyluxcore.Properties() self.sceneProps = pyluxcore.Properties() print(self.ext) print(self.cfgFileName) if (self.ext == "lxs"): os.chdir(self.lastpath) pyluxcore.ParseLXS(self.cfgFileName, self.configProps, self.sceneProps) self.configProps.Set(cmdLineProp) self.scene = pyluxcore.Scene( self.configProps.Get("images.scale", [1.0]).GetFloat()) self.scene.Parse(self.sceneProps) self.config = pyluxcore.RenderConfig(self.configProps, self.scene) self.setup() return elif (self.ext == "cfg"): os.chdir(self.lastpath) print(self.cfgFileName) self.configProps = pyluxcore.Properties(self.cfgFileName) self.scene = pyluxcore.Scene( self.configProps.Get("scene.file").GetString()) self.sceneProps = self.scene.ToProperties() self.cameraPos = self.sceneProps.Get( "scene.camera.lookat.orig").GetFloats() self.config = pyluxcore.RenderConfig(self.configProps, self.scene) self.setup() elif (self.ext == "bcf"): os.chdir(self.lastpath) self.config = pyluxcore.RenderConfig(self.cfgFileName) self.configProps.Parse(cmdLineProp) self.setup()
def PropertiesOps(): prop = pyluxcore.Property("test1.prop1", "aa") prop.Clear().Add([0, 2]).Add([3]) prop.Set(0, 1) prop.Set([3, 2, 1]) pyvariable = 999 prop = pyluxcore.Property("test1.prop1", [True, 1, 2.0, "aa", pyvariable]) props = pyluxcore.Properties() props.SetFromString( "test1.prop1 = 1 2.0 aa \"quoted\"\ntest2.prop2 = 1 2.0 'quoted' bb\ntest2.prop3 = 1" ) props0 = pyluxcore.Properties() props1 = pyluxcore.Properties() \ .Set(pyluxcore.Property("test1.prop1", [True, 1, 2.0, "aa"])) \ .Set(pyluxcore.Property("test2.prop1", ["bb"])) props0.Set(props1, "prefix.")
def TestPrismLuxCoreTestScene(cls, params): cfgFile = LuxCoreTest.customConfigProps.Get( "luxcoretestscenes.directory").Get()[0] + "/scenes/Prism/render.cfg" filmWidth = 525 filmHeight = 140 additionalProps = pyluxcore.Properties() additionalProps.Set(pyluxcore.Property("film.width", filmWidth)) additionalProps.Set(pyluxcore.Property("film.height", filmHeight)) StandardSceneTest(cls, params, cfgFile, "PrismLuxCoreTestScene", additionalProps)
def SceneEdit(self, session, frame): config = session.GetRenderConfig() scene = config.GetScene() props = pyluxcore.Properties() props.SetFromString(""" scene.objects.box2.ply = resources/scenes/simple/simple-mat-cube2.ply scene.objects.box2.material = greenmatte scene.objects.box2.transformation = 1 0 0 0 0 1 0 0 0 0 1 0 %f 0 0 1 """ % ((frame + 1) / 5.0)) scene.Parse(props)
def clickedStartNode(self): self.frameNodeConfig.setVisible(False) self.pushButtonStartNode.setEnabled(False) self.pushButtonStopNode.setEnabled(True) self.renderFarmNode = renderfarmnode.RenderFarmNode( self.lineEditIPAddress.text(), int(self.lineEditPort.text()), self.lineEditBroadcastAddress.text(), float(self.lineEditBroadcastPeriod.text()), pyluxcore.Properties()) self.renderFarmNode.Start() self.PrintMsg("Started")
def TestThreeSpheresLuxCoreTestScene(cls, params): cfgFile = LuxCoreTest.customConfigProps.Get( "luxcoretestscenes.directory").Get( )[0] + "/scenes/3-spheres/render.cfg" filmWidth = 300 filmHeight = 225 additionalProps = pyluxcore.Properties() additionalProps.Set(pyluxcore.Property("film.width", filmWidth)) additionalProps.Set(pyluxcore.Property("film.height", filmHeight)) StandardSceneTest(cls, params, cfgFile, "ThreeSpheresLuxCoreTestScene", additionalProps)
def TestDanishMoodLuxCoreTestScene(cls, params): cfgFile = LuxCoreTest.customConfigProps.Get( "luxcoretestscenes.directory").Get( )[0] + "/scenes/DanishMood/LuxCoreScene/render.cfg" filmWidth = 423 filmHeight = 570 additionalProps = pyluxcore.Properties() additionalProps.Set(pyluxcore.Property("film.width", filmWidth)) additionalProps.Set(pyluxcore.Property("film.height", filmHeight)) StandardSceneTest(cls, params, cfgFile, "DanishMoodLuxCoreTestScene", additionalProps)