Vuforia VFX Library

The library provides a range of object reveal effects for the initial discovery of an object with Vuforia; X-Ray, transparency, and many other visual effects are ready for your use case. These effects are easily applied to any scene in Unity to create stunning visual experiences. The asset package contains scenes, playback sequences and Prefab components which are available in the Unity Asset Store.

Getting Started

The Vuforia VFX Library demonstrates various visual effects that can be added to a Vuforia target in a Unity scene. The package contains sequences and scenes that demonstrate each shading effect, and this guide will show you how to add the shader component and dependencies into your own project.

See the VFX Overview for a list and demonstration of the different Prefab shaders.

See the Tinkering with the Vuforia VFX Library for guides on configuring the Target VFX component for Model Targets, Ground Plane, and for working with multiple visual effects.

Prerequisites

The VFX Library requires that you configure it with a target Observer.

Supported Platforms

The assets are optimized for Android and iOS devices. Use the assets on other platforms at your own discretion.

NOTE: If you plan to use the Phantom or X-Ray effects in your own project and build it to the iOS platform, you will need to add the RenderPipelineInitializer.cs to the ARCamera GameObject: It enforces correct initialization of the rendering queues for iOS to correctly display the shader effects. The script is available in the Assets/VFXCore/Scripts/VFX folder.

QuickStart VFX Library

  1. In a Unity Project, import the Vuforia Engine SDK and the Vuforia VFX Library from the Unity Asset Store.
  2. In the Vuforia Configuration (CmD+Shift+V or Ctrl+Shift+V), change the Play Mode to RECORDING and select either the Model Target or Ground Plane sequence from your Assets/SamplesResources/Recordings/ folder.
  3. Open and play the scene Main_Menu.

VFX Setup guide.

This section will show how to import and set up the VFX library and apply the shader component to your own Vuforia target. See the Vuforia VFX Library Overview for a list and description of the Prefab shaders and their configurations available in the package.

Installation

  1. If you haven’t already, import the Vuforia Engine for Unity.
  2. Visit the Unity Asset Store and add the Vuforia VFX Library to your Assets.
  3. In your Unity project, open the Package Manager.
  4. Select My Assets in the dropdown menu and download and import the asset package into your Unity project.
  5. In the Vuforia Configuration, add your license key.

ARCamera

When using the VFX Library, the Vuforia ARCamera GameObject should be configured for an optimal experience that support the visual effects:

  1. Adjust the Near and Far values of the Clipping Planes depending on the expected size of your scene.
    1. For example, a Model Target experience where the content is expected to appear within a few meters distance, the Near clip plane distance may be set to 0.05 - 0.1, while the Far clip plane distance should usually be set to a few tens of meters (< 100); setting the right distances ensure the best use of the depth buffer resolution of the device GPU, with the highest possible rendering quality.
  2. Add the FocusMode.cs script to the ARCamera GameObject. The script lets you specify the focus mode. The recommended focus mode for most applications is FOCUS_MODE_CONTINUOUSAUTO, although for specific situations, a different focus mode can be used. The focus mode is ignored when using Play Mode. See more about the focus mode at Working with the Camera.
  3. If your scene includes the use of the DepthNormalContour shader, add the CameraDepthMode.cs script to the ARCarmera GameObject and set the field to DepthNormals. Other shaders do not require the script to be added to the camera.

Target VFX

The TargetVFX.cs script is a component that extends from the ShaderVFX.cs base class. This component is where you modify the parameters of the shader. As mentioned earlier, there are many pre-configured Prefabs of this component that you can simply add to your scene as shown here:

The TargetVFX automatically computes, at every frame, the center and axis vectors of the target in Unity World Space while considering the current pose of the Vuforia target and the ARCamera GameObject; informing the shader of the exact world reference frame on which to operate in real-time.

  • The Observer parameter takes a VuforiaBehaviour component to apply the effect to. The TargetVFX then derives the pose and scale (bounding box) information to automatically adjust the shader effect. See more detail below in the Shader VFX class.
  • The Target Object is the 3DModel GameObject that the Material will be applied onto.

NOTE: The material will be applied to all applicable objects that are a child of the Target Object.

  • The Material is the material used for the effect by the shader properties that consequently modifies it.

NOTE: At runtime, the script will create and use a copy of the original Material to avoid that the original material gets permanently modified (e.g., when running in Play Mode).

You can also subscribe to the OnEffectStarted() and OnReachedEnd() events to position the activation of the effects based on specific actions. One example would be to trigger the effect as part of a chain of events or on user activation, or step completion.

General Settings 

The Is Target Shown on Target Found parameter is a boolean flag informing whether the TargetVFX.cs script should play automatically as soon as the Vuforia target is detected.

An optional ShowDelay (in seconds) can be set to delay between the detection and the trigger of the VFX.

The Coordinate System parameters specify the names of the shader properties that are used to define the local axis system of the target as these properties will vary depending on the TargetVFX configuration. See Tinkering with the Vuforia VFX Library for details.

The Center X, Y, Z fields represent the center in the local CS (coordinate system) of the target. By default, it is set to (0,0,0), which is the origin of the target CS, but it can be set to custom values to obtain customized translational offsets for the visual effect.

The Shader Scale parameter is used to scale the visual effect so that it can run in the same way on objects of arbitrary size; the Target VFX script automatically computes the scale from the Bounding Box of the Vuforia Target.

The Center Mode parameter allows the developer to specify one of two distinct behaviors:

  • TARGET - sets the center of the VFX at the origin of the Vuforia Target reference frame.
  • VIEWER - sets the center of the VFX at the viewer (ARCamera) position.

The choice of the Center Mode depends on the application and the intended spatial dynamics that you wish to achieve.

Usually, for AR apps using Model Targets, the VFX should be anchored to the Vuforia Target reference frame, therefore TARGET should be used in such a case.

For AR apps using Ground Plane, the visual effects should also use TARGET to center the effect on the virtual content rendered on the hit test point.

VFX Shader Class

The ShaderVFX.cs script is a key component of the library that allows you to configure, control and animate a visual effect through an arbitrary set of shader properties. This class holds the essential parameters that the TargetVFX component depends on.

The Transition mode can be LINEAR or CUBIC and can be selected via a Combo Box.

  • LINEAR mode interpolates the property values between start and end values linearly or in “smooth steps”.
  • CUBIC mode gradually accelerates the property values at the start value and gradually decelerates the transition at the end values.

The Shader VFX class exposes a set of properties and categorizes them into static and dynamic properties.

  • Static shader properties do not change. For example, a VFX using a constant color throughout the duration of the effect will have the _SomeColor property as Static.
  • Dynamic shader properties change dynamically during the lifetime of the visual effect by interpolating between a start and an end value, typically used for achieving an animated effect or transition.

For both static and dynamic, the ShaderVFX has properties of 3 types:

  • Scalar - Single floating-point value.
  • Vector – Represents positional or directional parameters used by the Shader.
  • Color – Color(s) to use in the effect.

Learn more on the used parameters used by the shaders in the Tinkering with the Vuforia VFX Library.