Display Vortex Cables in Unity

Cables, dynamically simulated in Vortex Studio, can be rendered in Unity during simulation.

When a Vortex Scene contains a Vortex Cable, it is added as a GameObject under the Vortex Scene hierarchy with a default renderer. The Vortex Cable GameObject can be modified, the renderer can be changed to give your cable the appearance you want.

What happens with the Vortex Cables in the Unity Scene?

After associating a Vortex Scene with your Unity scene, or after opening the Unity Scene, the Vortex Scene content will be linked to Unity. 

Every Vortex Cable Graphics extension will be discovered, no matter if they are directly in the scene, in a mechanism, or in an assembly. When discovered a new Vortex Cable GameObject will be created in the Unity Scene, with a default cable rendering component.

This shows the corresponding Vortex and Unity scenes, with their related cables. Notice that all the Vortex objects and Unity objects have the same name and the same hierarchy. The cable objects are indicated by the Cable icon.

Vortex Scene

Unity Scene

Vortex Scene

Unity Scene

 

 

The Vortex Cable GameObject is automatically configured to display the cable as a white cylinder. 

A VortexSpline component handles communication with its corresponding Vortex Cable Graphics extension. It should never be removed.

The VortexSplineGPUCylinderRenderer is created as a default renderer. It can be removed and replaced by another type of VortexSplineRenderer component.

 

How is the cable rendered?

The Vortex Cable GameObject is composed of two main parts: a VortexSpline component and a VortexSplineRenderer component. 

The VortexSpline component is created and managed automatically by the Vortex integration layer. 

There are several variations of the VortexSplineRendererThis component uses the data in the VortexSpline to do the actual cable rendering. We currently have these renderer components available:

  • Vortex Spline Cylinder Renderer

  • Vortex Spline Gpu Cylinder Renderer

  • Vortex Spline Instanced Mesh Renderer

  • Vortex Spline Strap Renderer

VortexSpline Component

The VortexSpline component is in charge of managing the control point arrays and updating the renderers.

 

Spline Renderer Components

We currently have these renderer components available:

  • Vortex Spline Cylinder Renderer

  • Vortex Spline Gpu Cylinder Renderer

  • Vortex Spline Instanced Mesh Renderer

  • Vortex Spline Strap Renderer

The Vortex Spline Cylinder Renderer Component

The VortexSplineCylinderRenderer component is used to render cylindrical meshes along the spline.

 

 

The mesh is generated in the renderer script every frame.

These public fields can be configured through the inspector:

Field

Description

Field

Description

Material 

The material that we want to assign to the generated mesh.

Num Sides

The number of sides composing the cylinder.

Radius

The radius of the cylinder.

Since the control points and the texture coordinates are generated on the Vortex side, the texture repeat period has to be edited from the Vortex Editor, not on the assigned Unity material.

Vortex Spline Gpu Cylinder Renderer Component

The VortexSplineGpuCylinderRenderer component is also used to render cylindrical meshes along the spline, but the vertices are computed on the GPU. The VortexSplineCylinderRenderer can be too slow when too many cables must be rendered. The VortexSplineGpuCylinderRenderer component parallelizes the work with compute shaders. The material applied to the GPU-generated spline must be based on a custom shader (SplineGPUMeshDefaultShader).

These public fields can be configured through the inspector:

Field

Description

Field

Description

Material 

The material that we want to assign to the generated mesh. The material must be based on the SplineGPUMeshDefaultShader.

Num Sides

The number of sides composing the cylinder.

Radius

The radius of the cylinder.

Material Compute Buffer

Name of the ComputeBuffer in the custom shader that contains the vertices data.

Vortex Spline Instanced Mesh Renderer Component

The VortexSplineInstancedMeshRenderer component is used to render mesh instances along the spline. 

 

A mesh can be assigned to the renderer with a local transform and a material. 

These public fields can be configured through the inspector:

Field

Description

Field

Description

Material 

The material that we want to assign to mesh instances. Enable GPU Instancing must be activated on the material.

Mesh

The mesh that we want to instantiate along the spline.

Mesh Position

A position offset for the mesh.

Mesh Rotation

A rotation offset for the mesh.

Mesh Scale

XYZ scaling factors to apply to the mesh.

 

Since the control points are generated on the Vortex side, to get enough evenly distributed control points, the Graphics Cable parameters in Vortex must be tweaked. The Technique must be set to "Mesh". The distance between the control points will depend on the associated Graphics Geometry size and the "Mesh Overlap" parameter. To get mesh instances with alternate orientations, enable "Alternate Mesh Rotation".

Vortex Spline Strap Renderer Component

The VortexSplineStrapRenderer component is used to render strap meshes computed on the GPU. The material applied to the GPU-generated spline must be based on a custom shader (SplineGPUMeshDefaultShader).

 

These public fields can be configured through the inspector:

Field

Description

Field

Description

Material 

The material that we want to assign to the generated mesh. The material must be based on the SplineGPUMeshDefaultShader.

Radius

The width of the strap.

Roundness

Thickness ratio to the strap width.

Material Compute Buffer

Name of the ComputeBuffer in the custom shader that contains the vertices data.

Spline GPU Mesh Default Shader

A material based on the SplineGPUMeshDefaultShader shader exposes these parameters:

Field

Description

Field

Description

Base Map

The albedo color texture.

Base Color

Multiplication color for the albedo.

Normal Map

The normal texture.

Metallic 

Determines how “metal-like” the surface is (between 0 and 1).

Smoothness

Determines how smooth the surface is (between 0 and 1). 

Tiling And Offset

UV tiling (X, Y components) and UV offset (Z, W components) to apply to the Base Map texture.