Cannot create AOVs with Python API

Operating System:
Windows
[] Linux
Kit Version:
[
] 107 (Kit App Template)
106 (Kit App Template)
105 (Launcher)
Kit Template:
[] USD Composer
[] USD Explorer
[] USD Viewer
[] Custom
GPU Hardware:
[] A series (Blackwell)
[] A series (ADA)
[
] A series
50 series
40 series
30 series
GPU Driver:
[*] Latest
Recommended (573.xx)
Other
Work Flow:

I am trying to create AOVs which I have done using path tracing and the GUI to Create a USD USDRender.Product and then set the camera connection to the camera of interest and set the file type to 32bit OpenEXR and the near and far camera ranges to get a PtZDepth pass

Now I want to automate this process using Python code on a number of synthetic scenes

While this page

https://docs.omniverse.nvidia.com/hkit/docs/omni.kit.capture.viewport/1.7.3/omni.kit.capture.viewport.html

Documents the viewport capture

And this page

Documents how to create AOVs in detail using button clicks in the GUI

What is missing is how to do this with Python API

Main Issue:

Need to specify the path for the USDRender.Product typically SdfPath(“/Render/RenderView”) as an argument to be processed by omni.kit.capture.viewport like in the docs Usage Examples — Omniverse Kit

But also include the workflow for path traced AOVs including PtZDepth and others

Reproduction Steps:

Cannot reproduce because documents are insufficient

Error Code:
The
No error cannot find a way to create AOV passes so it is not a feature request because I can do it via the GUI but not with the API

Hi there and thanks for the question. Let me see if I can get some help for you with this code. I will ask the engineers.

Thanks so much, I really appreciate the feedback

It also seems this document has no mention of the AOV entry point documented in the YouTube tutorial

See

It seems that there is a snippet from a file in the scripts director called movie_capture.py

which has the following

def main():
    global basePath
    global baseFilename
    global renderProductPath
    global viewportId
    global inflightFileIO

    parser = argparse.ArgumentParser()
    parser.add_argument("--viewportId", help="Viewport window name", required=True)
    parser.add_argument("--baseFilename", help="Base filename for output images", required=True)
    parser.add_argument("--basePath", help="Base path to save output images", required=True)
    parser.add_argument("--renderProduct", help="Render product prim path containing renderVars", required=True)
    parser.add_argument("--inflightFileIO",  type=int, help="Number of inflight file save operations per node", default=2)

    try:
        options = parser.parse_args()
        basePath = options.basePath
        viewportId = options.viewportId
        baseFilename = options.baseFilename
        inflightFileIO = options.inflightFileIO
        renderProductPath = options.renderProduct
        attach_post_process_save_to_disk()
    except Exception as e:
        carb.log_warn(str(e))

This refers to the renderProduct as an entry point

additionally I have the following directory

omni.kit.window.movie_capture-2.1.6/omni/kit/window/movie_capture in my old version of Omniverse Kit that I am working with which also has a tests folder which contains

test_file_options_window.py

test_movie_capture_window_startup.py

test_output_settings_widget.py

Which have helpful processes to help understand how MovieCapture internals work.

It is documented here

as

render_product_path (str, optional) – Render product path to use for capturing. Defaults to None.

This is also needed

I would assume that the following should make a valid UsdRender.Product

from omni.kit.menu.aov.scripts.aov import AOVMenuExtension
aov_menu = AOVMenuExtension()
aov_menu._on_create_single_aov()
render_product_str: str = "/Render/RenderView"
render_product = UsdRender.Product(pxr_stage.GetPrimAtPath(render_product_str))
render_product.CreateCameraRel().ClearTargets(False)
render_product.CreateCameraRel().AddTarget(pxr_stage.GetPrimAtPath(camera_path).GetPath())

I will test this now.

While this code seems to work, it doesn’t create a PtZDepth pass even when

Z-Depth /rtx/pathtracing/zDepthAOV Bool False The surface’s depth relative to the view position.

The with that variable for that AOV is set to True according to the docs

The script I found doesn’t seem to work either

Frustratingly the more I try the more things I find that do not produce AOVs

I feel a bit silly but it was documented all along

property render_product: str
Gets the render product used for capture.

Returns :The current render product used for capture.

Return type :str

It seems the code should really be

def find_prims_by_type(
    stage: Usd.Stage, prim_type: T.Type[Usd.Typed]
) -> T.List[Usd.Prim]:
    found_prims = [x for x in stage.Traverse() if x.IsA(prim_type)]
    return found_prims

def get_onstage_cameras(stage: Usd.Stage) -> T.List[Usd.Prim]:
    return find_prims_by_type(stage, UsdGeom.Camera)

from omni.kit.menu.aov.scripts.aov import AOVMenuExtension
pxr_stage: Usd.Stage = omni.usd.get_context().get_stage()
camera_path: str = f"{(get_onstage_cameras()[0]).GetPath()}"
aov_menu = AOVMenuExtension()
aov_menu._on_create_single_aov()
render_product_path: str = "/Render/RenderView"
render_product = UsdRender.Product(
    pxr_stage.GetPrimAtPath(render_product_path)
)
render_product.GetCameraRel().ClearTargets(True)
target_OK = render_product.GetCameraRel().SetTargets(
                    [f"{pxr_stage.GetPrimAtPath(camera_path).GetPath()}"]
)
if target_OK:
    log.error(
       "Awesome target for render product is set to "
       + f"{render_product.GetCameraRel().GetForwardedTargets()}"
)
else:
    log.error("Oh not target for render product not set :(")

Will continue prodding around tomorrow, still no result

Also, have a look in:
/kit/source/extensions/omni.rtx.tests/omni/rtx/tests/test_aov_targets.py

1 Like

stage = omni.usd.get_context().get_stage()

from pxr import UsdRender

render_prod = UsdRender.Product.Define(stage, “/Render/CusomtProduct”)
render_var = UsdRender.Var.Define(stage, “/Render/CustomVar”)

render_var.GetSourceNameAttr().Set(“ldrColor”)
render_prod.GetOrderedVarsRel().SetTargets([render_var.GetPath()])

1 Like

Acutally I got something working yesterday.

I will clear out the problem specific code and share the results later today or early tomorrow.

Most of the problems were really the meatbag between the chair and keyboard.

Ok glad to hear you got it working

Sorry yesterday got the better of my I will allocate time to a hello world a script at rendering from the CLI using AOVs

This issue 5 to 10 percent of rendered exr's missing scanlines is having an effect on me I will try a different OpenEXR codec and see if that improves my luck piz was what I used in my previous workplace.


This is what I am battling.

I’ve only ever seen this once, and it was because the animation had some bad key frames in it, and it was causing some error code with each frame. When you were rendering, you should keep an eye out on the log and look for any error codes. Then send that log to me. The best thing to do is to monitor the log in the Windows command panel, or just take the console tab and move it to the side of the rendering so you can watch it as it’s rendering for errors.

What happens if you render less data? For example, render without AOV, render real time, render at lower resolution? Also, what happens if you render to PNG.? You need to find something that works in order to figure out why it’s doing it.

I would take 100 frames and start with rendering:

  1. PNG with RT
  2. PNG with RT2 (preview)
  3. PNG with PT
  4. PNG with AOVs
  5. EXR with AOVs

Also try rendering the scene without the characters, just to see if it’s a character issue. See when the issue starts.