V-Ray Instancing

Overview

  • The V-Ray Instancing option was added in FROST MX v2.0.
  • It is only used at render time if the current renderer is Chaos Group’s V-Ray v3.1 or higher.
  • It is only available in Geometry meshing mode, and supports both Custom Geometry and built-in geometry shapes.
  • When enabled, the geometry objects will be sent to the renderer as dynamic V-Ray Instances.
  • When disabled, the geometry objects will be combined into a single large TriMesh.

How Does It Work

  • When the V-Ray Instancing option is enabled and FROST is in Geometry meshing mode, each particle will be sent to the V-Ray renderer as a transformation matrix and relevant channels, and the actual geometry will be provided as a dynamic V-Ray inatance.
  • When using the built-in Geometry primitives (Plane, Sprite, Tetrahedron, Box, Sphere), only one V-Ray instance will be allocated in memory, and will be reused for every single particle.
  • When using the Custom Geometry mode, the following rules apply:

Unique V-Ray Instance Creation

  • Every object on the Custom Geometry list will create a unique V-Ray Instance in memory which will then be reused by any particles assigned that shape.
  • When a Custom Geometry contains an animated mesh and Animation Timing specifies a Random or GeomTime-channel controlled offset, every unique time sample will create a new V-Ray Instance in memory which will be reused by all particles with that time offset value.

V-Ray Instance Reusage

  • When a particle specifies a new Material for a particle, no new V-Ray Instance will be created and the existing V-Ray Instance will be reused.
  • When a particle specifies an alternative Vertex Color or Mapping channel, no new V-Ray Instance will be created and the existing V-Ray Instance will be reused.
  • When a particle has custom Scaling or Orientation specified via the relevant channels or FROST controls, no new V-Ray Instance will be created and the existing V-Ray Instance will be reused.
  • In other words, it is possible to reuse a very large mesh stored as a single V-Ray Instance in memory on any number of particles, where each particle has unique Position, Rotation, Scale, Material, Texture Coordinates, Vertex Colors and Velocity with minimal memory overhead.
  • Only when a different mesh is requested from a different scene time, a new unique V-Ray Instance will be created for those particles that have the respective time offset.

Benefits

  • In version of FROST prior to v2.0, the rendering of large numbers of particles replaced by geometry objects was largely dependent on the available memory.
  • While render a million particles with a simple plane shape was possible, replacing each particle with a default Teapot primitive could easily use up all available memory on typical machines.
  • With the introduction of V-Ray Instancing, the geometry object will be allocated in memory only once and reused a million times, thus using very little memory.
  • This turns FROST into a very powerful generic scattering system.

Performance Considerations

  • In most cases, rendering V-Ray Instances in V-Ray is slightly slower than rendering a single combined FROST TriMesh.
  • For that reason, when the number of particles is relatively low and the combined TriMesh can fit in memory, it is recommended to disable the V-Ray Instancing option.

Exception To The Rule

  • A known exception to this rule is when the particle cloud has a volumetric shape and the particle meshes are relatively large and occlude many of the other particles behind them.
  • In this case, since the V-Ray instances are hit-tested at bounding-box level, very few particles will actually be raytraced at mesh level because they would never be “seen” by the renderer.
  • See the second benchmark below.

Particle Flow Benchmark

  • Particle Flow, VRay Advanced 3.40.02, Buckets, Min 1, Max 24 subdivs, 640x480
  • Mobile Intel Core i7 M640 (Arrandale), Dual-Core, HT, 8GB RAM, Windows 10
Particle Count Face Count Particle Flow V-Ray Instancer FROST TriMesh FROST V-Ray Inst. FVRI Slower
Box Primitive, 12 faces
10,000 120,000 63sec. 80sec. 62sec. 80sec. 1.29032x
100,000 1,200,000 115sec. 156sec. 117sec. 156sec. 1.33333x
1,000,000 12,000,000 155sec. / 7.3GB 194/209sec. / 5.1GB 161sec. / 7.3GB 182sec. / 3.1GB 1.13043x
Teapot 4 segs, 1024 faces
1,000,000 1,024,000,000 N/A 255sec. / 7.8GB N/A 317sec. / 3.1GB 1.24314x
5,000,000 5,120,000,000 N/A N/A N/A 476sec. / 7.4GB N/A
Teapot 8 segs, 4096 faces
5,000,000 20,480,000,000 N/A N/A N/A 470sec. / 7.4GB N/A
  • From the above tests, we can see that
    • With less than one million particles, rendering as one combined mesh is about 30% faster.
    • With one million particles and a simple box shape, rendering one combined mesh with an 8GB RAM machine comes to the edge of available memory.
    • At the same time, rendering one million particles in FROST with V-Ray Instancing barely uses any memory (about 1 GB of RAM over the base level).
    • Replacing the box shape with a 1024 faces teapot uses the same amount of memory in FROST with V-Ray Instancing, but the render time is 1.74176x longer.
    • Under the same circumstances, the native V-Ray Instancer reaches the edge of available memory, but is 1.24314x faster than FROST.
    • Rendering 5 million particles with the same teapot shape brings FROST with V-Ray Instancing to the edge of available memory, but it takes only 1.50158x longer.
    • Increasing the polygon count of the teapot 4 times does not affect memory usage or performance of FROST in V-Ray Instancing mode!

Krakatoa PRT Volume Benchmark

  • PRT Volume particles in a 100x100x100 box-shaped grid with spacing of 2.0.
  • Meshed with FROST using Custom Geometry, Box shape.
../../_images/frost2_box100_sp2_frost025.png ../../_images/frost2_box100_sp2_frost05.png ../../_images/frost2_box100_sp2_frost095.png ../../_images/frost2_box100_sp2_frost1.png

Count Radius FROST VRI FROST Mesh
132,055 0.25 139 sec. 117 sec.
132,055 0.5 114 sec. 104 sec.
132,055 0.95 97 sec. 85 sec.
132,055 0.99 72 sec. 66 sec.
132,055 1.0 5 sec. 12 sec.
14,406 1.0 4 sec. 4 sec.
  • Rendering FROST with V-Ray Instancing is generally a bit slower than rendering a single mesh.
  • As mentioned earlier, once the Radius reaches 1.0 and the boxes fuse into a smooth surface, FROST with V-Ray Instancing outperforms FROST with a single mesh.
  • It performs similar to rendering only the 14,406 outside particles using the PRT Volume Shell option.

Radius 1 132,055 primitives 147 sec. Radius 1 2,641,100 faces 125 sec.

Radius 2 132,055 primitives 109 sec. Radius 2 2,641,100 faces 101 sec.

Enabling V-Ray Instancing

  • To use V-Ray Instancing, you must
    • Set the Meshing Mode to Geometry
    • Check the Use V-Ray Instancing option
    • Make sure the current production renderer is set to V-Ray Advanced 3.1 or higher

V-Ray Instancing And Other Renderers

  • If the Use V-Ray Instancing option is checked but the production renderer is not set to V-Ray, FROST will generate an error.
  • This is to avoid potentially running out of memory if a very heavy setup was prepared for V-Ray, but the renderer was not changed by accident.

V-Ray Instancing And Viewport Meshing

  • V-Ray Instancing is only supported at render time when the production renderer is set to V-Ray Advanced 3.1 or higher.
  • However, the 3ds Max viewports will still get a single combined mesh from FROST, which can easily overwhelm the system.
  • Thus, if the particle count is very high, the custom geometry is very heavy, or both, it is recommended to
    • Set the Particle % value in the Viewport group of controls to a very low value (1% or less), or to
    • Disable viewport meshing completely by unchecking the Enable In Viewport option in the Viewport group of controls.