Rendering with V-Ray

In this tutorial, we present a method to render Golaem simulations with V-Ray Next in 3ds Max. The big advantage of this method is that it uses procedural rendering (saving a lot of memory and enabling to customize shading and asset variation after simulation) in 3ds Max.

This method requires the VRay for Maya plugin. If you don't have a license, you can download the free Demo version on Chaos Group website.

Supported Versions

Notice that you need the following versions of Golaem and V-Ray for this process to work:

  • 3ds Max 2022, 2023 & 2024 (check download page or reach us here for another version)
  • Compatible versions for V-Ray for 3ds Max and Golaem. Please check the Release Notes
The following workflow will enable rendering Golaem simulations using the V-Ray Adv renderer.

Workflow

The figure below details the workflow of the render of Golaem simulations with V-Ray in 3ds Max. For a better understanding of the process, check the Golaem Rendering Workflow.

Setup Simulation in Maya

Create your Crowd Simulation within Maya using Golaem. In our example we will use the stadium scene from the Golaem Samples. Once the simulation is done, open the Simulation Exporter to export the Simulation Cache and import the Crowd Shaders in your Maya scene. Once the Simulation Cache will be exported, a Simulation Cache Proxy and a Crowd Render Proxy node will be created and Golaem will be switched in Cache Replay Mode. .

The Crowd Render Proxy node defines attributes to export custom .vrscene files for 3ds Max (in the VRay Attributes):

Specify the directory in which you'd like the files to be exported and press the "Export 3ds Max VrScene files" button. You will obtain two files:

  • cacheName.proxyNodeName.vrscene which defines how V-Ray should handle the exported Simulation Caches and render them as Crowd Characters (e.g. all the parameters defined in the VRay Render Proxy). Details about this .vrscene file can be found here.
  • cacheName.proxyNodeName_shaders.vrscene which contains the shaders used by the exported Crowd Entities.

To export the shaders used by the exported Crowd Entities within Maya, the proxy uses VRay's built-in vrscene exporter. If you're using the free Demo version of V-Ray for Maya, keep in mind that only the shaders of the first 200 objects of your scene will be exported as a .vrscene. The exported shaders can be checked when doing a render in Maya. if some Crowd Character meshes appear orange, it means that there're too many objects in the scene. Delete them to export the shaders properly.


Left: more than 200 objects in the scene - Right: less than 200 objects in the scene

Setup 3ds Max

You must follow a few steps to be able to render Golaem simulations in 3ds Max with V-Ray.

Notice that the Golaem For 3dsMax plugin supports two versions of V-Ray which are listed in the Release Notes. One version is supported by default, the other requires a manual installation which is detailed here (check both the Vray and the 3dsMax parts).

This plugin can be downloaded separately as a zip file from the Golaem download page, depending on the 3dsMax version. Once the zip file is extracted, some files must be copied in the 3dsMax installation directory.

Installing the VrayGolaem 3ds Max plugin

  • glmCrowd3dsMax2022Vray.dlo, glmCrowd3dsMax2022VrayHSL.dlt and glmCrowd3dsMax2022VraySwitch.dlt must be copied from [Golaem For max installation directory]\procedurals\3dsmax to %PROGRAMDATA%\Autodesk\ApplicationPlugins\VRay3dsMax2022\plugins
  • New entries must be created in the PackageContents.xml file located in %PROGRAMDATA%\Autodesk\ApplicationPlugins\VRay3dsMax2022\, such as:
<ComponentEntry AppName="VRayGolaem plugin" Version="6.00.20" ModuleName="./plugins/glmCrowd3dsMax2022Vray.dlo" />
<ComponentEntry AppName="VRayGolaemHSL plugin" Version="6.00.20" ModuleName="./plugins/glmCrowd3dsMax2022VrayHSL.dlt" />
<ComponentEntry AppName="VRayGolaemSwitch plugin" Version="6.00.20" ModuleName="./plugins/glmCrowd3dsMax2022VraySwitch.dlt" />

Adding the Golaem V-Ray procedural to your environment

V-Ray for 3dsMax needs to be able to find the Golaem V-Ray procedural by setting one environment variable. There are many ways to add a path to an environment variable. Here's an example of a bat file to launch 3ds Max with the correct environment variables:

:: Set Environment Variables
set PATH=C:\Golaem\Golaem-8.2-Max2022\bin;%PATH%
set VRAY_FOR_3DSMAX2022_PLUGINS=C:\Golaem\Golaem-8.2-Max2022\procedurals\vray\60;%VRAY_FOR_3DSMAX2022_PLUGINS%
:: Launch 3ds Max
"C:\Program Files\Autodesk\3ds Max 2022\3dsmax.exe"

In this example 3dsMax 2022 is installed in its default location (C:\Program Files\Autodesk\3ds Max 2022), and the Golaem for 3dsMax zip file was extracted to C:\Golaem\Golaem-8.2-Max2022. Vray 6 has been installed for 3ds Max 2022 and is compatible with the procedural stored in the Golaem 60/ directory. These file paths obviously depend on your own installation and 3dsMax version. It is important for the Golaem related paths to be at the beginning of the %PATH%  environment variable.

Setting up the Scene Unit

Within 3ds Max, Golaem considers that simulations have been made in centimeters. Thus, when a VRayGolaem node will be loaded with a .vrscene file, the node will be scaled accordingly based on the 3ds Max System Unit. It is possible to change this default behavior by setting the following variable:

:: Set Scene Unit (0 for millimeters, 1 for centimeters, 2 for decimeters, 3 for meters, 4 for inches, 5 for feet)
set GLMCROWD_UNIT=1

Rendering a Simulation in 3ds Max with V-Ray

A VRayGolaem node is a 3ds Max proxy object which references a crowd .vrscene file and a shader .vrscene file and handles the rendering of a Golaem Crowd simulation in 3ds Max at render time. It can be created from the Create tab of the Command planel, VRay category, select the VRayGolaem button in the Object Type panel, and then click and drag in a viewport to create it.

Please notice that it's not supported to instance a VRayGolaem node.

The node has two attributes to load the Crowd and the Shader .vrscene files (optionnal).  You can specify Texture search paths using the VRAY_ASSETS_PATH environment variable if needed.

Once the Crowd .vrscene file loaded, the other attributes of the node will be automatically filled according to the content of the file. They now can be edited to change the rendering results (motion blur properties, subdivision attributes...). The 3ds Max node attributes are the same than the Maya node.

Those parameters will also enable to display the Crowd Entities as bounding boxes within 3ds Max viewport (notice that frames 0 and 1 are not exported and nothing will be displayed for those) :

When you're happy with everything, render with V-Ray and you're done!

Notice that this method has the same properties than rendering inside of Maya. It means that it supports 3d motion blur, displacement, frustum culling, subdivision surfaces, shading variation, render passes... More here. The only not supported feature in 3ds Max is light linking.

Assigning 3ds Max Shaders

By default, the shaders used by the VRayGolaem node for the Crowd Entities are exported from Maya in a .vrscene file and loaded in the Shaders .vrscene attribute. Those shaders can be directly created in 3ds Max.

For performance reasons, only 3ds Max Shaders assigned to the VRay Golaem node (as Multi/Sub-Object shaders) will be available to Crowd Characters.

Assign a Multi/Sub-Object material to the VRayGolaem node and create as Sub-Objects as you need. For each of those Sub-Object create a Shader from the V-Ray Materials library (Standard 3ds Max shaders are not supported) and rename it according to name of the Shaders stored the Character File postfixed with a "@" (see image below). At render time, those shaders will be updated and made available to Crowd Entities:

If a Shader listed in the Character File, with the same name, is found both in the Shader .vrscene file and in the VRayGolaem Sub-Objects, the one in the .vrscene file will be used in priority. To fix this, you can either remove the Shader .vrscene file from the proxy node or reexport the Shader .vrscene file from Maya after having deleted the Shader node from your Maya scene.

If a Shader listed in the Character File, with the same name, is not found (neither in the Shader .vrscene file nor in the VRayGolaem Sub-Objects), the default shader is used (the name of the default shader can be found / changed in the VRayGolaem node attributes). If the default shader is not found, the meshes requiring that Shader are not rendered.

Dealing with Shading Variation

Golaem allows to define Shader Attributes in the Character Maker which can be then used to pass random or PP Attribute controlled values to the shading graph. Those values can also be read and used in 3ds Max using the VRay's VRayUserScalar shader. Golaem also provides two VRay maps shaders called VRayGolaemSwitch and VRayGolaemHSL which can respectively be used to make texture variation and color variation. Those maps shaders work the same way than the Maya ones:


VRayGolaemSwitch and VRayGolaemHSL maps in the Slate Material Editor

Texture Variation

Thus, if an integer Shader Attribute called tshirt_textureIdx_value with a value between 0 and 3 has been defined on the Tshirt mesh in the Character Maker, a VRayUserScalar shader can be created and set with the same name:

This VRayUserScalar shader can then be plugged wherever you want on the Shading Graph of the Tshirt mesh (which should be linked to the VRay Golaem Multi/Sub-Object shader), such as a VRayGolaemSwitch for example:


Example of a Texture Variation

Color Variation

Thus, if a float Shader Attribute called tshirt_hue_value with a value between -1. and 1. has been defined on the Tshirt mesh in the Character Maker, a VRayUserScalar shader can be created and set with the same name:

This VRayUserScalar shader can then be plugged wherever you want on the Shading Graph of the Tshirt mesh (which should be linked to the VRay Golaem Multi/Sub-Object shader), such as a VRayGolaemHSL saturation attribute for example:


Example of a Color Variation

Texture and Color variation can be combined in any ways and a same VRayUserScalar shader can also be used to feed different attributes within the same shading graph.

Editing the Simulation

All parameters relative to the Render Proxy (motion blur, frustum culling, subdivision, visibility...) can be changed directly on the 3ds Max node or in its Object / VRay properties panel. The actual transformation and scale of the Render Proxy object in the 3ds Max scene is also taken into account.

If you'd like to change any Crowd Shader properties (texture, color, displacement, multi matte IDs...), it can be done on the imported shaders in Maya (and in this case, the Shader .vrscene must be reexported) or on the assigned shaders in 3ds Max (see above).

Finally, if you'd like to change the assets repartition or the shading assignment, it must be done in the Character Maker in Maya. When done, you just need to save the changes in the Character File. Exporting the .vrscene files is not required.

FAQ

When do I need to reexport the .vrscene files from Maya?

Always remember that because we are using a procedural rendering approach, even in 3ds Max, it is not required to reexport your simulation if you change the mesh repartition (e.g between tshirts and sweatshirts), shading assignment or the shaders index range in the Character Maker's Geometry Tab. Just save it, and re-render! (the only case where it is not true is if you setup ppAttributes to be used by shaders attributes, as they need to be exported with the cache).

When I load the Crowd .vrscene, the parameters of the node are not updated. What have I done wrong?

To fill the node attributes, the VRayGolaem bridge uses the Golaem Crowd VRay Plugin. If that plugin can not be found, it means that the VRay environment variable used to specify Vray plugins location has not been set correctly and you should get the following message in the 3ds Max Listener :

VRayGolaem: Error loading .vrscene file "C:\maxExport\vray.crowdProxyVRayShape.vrscene". vray_glmCrowdVRayPlugin.dll plugin was not found in environment variable "VRAY4_FOR_3DSMAX2020_PLUGINS" (C:\Program Files\Chaos Group\V-Ray\3dsmax 2020 for x64/bin/plugins;).

A common mistake is to set environment variable VRAY4_FOR_3DSMAXXXXX_PLUGINS for the wrong version of 3ds Max (i.e. 2022 instead of 2020) or that the PATH environment variable contains an incompatible version of the Golaem V-Ray procedural. The value of an environment variable can be easily checked in 3ds Max using the following MaxScript command:

systemTools.getEnvVariable("myEnvVarName")

And here're the expected results when querying the value of the environment variables in 3ds Max:

systemTools.getEnvVariable("VRAY4_FOR_3DSMAX2020_PLUGINS")
"C:\Golaem\GolaemCrowd-8.2-Max2020\procedurals\vray\40;C:\Program Files\Chaos Group\V-Ray\3dsmax 2020 for x64/bin/plugins;"

systemTools.getEnvVariable("PATH")
"C:\Golaem\GolaemCrowd-
8.2-Max2020\bin;[...];C:\Windows\system;"

I haven't found the answer to my question in the answers above. What else?

Here are some tips to troubleshoot issues:

  • Make sure you're using supported versions of Vray For Maya and Vray For 3ds Max. Those can be different for Maya and 3ds Max and can be checked in the Release Notes.
  • Make sure it renders in Maya. That's usually a good way to check that the first part of the workflow is valid.
  • If something fails (procedural not found, missing shaders, missing cache file...), V-Ray and/or Golaem will almost always warn you in the V-Ray messages window. A more verbose render log can be found in %TEMP%/vraylog.txt

Finally if none of those above worked, please contact us, specify the V-Ray versions used (for both Maya and 3ds Max), copy / paste the content of the 3ds Max Listener / Editor Window and attach the vraylog.txt file