In Omniverse code, how can I render a scene using the interactive path tracing? This is the current code I have right now:
viewport_window = omni.ui.Window('SimpleViewport', width=1280, height=720+20) # Add 20 for the title-bar
with viewport_window.frame:
viewport_widget = ViewportWidget(resolution = (1280, 720))
# Control of the ViewportTexture happens through the object held in the viewport_api property
viewport_api = viewport_widget.viewport_api
# We can also switch to a different camera if we know the path to one that exists
viewport_api.camera_path = '/World/Camera_2'
viewport_api.renderer = "interactive" // This is not right
omni.kit.viewport.utility.capture_viewport_to_file(viewport_api, file_path="...")
Can I add something to the viewport API to do this?
@abhishekjoshinj luckily @mati-nvidia covered the topic of changing viewport renderer programmatically in a past livestream using action registry. though not directly through viewport API, hopefully it’s still worth knowing:
and below is the snippet for each of the renderers:
# RTX Real-Time
import omni.kit.actions.core
action_registry = omni.kit.actions.core.get_action_registry()
action = action_registry.get_action("omni.kit.viewport.actions", "set_renderer_rtx_realtime")
action.execute()
# RTX Path Tracing
import omni.kit.actions.core
action_registry = omni.kit.actions.core.get_action_registry()
action = action_registry.get_action("omni.kit.viewport.actions", "set_renderer_rtx_pathtracing")
action.execute()
# Iray
import omni.kit.actions.core
action_registry = omni.kit.actions.core.get_action_registry()
action = action_registry.get_action("omni.kit.viewport.actions", "set_renderer_iray")
action.execute()
# Storm
import omni.kit.actions.core
action_registry = omni.kit.actions.core.get_action_registry()
action = action_registry.get_action("omni.kit.viewport.actions", "set_renderer_pxr_storm")
action.execute()