0. Who this is for

These guidelines are for users of the AppSDK who want to use it to create a scene for rendering with V-Ray from the data in their host application scene. We will not discuss details on how to write code with the AppSDK here - there are separate docs for this. Rather we will cover what V-Ray plugins to add to the scene, how to link them and what parameters to set.
Note: This document will be updated and extended over time.

1. Introduction

1.1. A note on terminology

1.2. V-Ray scene contents

We could informally define three kinds of plugins that build up a V-Ray scene.
One would be the so called "top-level" plugins, which can exist on their own, without being part of some plugin tree. Lights are top-level plugins for example. They can also receive input from other plugins of course, but they do not output to other plugins.
The plugins which are not top-level serve as input for parameter slots which require a plugin of certain type. For example a material plugin may require an optional texture input and you'd reference a texture plugin there. The texture plugin may receive input from a UVW generator and so on.
The third kind would be a special type of top-level plugins which only have one instance. These are basically settings plugins. Most of them have "Settings" in their name, but a few don't. The V-Ray camera is also defined by such a singleton settings plugin.

1.3. Parameter types

The following are the types recognized in a V-Ray scene (think .vrscene file). They have corresponding types in the different AppSDK language bindings. The SDK uses the respective basic language types wherever possible and defines custom type classes for the rest.

Parameter polymorphism is an important feature of V-Ray. Texture parameters accept simple values, so instead of creating an additional texture plugin which generates a single color you just set a Color value to the texture slot. Same goes for float textures and single float values etc. You can also set the value of a texture parameter to an output parameter as described above.

1.4. V-Ray scene file format

V-Ray uses a text based scene file format (.vrscene). It is quite simple which makes it convenient to debug and modify by hand. The format is case-sensitive and a little similar to JSON. Large data values, such as geometry definitions can be compressed (and text encoded).
The main rules are:

1.5. Default values

Every parameter has a default value, so even after you create an "empty" plugin instance it is actually fully functional. Of course it might need data, as for example with geometry plugins, but a light will work right away (placed at 0 coordinates). That being said, some plugins have inconvenient default values, which almost always need to be changed (for example some settings plugins, such as the image sampler settings or some shadow parameters). We usually can't fix the defaults, because it would break existing user scenes. Nevertheless, unless you know what you're doing, it is recommended to stick to the default values. You are free to experiment, of course, but don't use values which you don't understand as they may have performance implications or quality implications or they may even break physical plausibility.
Note that when you export (save) a vrscene file it will always contain a bunch of settings plugins, even if you didn't create them. They will have default parameter values. This is how V-Ray always saves files.

1.6. Debugging and help

Apart from documentation included with the AppSDK and this guide, the help pages for 3dsMax and Maya on docs.chaosgroup.com are a good source of parameter information and examples, although they use the user-friendly UI names for things and not the actual scene parameter names.
A very useful tool for basic parameter information is plgparams.exe included in the binary folder of the SDK. It lists all parameters for the specified plugin (or all plugins with -list) and their types, default values and text comments. Similar information can be obtained using the ListAllPluginsAndProperties example in the C++ folder (or equivalent code for another language).
It is often useful to save out your scene to a file to inspect if you did everything properly. For example you may have failed to set some parameter properly and you will see this in the file, although you can also check the result of the set operation in your code. You can try to pinpoint problems by deleting parts of the scene (parameters or whole plugins) and re-rendering.
It can be very helpful if you have a V-Ray for 3dsMax or Maya and use it to export vrscene files to see what plugins and parameters are written out. The exporters for 3dsMax and Maya can be considered "ground truth" (even though they may have an occasional bug or missing feature).
If you're getting a black render make sure your camera is positioned and oriented properly and not inside an object. Keep in mind the default up-axis is Z, but it can be set to something else, usually Y. You might also get invisible or black objects if something is wrong with the attached material.
Another thing to watch out for is V-Ray's errors and warnings, so always implement the DumpMessage callback.

2. Defining camera position

One of the first things you'd want to do is control your camera. This is done through the RenderView plugin. You will always want to create and setup this plugin, exactly one, in your scenes. (The exception is when you are baking textures - then you'd use BakeView.)

The main parameters are:

For advanced camera effects, such as DoF, exposure etc. you will need to enable the physical camera. See the Physical camera subsection in the settings section below for details.

3. Creating lights

Good lighting is the most important thing for getting good photorealistic renders. It also affects image noise and performance. Some lights (generally the simpler ones, especially the first four in the list) render faster and with less noise than others. Things that may make affect noise and performance of lights are: having a texture instead of flat color; having a complex mesh; being an area light with small relative size.

Listed below are V-Ray's light plugins, ordered roughly by increasing photorealism. Common parameters are at the end and some specific parameters are described in the Reference at the end of this document. There are even more parameters that we will not mention here.

Some of these plugins have versions from 3dsMax with additional parameters, such as LightOmniMax, LightSpotMax etc.

Common light parameters:

Other parameters common to many, but not all of the lights (check respective parameter lists):

4. Creating geometry

4.1. The Node plugin

Before we get to defining your actual geometry data, there is a top-level plugin for non-light-emitting objects called Node. It links the geometry data (geometry parameter) with a material plugin (material parameter) and positions it in the world (transform parameter). You could reference the same geometry in different nodes with different positions.

4.2. Geometry sources

V-Ray works with triangular geometry only, so if you have larger polygons, you will have to triangulate them. The simplest way would be the ear clipping method for convex polygons. The triangle vertex indices are specified in counter-clockwise order in the geometry arrays for V-Ray if you're looking at the front face of the triangle.

Lets look at the main geometry source plugins (we will ignore some others):

4.3. Instancing

TODO: Instancer, Instancer2

5. Creating materials

Exporting materials is probably the most complicated part, because it may involve complex shader networks, especially in apps with high artistic control, such as the popular DCC tools from Autodesk. Nevertheless, you can get good results even by using only a few plugins.

There are two types of plugins involved - material (names start with "Mtl") and BRDF (names start with "BRDF") plugins. BRDFs describe what happens with light when it interacts with the surface, like refraction, diffuse scattering, etc. BRDFs get plugged into material plugins, which may extend their behavior or combine them. Finally the material plugin gets plugged into a Node that links it to a geometric object in the scene.

You should always connect a MtlSingleBRDF instance to the Node::material slot. Despite its name, the MtlSingleBRDF::brdf parameter accepts other Mtl plugins, so there is no problem with using any material before finally adding MtlSingleBRDF.

There are some material and BRDF plugins that still exist for compatibility reasons, but we don't recommend you use them. For example instead of connecting MtlDiffuse to a Node, you should create BRDFDiffuse -> MtlSingleBRDF::brdf -> Node::material. Plugins with names ending with "_ASGVIS" can also be ignored. We don't have an exhaustive list of deprecated plugins at the moment.

The workhorse of your material setups should be BRDFVRayMtl. It combines three types of effects in one plugin - diffuse, reflection and refraction (we have them in separate plugins as BRDFDiffuse, BRDFMirror and BRDFGlass respectively). You can use only one of the layers, though, by setting the colors of the others to black. The plugin splits the incoming light energy according to the colors for the three layers. For example, by default the reflection and refraction have black color, so these layers are skipped. If you set a white reflection color you will get a mirror. If you set a white refraction color you will get glass. The layers are evaluated in this order: reflection, refraction, diffuse. The amount of energy that passes to the next layer is the complementary color to the color of the layer. If you have a (0.2, 0.2, 0.2) reflection color, 20% of light the energy will go into the specular reflection and 80% will pass on to the refraction layer. If your refraction layer has color (1.0, 1.0, 1.0) all of the remaining energy will continue as refracted light, so you will get the effect of a glass material (a little reflection and full refraction of the rest). If the refraction color is (0.5, 0.5, 0.5) instead, 50% of the remaining energy will refract and 50% will scatter off from the diffuse layer. If the diffuse color is white, all of that remaining energy is scattered around the scene and if it's black all of it is absorbed (that would heat the object in the real world). So lets summarize what happens with the incoming energy with a few examples:

The absorption of energy in the diffuse layer matters for GI (global illumination). Having a closed room with pure white diffuse walls is like having a room of mirrors. V-Ray will bounce light around until it reaches its maximum GI depth and this may slow rendering down. If the walls were 88% white instead, only 7% of the original energy will remain after 20 bounces. At some point V-Ray will decide that the ray is too weak and insignificant and it will stop tracing it. V-Ray makes a lot of decisions based on light intensity, so this matters. Samples with intense light are considered more important than weak ones.

An important aspect of BRDFVRayMtl is the Fresnel reflection parameter (which is off by default when you create an instance, while it's on by default in V-Ray for 3dsMax). When it's enabled reflection amount depends on the angle of incidence. Glazing angles produce more reflection than looking head-on at the surface. This changes the conclusions we made above about how energy is distributed in the layers of the material. Even with 100% reflection (white color) some of the energy will go through to the reflection and diffuse layer. Fresnel reflections are a must for physically plausible materials. For Fresnel you need to set a correct index of refraction (IOR), even if the material doesn't refract any light. For example metals have very high IORs.

BRDFVRayMtl also has a translucency option, but you should use BRDFSSS2 instead for subsurface scattering.

5.1. Material and BRDF plugins

Some advanced materials:

Below is a list of BRDF plugins for the materials. The difference between the Blinn, Phong, Ward, Cook-Torrance and GGX models is in how the specular highlight behaves and what parameters you have to control it. The respective BRDF plugins combine a diffuse and a glossy reflection component, while VRayMtl provides more options, like a Fresnel term, refraction, etc.

Some BRDFs simulating specific real world materials:

And bump maps:

5.2. Textures and UVW generators

The BRDFs (and some lights) have many Color, AColor and Float parameter slots that can be textured. You will usually just load texture files, but V-Ray also offers many procedural textures, as well as texture plugins that serve as modifiers (i.e. apply some simple function, combine textures, extract data from one of the channels etc.). There are over 200 hundred texture plugins, so we will only look at the most important ones. Many of the plugins are made for specific host applications. Apart from the texture data itself, V-Ray uses UVW generator plugins to generate UVW mapping coordinates or modify the original data from the geometry source. Using a UVWGen plugin is not obligatory.

For texture files:

Textures that modify and combine colors:

Some procedural textures:

Finally, the UVW generators:

6. Scene and render settings

6.1. Image and region size

These are controlled from the SettingsOutput plugin, but it is one of the few exceptions where you should not touch the plugin directly. The AppSDK has APIs for setting image and region size.

6.2. Image sampling and filtering

V-Ray has several types of image samplers. These are algorithms that determine how many samples to take for each pixel. This is combined with an image filter, which can soften or sharpen the final image.

The image sampler is controlled from SettingsImageSampler. These are the four types of its type parameter:

The progressive sampler produces whole images iteratively, refining them with each pass. The other samplers work on small "buckets" and only return an image when it is complete.

For details on the adaptive and progressive sampler see this page. You can also see what our CTO has to say about sampling: https://www.youtube.com/watch?v=tKaKvWqTFlw.

Some of the default values when you create (or if you don't) the SettingsImageSampler plugin are not optimal. They are currently kept for compatibility reasons. Here are some guidelines for changing them:

Most filters have just one size parameter for the kernel radius. Catmull-Rom has no parameters.

6.3. Global illumination

SettingsDMCSampler - use_local_subdivs=0

6.3.1. Irradiance map

6.3.2. Light cache

6.4. Environment

6.5. Units (scale)

6.6. Physical camera

6.7. Color mapping

6.8. Stereo rendering

6.9. Miscellaneous

The SettingsRaycaster plugin has one parameter of interest: embreeUse. You'd want to set this to 1 (default is 0), because it increases raytracing performance.

6.10. RT Engine

7. Minimal renderable scene

This is a diagram of the most simple possible scene that will render an object. These are the plugins and parameters you will need to create and set.


A. Brief plugin reference

This reference does not list all of V-Ray's plugins, but most users will rarely need the ones that are not mentioned here.

Also only some of the parameters are explained here. As a general rule, follow the advice in Debugging and help when looking for info on plugins.

A.1. Common plugins

Light plugins (see also section 3 above)

LightOmni

LightSpot

LightRectangle

LightSphere

LightMesh

LightDome

LightIES

SunLight

Geometry plugins

Node

GeomStaticMesh

GeomStaticNURBS

GeomStaticSmoothedMesh

GeomDisplacedMesh

GeomHair

GeomMeshFile

Material and BRDF plugins

MtlSingleBRDF

Mtl2Sided

MtlMulti

MtlVRmat

MtlGLSL

MtlOSL

MtlRoundEdges

MtlMaterialID

MtlOverride

MtlRenderStats

MtlWrapper

BRDFVRayMtl

BRDFBlinn

BRDFCookTorrance

BRDFGGX

BRDFPhong

BRDFWard

BRDFDiffuse

BRDFGlass

BRDFGlassGlossy

BRDFLight

BRDFMirror

BRDFCarPaint

BRDFFlakes

BRDFHair3

BRDFLayered

BRDFSSS2

BRDFSSS2Complex

BRDFScanned

BRDFSkinComplex

BRDFStochasticFlakes

BRDFBump

BRDFMultiBump

Textures and UVWGenerators

A.2. Other plugins

CameraDome

EffectLens

GeomParticleSystem

VRayClipper

Volumetric plugins