How to Display Soil Bins in Unity

Soil Bins, dynamically simulated in Vortex Studio, can be rendered in Unity during simulation. When a Soil Bin is loaded, a height field prefab is loaded from an asset bundle file located in the same directory as the Vortex file that contains the Soil Bin.

Manually creating prefabs and Asset Bundles

To manually create assets for the Soil Bin, a Unity project with the Vortex Integration Package is needed (such as VortexUnityTools or your own project), an height field prefab must be added packaged in an asset bundle.

For an overview of the assets workflow, refer to Workflow for Preparing and Using Assets for a Vortex Simulation with Unity Graphics.

Height Field Prefabs

At simulation time, when a Soil Bin instance is added, the Vortex Integration will look for a height field prefab with a specific name. The prefab name must contain the Graphics Soil hierarchy with the Graphics Soil name from the Vortex Editor explorer without the parent element that is contained in a Vortex file. The hierarchy levels are separated with period characters. Folders are omitted from the hierarchy. The name and hierarchy are case sensitive.

For example, for the following hierarchy, the prefab name would be SoilBin.Graphics Soil.

Creating a Height Field Prefab

The height field prefab must have a Vortex Height Field component and a Vortex Height Field Renderer component.

  1. Create an empty GameObject
  2. Rename it with the proper name (see the Height Field Prefabs section introduction)

  3. Select the created GameObject and add the VortexHeightField and VortexHeightFieldRenderer components in the inspector

  4. Create a new material based on the DefaultTransparentHeightFieldShader shader and assign it to the VortexHeightFieldRenderer material field.
    Change the material's surface type to transparent and enable Depth Write.

  5. Drag and drop the GameObject somewhere in the Assets folder in the project pane to create the prefab
    You can create folders in in the assets folder to store the prefabs (ex: Assets/Resources/Scene)

For more details on the height field components, please refer to How to Display Earthwork Zones in Unity.

Creating an Asset Bundle

Once the height field prefabs are created, they can be packaged in asset bundles so that they can be loaded by VortexUnityApp, or your own similar Unity application with Vortex Integration.

The process for generating an asset bundle is described in this section. In short, you can use the Export Asset Bundle... command from the context menu when selecting the folder containing the prefab's assets.

Then, select the file's destination and name to create the file.

In order to get VortexUnityApp to load the asset bundles properly, the asset bundles files should be placed in the same folders where are stored the Vortex files that contains the Soil Bins.