Coordinate tripod labels not rendering in OVITO Scripting

I’m getting the following rendered coordinate tripod without letter labels in the image when adding the CoordinateTripodOverlay object to the viewport:

image

I’m not sure if this is a rendering issue or a fonts availability issue? I’m not getting any warnings. Here’s the script snippet:

...
pipeline.compute()

tripod = CoordinateTripodOverlay()
tripod.size = 0.07
tripod.offset_x = 0.20
tripod.offset_y = 0.13
tripod.axis1_color = [0,0,0]
tripod.axis1_label = "a"
tripod.axis2_color = [0,0,0]
tripod.axis2_dir = [0.0,-5.0,0.0]
tripod.axis2_label = "b"
tripod.axis3_color = [0,0,0]
tripod.axis3_label = "c"
tripod.outline_enabled = True
tripod.outline_color = [0, 0, 0]
tripod.font_size = 0.8
tripod.line_width = 0.1
tripod.outline_enabled = False
tripod.outline_color = [0, 0, 0]
tripod.font = 'Arial' 

viewport = Viewport()
...
viewport.overlays.append(tripod)
...
renderer = TachyonRenderer() 
...
viewport.render_image(renderer=renderer, crop=True, alpha=True)

I get the same with OSPRayRenderer. I can’t get OpenGLRenderer to work on my headless setup (even in VNC session).

When I use OVITO Basic (GUI) via a VNC session, no issue in labels showing.

Setup Details

OS: Ubuntu 22.04.3 (Server edition)
Python: 3.10.12
OVITO: 3.10.0

What happens if you don’t do tripod.font = 'Arial' and let the overlay use its default font? I’m not sure if this is the reason, but the Arial font may not be available to OVITO when running in a headless (non-desktop) system environment.

A second thing you could try is to set the environment OVITO_GUI_MODE=1 to explicitly request the initialization of a full GUI environment, see here.

1 Like

Removing the line for setting font did not fix the problem.

The issue does seem to be with the ray tracing rendering as I finally got OpenGLRenderer to work and this fixed the problem.

image

I had set the env variable OVITO_GUI_MODE=1 but was still getting a display server error. The key command I was missing was xvfb-run, ex.:

OVITO_GUI_MODE=1 xvfb-run python script.py

which makes sense given I’m running a headless box.

Thanks for the help.

Actually, it seems tripod labels will show up for TachyonRenderer and OSPRayRenderer in headless operation as well, you just have to also specify the env variable and use xvfb, i.e., OVITO_GUI_MODE=1 xvfb-run ... .

Might want to verify and add this detail to the docs for the ray tracing classes.

I was able to reproduce the font-rendering issue on my Linux system. It occurs on the Linux platform if you use the standalone OVITO Python module to render some text into an offscreen image buffer in a headless environment (OVITO_GUI_MODE not set). It affects all 3d rendering backends of OVITO in the same way, because the font rendering is always done through the Qt cross-platform framework, and this is where the problem lies.

In a headless environment (i.e. without access to a windowing system such as X or Wayland), OVITO lets Qt fall back to using the so-called “minimal” QPA platform plugin, which provides rudimentary font rendering support. In the past, this was sufficient to make offscreen font rendering work in OVITO, but, apparently, this is no longer the case in the latest version of the Qt framework.

I found that setting the (undocumented) environment variable QT_DEBUG_BACKINGSTORE=1 can resolve the problem – even without activating OVITO_GUI_MODE=1 and starting a virtual X server with xvfb-run. We’ll make sure in the next release of the OVITO Python package that this environment variable will always be set internally to make font rendering work out of the box.

1 Like