©Anton Podvalny

Table of Contents


Introduction


In this chapter we'll cover the main type of geometry in V-Ray.

Geometry in V-Ray is represented by triangle meshes. We don't support arbitrary polygons, as triangles are faster to intersect.

 

Types of geometry


The following categorization of geometry in V-Ray can be made:

  • Implicit geometry - It has an analytical defininition. Examples for this is are the GeomPlane and GeomPerfectSphere plugins.
  • Static geometry (triangles) - A mesh of triangles is explicitly defined before rendering and stays in memory during the whole render process. This is the main topic of this chapter.
  • Dynamic geometry - Primitives are generated at runtime when needed and may be discarded to free up memory. We will cover this in later chapters.
    • Hair and fur
    • Subdivision surfaces
    • NURBS
    • Proxy (load geometry from a file)


Static vs. Moving

We also differentiate between static and moving geometry. The latter can have a different world position at every frame when doing animation. This allows motion blur to be calculated. If this is not needed, static geometry is faster to intersect. You can see a static and moving version of the teapot in the following picture:

 

 

V-Ray constructs separate trees for optimally accelerated intersection of different types of geometry.

Plugins


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 (its geometry parameter) with a material plugin (the material parameter) and positions it in the world (transform parameter). You could reference the same geometry from different nodes at different positions without duplicating data.

Geometry sources

Lets look at the main geometry source plugins:

  • GeomStaticMesh - The basic fixed geometry descriptor that you will use in most cases. Requires vertex and normal data plus optional UVW texture mapping coordinates. V-Ray static meshes work 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.
  • GeomStaticSmoothedMesh - References another mesh plugin (usually GeomStaticMesh) and generates a smooth, subdivided version.
  • GeomDisplacedMesh - References another mesh plugin (usually GeomStaticMesh) and generates a displaced version using a texture map.
  • GeomStaticNURBS - Defines a smooth NURBS surface using control vertices and weights.
  • GeomHair - References another mesh plugin (usually GeomStaticMesh) and generates hair (can be tweaked for fur, grass, shaggy rug etc.) on it. The plugin has many parameters for the size, shape and distribution of strands. This corresponds to VRayFur in 3dsMax and Maya.
  • GeomMayaHair - Defines explicit hair and strand geometry.
  • GeomMeshFile - 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. If you have a file in another format, like .obj, you need to convert it with the ply2vrmesh tool.
  • GeomParticleSystem - Defines a particle system. Particles could be spheres or another geometry source.
  • GeomEnmesh - A geometry that 'coats' an object’s surface with a repeating pattern of a rendered geometry that follows the UVW space of that geometry. Small objects are efficient as Reference objects - the bigger the object is, the more computing power is needed for render, thus the render time is increased.

GeomStaticMesh

Here is a description of the more important plugin parameters:

  • vertices - (should be set) VectorList with the vertex coordinates in object space.
  • faces - (should be set) IntList with indices in the vertices array. Every three indices make a triangle. The same vertex index may be used multiple times (for the different triangles it is part of).
  • normals - (should be set) VectorList with normal vectors in object space. These can have a different count from vertices.
  • faceNormals - (should be set) IntList with indices in the normals array. Every index defines the normal for the corresponding vertex in the faces array.
  • map_channels - An optional list of lists, where each inner list is generic and has three elements. The first element is the channel index (usually starting from 1), followed by a VectorList with UVW coordinates (leave W at 0.0 when you're only mapping 2D). The third element is an IntList with indices in the UVW array. Each index corresponds to a vertex defined in the faces array.
  • map_channels_names - An optional list of strings with names for the corresponding elements of the map_channels list.
  • face_mtlIDs - An optional IntList with material indices for each triangle. The number of indices is equal to the length of the faces array divided by 3.
  • velocities - List of per vertex velocity 3d vectors for motion blur.
  • edge_visibility - A list of edge visibility flags: each 32-bit integer in the list has an edge visibility bit for the edges of 10 consecutive triangles. The highest two bits are unused.
  • shaders_names - An optional list of lists, where each inner list is generic and has 2 elements - face material ID (integer) and shader name (string)
  • smooth_derivs - A list of mapping channels with smooth derivatives; this can also be a single boolean value to specify whether all channels are smooth.
  • weld_threshold - If this parameter is present, the vertices of the mesh which are within the given threshold of one another will be welded. If absent or negative, no welding is performed.
  • primary_visibility - When this is turned off the object is not visible to camera rays, but still visible in reflections.
  • dynamic_geometry - If set to true, the geometry will not become part of the static intersection tree. Only its bounding box will be used and if that's intersected a separate local tree will be intersected. This may boost performance for real-time rendering of moving objects.
  • smooth_uv_borders - True to smooth UVs at mesh borders when rendering this mesh as a subdivision surface.
  • smooth_uv - True to smooth UVs when rendering this mesh as a subdivision surface.
  • first_poly_vertices - A list of indices of the first vertices of the polygons of degree greater than 4. This is used together with edge_visibility by the subdivision algorithms to determine the original polygons. Unless this is used, the invisible edges are assumed to be the diagonals of quads.

Scene


Format

In the scenes bundle attached to this lesson you can see scene vrscenes/cube.vrscene. Check the Node (line 3) plugin representing the cube, as well as its geometry in the form of a GeomStaticMesh (line 12). Notice how the geometry is referenced by the node plugins:

Node CubeShape@node {
    geometry=CubeShape@mesh2;
    ...
}
GeomStaticMesh CubeShape@mesh2 {
    ...
}

 

Hex format

Open the file vrscenes/teapot.vrscene from the bundle. Notice that the vertices, faces, normals lists are encoded in hex format to reduce the size of the data. This is an option when exporting a vrscene file. It can be turned off to get plain text which is useful for debugging:

vertices=ListVector(
    Vector(-152.196, -153.631, 0.0),
    ...
)

 

Smoothing meshes by subdivision


Standard

The first way of getting a smoothed mesh is to wrap the GeomStaticMesh instance in a GeomStaticSmoothedMesh plugin by referring to the former in the mesh parameter of the latter. Inspect vrscenes/cube_subdiv.vrscene (from the scenes bundle) to see an example. The image below shows the geometry subdivided during render time using the standard subdivision method by rendering the Geometry_Subdiv.vrscene file:

 

OpenSubdiv

Alternatively you can use the OpenSubdiv library embedded in V-Ray to do the subdivision. In this case you don't need another plugin. Just set the osd_subdiv_level to a value larger than zero. There are a few more osd_* and creasing parameters. See vrscenes/cube_open_subdiv.vrscene for example. The image below shows the geometry subdivided at render time using OpenSubdiv by rendering the Geometry_OpenSubdiv.vrscene file:

 

  • No labels