Hello,
we are mass rendering images of different configurations of a product inside our product configurator. To do this, we update a usd scene with our own Omniverse Connector and after that, we call an omni-service that wait some seconds, captures the result and send the result back to out application.
When using rtx-renderer this works fine (regardless if using PathTracing or RaytracedLighting). But when using iray some results have a “black floor” (the floor is just a plane with white, reflecting material).
Here is the code of our omni-extension:
@router.post("/render", description="Renders a session", summary="Renders the current session from a specified camera")
async def post_render(data: dict = fastapi.Body(None)):
carbSettings = carb.settings.get_settings_interface()
renderer = omni.renderer_capture.acquire_renderer_capture_interface()
viewportWindow = omni.kit.viewport_legacy.get_default_viewport_window()
currentCameraPath = viewportWindow.get_active_camera()
currentRendererResolutionWidth = carbSettings.get("/app/renderer/resolution/width")
currentRendererResolutionHeight = carbSettings.get("/app/renderer/resolution/height")
currentRendererResolutionMultiplier = carbSettings.get("/app/renderer/resolution/multiplier")
requestId = data.get("requestId", "00000000-0000-0000-0000-000000000000")
acceptRenderedImageUri = data.get("acceptRenderedImageUri", "https://localhost:6001/api/session/00000000-0000-0000-0000-000000000000/AcceptRenderedImage")
cameraPath = data.get("cameraPath", "/Stage/Cameras/Interactive")
cameraPositionX = float(data.get("cameraPositionX", "0"));
cameraPositionY = float(data.get("cameraPositionY", "0"));
cameraPositionZ = float(data.get("cameraPositionZ", "5"));
cameraTargetX = float(data.get("cameraTargetX", "0"));
cameraTargetY = float(data.get("cameraTargetY", "0"));
cameraTargetZ = float(data.get("cameraTargetZ", "0"));
renderDuration = data.get("renderDuration", 3);
def renderImageIntoMemeryCallback(capsule, length, width, height, textureFormat):
try:
ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p
ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py_object, ctypes.c_char_p]
pointer = ctypes.pythonapi.PyCapsule_GetPointer(capsule, None)
ap = ctypes.cast(pointer, ctypes.POINTER(ctypes.c_byte * length))
imageData = base64.b64encode(ap.contents)
carbSettings.set("/app/renderer/resolution/width", currentRendererResolutionWidth)
carbSettings.set("/app/renderer/resolution/height", currentRendererResolutionHeight)
carbSettings.set("/app/renderer/resolution/multiplier", currentRendererResolutionMultiplier)
carbSettings.set("/app/asyncRendering", True)
carbSettings.set("/app/asyncRenderingLowLatency", True)
viewportWindow.set_active_camera(currentCameraPath)
req = urllib.request.Request(acceptRenderedImageUri, method="POST")
req.add_header('RequestId', requestId)
req.add_header('ImageWidth', width)
req.add_header('ImageHeight', height)
req.add_header('ImageFormat', str(textureFormat))
req.add_header('CameraPath', cameraPath)
gcontext = ssl.SSLContext()
urllib.request.urlopen(req, imageData, context=gcontext)
except:
print(sys.exc_info()[0])
if currentCameraPath != cameraPath:
viewportWindow.set_active_camera(cameraPath)
carbSettings.set("/app/asyncRendering", False)
carbSettings.set("/app/asyncRenderingLowLatency", False)
carbSettings.set("/app/renderer/resolution/width", data.get("rendererResolutionWidth", 1280))
carbSettings.set("/app/renderer/resolution/height", data.get("rendererResolutionHeight", 720))
carbSettings.set("/app/renderer/resolution/multiplier", data.get("rendererResolutionMultiplier", 1))
viewportWindow.set_camera_position(cameraPath, cameraPositionX, cameraPositionY, cameraPositionZ, True)
viewportWindow.set_camera_target(cameraPath, cameraTargetX, cameraTargetY, cameraTargetZ, True)
renderingTime = 0.0
while renderingTime < renderDuration:
renderingTime += await omni.kit.app.get_app().next_update_async()
viewport_ldr_rp = viewportWindow.get_drawable_ldr_resource()
renderer.capture_next_frame_rp_resource_callback(renderImageIntoMemeryCallback, viewport_ldr_rp)
return {"status": "success"}
As kit expirience we use an own minimal composition (to optimize start up performance and memory consumption). Perhaps there is missing some setting. Here is the kit file:
[package]
title = "XcalibuR - Renderer (IRAY)"
description = "Kit app that is used by XcalibuR for rendering (IRAY)"
version = "1.0.0"
# That makes it browsable in UI with "app" filter
keywords = ["app"]
[settings.log]
flushStandardStreamOutput = true
#detail = true
#fullDetail = true
outputStreamLevel = "Info"
[dependencies]
"omni.kit.uiapp" = {}
#"omni.kit.menu.file" = {}
#"omni.kit.window.extensions" = {}
"omni.kit.window.viewport" = {}
"omni.kit.registry.nucleus" = {}
"omni.renderer" = { tag = "rtx" }
"omni.hydra.iray" = { order = -1000 }
#"omni.rtx.settings.core" = {}
"omni.services.diomex.framework.kitagent" = {}
#"omni.kit.livestream.websocket" = {}
[settings]
exts."omni.kit.renderer.core".imgui.enableMips = true
app.window.title = "XcalibuR - Renderer (IRAY)"
app.runLoops.main.rateLimitEnabled = true
app.runLoops.main.rateLimitFrequency = 60
app.runLoops.main.rateLimitUseBusyLoop = false
renderer.enabled = "iray"
# Camera Inertia
persistent.app.viewport.camInertiaEnabled = true
persistent.app.viewport.camInertiaAmount = 0.55
# Fast shutdown by default
app.fastShutdown = true
# Eco Mode
rtx.ecoMode.enabled = true
#[settings.exts."omni.kit.registry.nucleus"]
#registries = [
# { name = "kit/public", url = "https://kit-103-0-public-extensions.s3.amazonaws.com/public"}
#]
[[test]]
args = [
"--no-assert-dialog",
"--/renderer/multiGpu/autoEnable=false",
"--/renderer/activeGpu=0",
"--/app/asyncRendering=false",
"--/renderer/debug/validation/enabled=false",
]
Any idea what could cause this behavior?
Thank you very much
Carl