Implementing embedded distributed rendering with V-Ray

General

Approaches for distributed rendering

Rendering with the host application

Rendering with the standalone version of V-Ray

Implementing support for distributed rendering

On the render client

On the render slave

Collecting the render output

 

General

V-Ray supports distributed rendering (DR) where the calculations for rendering a single frame are split across multiple machines in a local network. This section covers the details on implementing support for distributed rendering in embedded V-Ray implementations.

 

When V-Ray is implemented as embedded module inside another application (host), there are two different approaches to implementing distributed rendering. The two approaches differ in the way rendering is done on the render slaves.

 

In the first approach, the host application is started on the render slaves, and the V-Ray module inside the host does the actual rendering. In the second approach, the standalone version of V-Ray is used to render on the slave machines.

Approaches to distributed rendering

Rendering with the host application

This approach requires that the host application can be started on the render slaves in a state that would allow the embedded V-Ray module to receive and process distributed rendering requests. Many modelling/rendering applications already have a suitable render-only mode that does not require additional licenses and has no graphical user interface, but allow rendering to be done. An advantage of this approach is that any rendering features of the host application can be used in the distributed rendering (e.g. native textures). In the second approach described below, only those features that can be rendered with the standalone version of V-Ray can be supported.

Rendering with the standalone version of V-Ray

This approach does not require the host application to be running on the render slaves; instead the standalone version of V-Ray, started in slave mode, is used to process distributed rendering requests. This approach requires that the embedded implementation of V-Ray can export the scene as a .vrscene file so that the render slaves can read the scene description. With this approach, rendering features (e.g. native textures) specific to the host application cannot be used.

Implementing support for distributed rendering

On the render client

Before you can use distributed rendering, you must initialize the V-Ray distributed rendering system. On the render client, this is done by calling the VUtils::initClient() function from the V-Ray DLL. This function must be called only once, when the host application is initialized. Before the host application exits, you must call the VUtils::doneClient() function to clean up any resources used by the distributed rendering system.

 

On the render client, distributed rendering is exactly the same as regular render, with the difference that you must set the VRaySequenceData::distributedRenderer member with a pointer to an instance of class VRayDistributedRenderer. V-Ray will call various methods of this class to transfer the scene description and individial frame parameters to the render slaves. Additionally, you must set the VRaySequenceData::renderHosts member with a list of the machines that will take part in the distributed rendering.

 

Note that it is important to set correctly the VRayFrameData::currentFrame member when rendering animations in DR mode. V-Ray uses this member to figure out if the client machine has finished rendering a particular frame, before the render slaves can move on to the next one.

On the render slaves

This part assumes that the first approach is taken, where the host application is used on the render slaves. If the second approach is used, this part is already implemented by the standalone version of V-Ray.

 

Once the host application starts, you must initialize the V-Ray distributed rendering system. On the render slaves, this is done by calling the VUtils::initServer() function. This opens the necessary communcation ports so that the V-Ray distributed rendering system can accept rendering requests, and starts a new thread to process these requests. Once this function is called, the host application should be put in a waiting state. If you wish to terminate the host application, you must call the VUtils::doneServer() function to clean up any resources taken by the V-Ray distributed sendering system.

 

Once initialized, the V-Ray distributed rendering system will accept DR requests and will automatically call the respective methods of the renderer (e.g. VRayRenderer::beginSequence(), VRayRenderer::beginFrame() etc).

 

At any time during the rendering, you can determine if V-Ray is rendering in slave mode by checking the VRaySequenceData::isServerMode member.

Collecting the render output

V-Ray uses two methods of class OutputRegion to transfer the rendered buckets from the render slaves to the render client: OutputRegion::getBuffer() and OutputRegion::setBuffer(). The first method is used to obtain a binary representation of all bucket data, so that it can be sent over the network. The second method is used to read that data into an actual bucket on the render client.

 

If you are using the default V-Ray VFB, these methods are automatically supported by the default V-Ray VFB implementation. If you are using your own implementation of the class OutputRegion, then you need to implement the OutputRegion::setBuffer() and OutputRegion::getBuffer() methods.