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.
1. Introduction
1.1. A note on terminology
- plugin: We use the term plugin a lot. Technically it could mean a plugin DLL for V-Ray (even V-Ray itself is a kind of plugin) or the type defined in it, which is for example a class in the programming sense, or finally an instance of this class which resides in memory and can be saved to a scene file. We will be using the term plugin to refer to plugin instances.
- exporter/translator: We call the piece of software that translates some native scene format to the V-Ray scene format an exporter or a translator, interchangeably. Basically what it does is creating a bunch of V-Ray plugins and setting their parameters. Note that we also use the verb "to export" sometimes in reference to the act of saving out the scene (which was already translated) to a *.vrscene file.
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.
- Basic types:
int, bool, float, Color
(3float
RGB),AColor
(4float
ARGB),Vector
(3float
),string
,Matrix
(3Vector
s),Transform
(aMatrix
and aVector
for translation) - Objects: references to other plugin instances
- Lists: generic heterogenous lists and concrete typed lists
The AppSDK uses a generic type class calledValue
for items in a generic list. Note that generic lists can be nested. The typed lists areIntList, FloatList, ColorList
andVectorList
. - Output parameters
These are additional values generated by a given plugin which may be used as input by others. For example theTexAColorOp
plugin can be referenced directly as a texture, resulting in its default color texture output, but you can also refer to any of its other outputs, likesum, difference, maximum
etc. for different results.
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:
- Each plugin instance is defined on a new line starting with its type name follow by a space, an instance name, another space and an opening curly brace.
- Each parameter is written on a new line with its name, an equals sign with no whitespace on both sides and a value. The line ends with a semicolon. A parameter definition line may be split into multiple lines for long values such as lists.
- References to other plugins are defined by writing our their instance names without quotation. Output parameters are specified the same way with additional double colon and parameter name (
instance_name::out_param_name
). - The end of the plugin definition is marked with a closing brace on a new line.
- C++ style single line comments are supported.
- Files can be stitched together with an
#include "another.vrscene"
directive like in C. - References can be made to plugins which will be defined further down the file.
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.