Realtime Image Display (DISP)

Realtime image display means that rendered image data is made available while it is being rendered, on a tile-by-tile basis. The tiles are sent to various destinations in parallel as listed below. Any number of concurrent streams is supported, and the delivery of tiles is handled by a separate thread in mental ray that will maintain a fast response rate regardless of system load, not exhibiting long delays between tiles because running independently of rendering operations.

Tile Targets

Image tiles can be sent to

a file descriptor
which must be passed to mi_rc_run function as its second argument. This mode is enabled either by calling mi_disp_stream_pipe_begin, or by passing a nonzero file descriptor and setting the miRENDER_DISPLAY flag (which is part of the default flag mask) to mi_rc_run, which then calls mi_disp_stream_pipe_begin.
This stream will always receive color tiles sent as bytes (8-bit data) in RGBA order.
a callback function
which is installed with the mi_disp_stream_cb_begin function. The callback can be installed in addition to the other methods, and does not depend on the miRENDER_DISPLAY flag. If multiple frame buffers are rendered simultaneously in mental ray then the callback is able to select which buffer to take the tile from.
This method is not limited to color nor to 8-bit data.
a JPEG stream
which also involves a callback function, but instead of pixel rectangles, raw blocks of compressed JPEG are passed to the callback. In this mode, mental ray switches to a top-down rendering order. JPEG streams are created with the mi_disp_stream_jpeg_cb_begin function.
This stream will receive color images as bytes (8-bit data).
a socket
which is passed within the image file. If there are file output or frame buffer file statements in the camera, the specified image files are created with the same name but containing just a small 128-byte sequence of characters. This file is called the stub file, see below. It provides details about the mental ray process which is rendering this image together with information for establishing a display connection to mental ray. The content of the file is overwritten with the final image when rendering has completed and the frame buffers have been written to files.
This stream will always receive color tiles sent as bytes (8-bit data) in RGBA order.
Note This mode works only if there is no file descriptor.

Stub File

The image file is created initially with a size of exactly 128 bytes. The first bytes are are filled with a sequence of characters such as

ray3.6,1024,768,robot,51382,1.000000,140528,51383

The fields are comma separated. The order and meaning of the fields is pre-defined as follows:

versionwidthheighthosttile portgammaprocesstalk port
ray3.61024768 robot513821.0 14052851383
version
is 3.6 for current mental ray indicating IPv6 support, or 3.3 for older versions using IPv4. Otherwise, both versions perform identical display protocol communication and byte streams.
width
height
the resolution of the image to be rendered.
host
the name of the machine where mental ray is running, here robot, to be able to connect to remote renderings.
tile port
the network port number in a socket connections for uni-directional image tile protocol.
gamma
the gamma setting of the rendered mental ray scene, which is not applied to the tile data, but may be applied dynamically upon display in the receiving application.
process
the operating system identifier of the mental ray renderer, which is needed in case more than one rendering is running on the same machine.
talk port
the network port number in a socket connection for bi-directional communication using the talk protocol.

The last field is followed by a newline and a null byte character. The remainder of the file is undefined.

Programs such as imf_disp can connect via a socket to the specified port on the given host to obtain the image tiles.

The 128-byte file may specify -1 as socket identifier for the tile port, which informs that the firewall mode was enabled by the package that mental ray is integrated in. This mode attempts to work with restrictive firewall software which considers an attempt to create any kind of socket, even local sockets, as a remote access and, therefore, blocks it. This is common practice on Windows platforms. mental ray in firewall mode does not use sockets for communication any more, thus disables tile delivery in this case.

mental ray also offers the mi_disp_stream_socket_begin function, which installs a user-defined socket and starts sending data to that socket. This socket is independent of the socket created automatically by mental ray for image file output, and will not get written to any files.

Note The difference between a file descriptor (method 1) and a socket is that the former begin the transfer with a type-5 message and the latter with a type-6 message (see below).

Tile Protocol

The sequence to send tiles follows a common protocol, for all of the targets.

Data is sent in packets. Each packet consists of a header, followed by optional image data. The header consists of five integers in network byte order (big-endian, high byte first): one packet type code followed by four parameters. The following packets are defined:

01234data sizefunction
6frame0000 start of a new frame
5widthheightgamma00 image size (file descriptor only)
2xlxhylyh n · (yh − yl + 1)
· (xh − xl + 1)
new image tile, n = 4 for RGBA
400000end of image
300000 refuse connection

Image size packets (type 5) are sent only to file descriptors and not to sockets because socket readers have obtained that information from the 128-byte file already. All integer values are sent in network byte order, including the gamma value which is actually a floating-point value (to be read as integer and converted to a float afterwards, see example). Packets with types not listed in the table above should be quietly ignored, they will consist of only the header.

Only image data packets (type 2) have data after the header. Data is sent in expected order, like RGBARGBA... for color tiles with eight bits per pixel component, beginning with the lower left corner of each tile. The coordinates of the lower left tile pixel (xl, yl) and of the upper right tile pixel (xh, yh) are in absolute image coordinates. If output shaders run, the image may be sent multiple times, once as rectangular tiles during rendering and then once per output shader in blocks of scanlines, or even as a complete image. The order of tile and scanline packets is undefined.

Copyright © 1986, 2015 NVIDIA ARC GmbH. All rights reserved.