Introduction
In this chapter we'll talk about V-Ray Proxy Geometry and the Instancer functionality. We'll cover particles in a later section.
V-Ray Proxy imports geometry from an external mesh at render time only. The geometry is not present in the host application scene and does not take up any resources. This allows the rendering of scenes with many millions of triangles, more than the host application itself can handle. This technology opens up possibilities for rendering vegetation and foliage, but not only - each case where multiple similar objects need to be rendered is a good use case for instancing. It conserves RAM usage by referencing the same geometry for multiple nodes, possibly with different materials.
We'll be interested in the GeomMeshFile::file property. It loads geometry from a file, a so-called geometry Proxy. The geometry is only loaded on-demand as a ray hits it, so in some cases such as distributed bucket rendering it may prevent unnecessary calculations and memory usage. The currently supported formats are V-Ray's .vrmesh and Alembic .abc.
The .vrmesh File Format
Meshes are exported to a special .vrmesh file format. This file format contains all geometric information for a mesh including vertices and face topology, texture channels, face material IDs, smoothing groups, and normals. In short, it has everything needed to render the mesh. In addition, the mesh is preprocessed and subdivided into chunks for easier access. The file also contains a simplified version of the mesh used for preview purposes in the viewports. Also, there is an option for adding point cloud data to the file, which is a simplified geometric representation of the mesh in the form of 3D disks with different levels of detail. Each level comprises of disks with equal radius lengths which is greater for levels of lower detail and smaller for the more detailed ones. When the object is rendered, a point cloud geometry level is chosen depending on the distance between the object and the camera; for distant objects, lower resolution point clouds are used. Thus the original mesh is replaced by the simpler point cloud geometry with the appropriate level of detail allowed by distance.
It is important to realize that the mesh is in a "ready to render" format. No further modifications to the mesh are expected. You can't apply modifiers to the mesh, or animate it in any way except if you animate the position/orientation of the proxy object. If you need to make changes to the mesh, you can make the changes in 3ds Max, import the mesh back as an Editable Mesh (see the Import section below) and re-export it back to a .vrmesh file.
Alembic Support
The V-Ray Proxy can load and render Alembic files (.abc). The supported geometry types are polygonal meshes (without subdivision surfaces), spline curves and particles.
Code Example
# Create a new GeomMeshFile plugin instance. It loads geometry from a file (a so-called geometry proxy). # The geometry is only loaded on-demand as a ray hits it so in some cases # such as distributed bucket rendering it may prevent unnecessary calculations and memory usage. # The currently supported formats are V-Ray's .vrmesh and Alembic .abc. # Other formats could be converted to .vrmesh using the ply2vrmesh tool. geometry = renderer.classes.GeomMeshFile() geometry.file = os.path.join(SCENE_PATH, 'assets', 'Tree.vrmesh') # Create a new Node plugin instance referring to the material and proxy geometry. node = renderer.classes.Node() node.material = material node.geometry = geometry
// Create a new GeomMeshFile plugin instance. It loads geometry from a file (a so-called geometry proxy). // The geometry is only loaded on-demand as a ray hits it so in some cases // such as distributed bucket rendering it may prevent unnecessary calculations and memory usage. // The currently supported formats are V-Ray's .vrmesh and Alembic .abc. // Other formats could be converted to .vrmesh using the ply2vrmesh tool. GeomMeshFile geometry = renderer.newPlugin<GeomMeshFile>(); geometry.set_file("assets" PATH_DELIMITER "Tree.vrmesh"); // Create a new Node plugin instance referring to the material and proxy geometry. Node node = renderer.newPlugin<Node>(); node.set_material(material); node.set_geometry(geometry);
// Create a new GeomMeshFile plugin instance. It loads geometry from a file (a so-called geometry proxy). // The geometry is only loaded on-demand as a ray hits it so in some cases // such as distributed bucket rendering it may prevent unnecessary calculations and memory usage. // The currently supported formats are V-Ray's .vrmesh and Alembic .abc. // Other formats could be converted to .vrmesh using the ply2vrmesh tool. GeomMeshFile geometry = renderer.NewPlugin<GeomMeshFile>(); geometry.File = Path.Combine("assets", "Tree.vrmesh"); // Create a new Node plugin instance referring to the material and proxy geometry. Node node = renderer.NewPlugin<Node>(); node.Material = material; node.Geometry = geometry;
// Create a new GeomMeshFile plugin instance. It loads geometry from a file (a so-called geometry proxy). // The geometry is only loaded on-demand as a ray hits it so in some cases // such as distributed bucket rendering it may prevent unnecessary calculations and memory usage. // The currently supported formats are V-Ray's .vrmesh and Alembic .abc. // Other formats could be converted to .vrmesh using the ply2vrmesh tool. var geometry = renderer.classes.GeomMeshFile(); geometry.file = path.join(SCENE_PATH, 'assets', 'Tree.vrmesh'); // Create a new Node plugin instance referring to the material and proxy geometry. var node = renderer.classes.Node(); node.material = material; node.geometry = geometry;
Instancer
The instancing process can be controlled by the Instancer plugin. It allows the instanced geometries to be transformed by particles. It has the following parameters:
- instances - A list of N+1 elements where N is the number of instances; the first element is a time value, the rest are lists with elements: particle id, transform, velocity transform, hasInstanceTime, instanceTime, additional_params_flags, additional_param_1, ..., additional_param_N, visibility, node, node, node, ...
- nsamples - Number of transform samples
- visible - If false, no geometry will be generated and rendered
- shading_needs_ids - Set to true if the particle shade data sent to the instanced geometry needs to include the particle ID.
- use_additional_params - If this is set to 'true' the lists in the 'instances' parameter have additional parameters after 'time instancing' parameters - an int with flags indicating what parameters follow and after that the parameters that follow. Their types depend on the flags in the int and are in a strictly defined order. New flags may be added and additional parameters for them can be added at the end of the chain. The flags are defined in HierarchicalParameterizedNodeParameters in an enum.
- use_visibility - Use particle visibility. If set to 'true' the lists in the 'instances' parameter have particle visibility parameter after 'additional parameters'.
- use_time_instancing - If this is set to 'true' the 'instances' parameter will contain the elements hasInstanceTime (bool) and instanceTime (double). Otherwise, they should not be present.
- user_color_pp_1/2/3/4/5 - Corresponds to Maya's userVector1/2/3/4/5PP.
- user_float_pp_1/2/3/4/5 - Corresponds to Maya's userScalar1/2/3/4/5PP.
- acceleration_pp - Per-particle acceleration.
- colors - Per-particle diffuse color.
- emission_pp - Per-particle emission color.
- age_pp - Per-particle age.
- lifespan_pp - Per-particle lifespan.
- opacity_pp - Per-particle opacity.
Examples
The following image is rendered by using this scene.
The following image is rendered by using this scene.
See comments in the scenes about how the proxy is included.
Notes
App SDK provides methods for reading and writing of .vrmesh files - several examples are available in the App SDK installation package in the folders
examples/{language}/geometry
.- The geometry generated by the proxy object is not modifiable. Any modifiers applied to the V-Ray Proxy node will be ignored.
- The geometry from the file, could be read and applied to e.g. GeomStaticMesh -
examples/{language}/geometry/04-file-to-static-mesh
- If you need to create several proxies linked to the same .vrmesh file, it's better to make them instances. This will save memory since the .vrmesh file will be loaded only once.
- Materials are not saved in the .vrmesh file. Instead, the geometry will be rendered with the material applied to the VRayProxy node. This is because third party materials and procedural textures would be difficult to describe in a general way. In addition, you may want to edit the material independently of the mesh.
- The resulting .vrmesh files can be rendered by the standalone version of V-Ray, V-Ray for Maya, or V-Ray for 3ds Max.
- Standard shadow maps will not include information about the proxy objects. If you want the proxy objects to cast shadows, you should use Ray Traced Shadows or Shadow Maps shadow types.
- You can convert .ply and .obj files to .vrmesh files with the help of the ply2vrmesh converter tool.