script - render

Started by Kirolucber, February 02, 2016, 01:39:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Kirolucber

Hy guys,

I´m new in the area and I recently started using "keyshot". I´d like to know how to build a script to render a sequence of images,
allowing the configuration of quality, dimension and frames volume.

The script "Render Ambient Occlusion.py" only renders one image in occlusion and has the option "render max time (s)",
and the "Render Animation Passes.py" renders sequencies in occlusion, not allowing the quality configuration.

I would also like to render an animation sequence through the script, but making that the final image (and not occlusion).

Do you know if anyone could help me build this script or send me one?

I really appreciate your help. Many thanks!

Kirolucber

jt_pedersen

I think you can pick up further tricks from the documentation take a look at the tips in http://keyshot.com/scripting/doc/6.1/quickstart.html or look up the specific functions to control the rendering , ie lux.renderOptions 

Kirolucber

I saw this documentation, but could not apply it. I am learning little by little to program and realized that these codes of the documentation can be executed on Phyton compilator. The keyshot scripts structure are different?

Kirolucber

I am trying to create a script and it is not working. Can anyone that knows script help me? Thanks!

# ___________animation________________.
import os

def render(folder, fmt, frame, pass_, width, height, env, mmap):
    fmt = fmt.replace("%d", str(frame)).replace("%s", pass_)
    path = os.path.join(folder, fmt)
    lux.renderImage(path = path, width = width, height = height)
    lux.setEnvironmentImage(env)
    lux.applyMaterialMapping(mmap)

def main():
    frames = lux.getAnimationInfo()["frames"]
    if frames == 0:
        raise Exception("No animation in scene! Please create one and try again.")

    values = [("folder", lux.DIALOG_FOLDER, "Output folder:", None),
              ("fmt", lux.DIALOG_TEXT, "Output file format:", "frame.%d.%s.jpg"),
        
              ("time", lux.DIALOG_INTEGER, "Max Samples Rendering:", 64 ),

              ("width", lux.DIALOG_INTEGER, "Output width:", 800),
              ("height", lux.DIALOG_INTEGER, "Output height:", 800),
              ("start", lux.DIALOG_INTEGER, "Start frame:", 1, (1, frames)),
              ("end", lux.DIALOG_INTEGER, "End frame:", 10, (1, frames)),
              (lux.DIALOG_LABEL, "---"),
             

]



    opts = lux.getInputDialog(title = "Animation",
                              desc = "__________animation_____________.",
                              values = values,
                              id = "teste.py.luxion")



    if len(opts["folder"]) == 0:
        raise Exception("Folder cannot be empty!")
    fld = opts["folder"]

    fmt = opts["fmt"]
    if len(fmt) == 0:
        raise Exception("Output format cannot be empty!")
    if fmt.find("%d") == -1:
        raise Exception("Output format must contain '%d' to express the frame number!")
    if fmt.find("%s") == -1:
        raise Exception("Output format must contain '%s' to express the pass!")

    width = opts["width"]
    height = opts["height"]

    start = opts["start"]
    end = opts["end"]
    if start > end:
        raise Exception("Start frame cannot be larger than end frame!")

    for f in [f for f in os.listdir(fld) if f.endswith(iext)]:
        path = fld + os.path.sep + f
        lux.newScene()
        print("Importing {}".format(path))
        lux.importFile(path)
        path = path + "." + oext
        print("Rendering {}".format(path))
        lux.renderImage(path = path, width = width, height = height)

    env = lux.getEnvironmentImage()
    mmap = lux.getMaterialMapping()

    for frame in range(start, end+1):
        lux.setAnimationFrame(frame)

main()


jt_pedersen

The KeyShot scripts are python scripts, that are evaluated within KeyShot. The console in KeyShot is very similar to the console you get by starting python on a commandline.

Try to reduce your script to the minimum that still gives the error, and try to understand what the exact error is. Is it a python programming error or a KeyShot specific error?


Kirolucber

The error comes from this script, indeed!
I am trying to modify the script called "Render animation passes" to render a animation sequence but without using Ambient Occlusion or Toon Outline Shading.

Keyshot seens to have a bug in the render engine.

If you try to render an animation in Maya, for example, and to export all the scene, including camera and objects to keyshot and try to perform the render, when the animations are overlayed the animations to compare the results, you can notice that certain objects are offset. But if you try to render this imported scene using the script, things are ok and equal.

That's why I am trying to come up with a script to automate these renders.

attached example

jt_pedersen

Hi

I am sorry but I, did not see you reply before.
I hope that you have solved your issue?

There does seem to be something amiss when importing the camera animation, I will investigate that.

For future reference please state clearly what error you see, and what you did expect.  "It comes from the script", what comes from the script and how? "A bug in the render engine" , what bug and how did you arrive at that conclusion.

Creating a rar -archive with 1600 files and saying that there is an error leads to a quite frustrating experience of guessing what the error is and where it may be lurking.

Kirolucber

First of all, thanks for your support. I really appreciate it.

I´m facing a strange "bug": I created a scene with the animated camera "scene maya.mb". I rendered using Maya. Then I tried to render it using Keyshot: I exported the scene ("Scene keyShot.bip") and generated the render, using the stantard method. Here´s the bug: when I match the 2 renders, the overlap is not ok as the video "Scene keyShot overlap.mov" shows. In the middle of the animation, the Keyshot rendered scene goes out of position, compared to the Maya rendered scene. Interesting: when the render is made using script ("Script Render Animation Passes"), the scenes are perfectly "one over another". This is showed in the video "Scene keyShot render - Script Render Animation Passes.mov".

(attached archives cameraOverlap.rar)

jt_pedersen

Hi

I am not certain if i understand the issue you describe correctly, when i look at the videos you have in the file the look very similar ("Scene keyShot render - Script Render Animation Passes.mov" and "Scene keyShot overlap.mov" )

The file did reveal a bug with setting animation/start and end times, which for me showed up as a very short and wrong timeline for the animated camera.   For now I can only suggest trying to workaround that by changing the timeline settings.