Virtual Scene Scale Factor in Unity¶
This article explains how to use an arbitrary scale in your Unity scene despite Vuforia Engine requiring all targets to be configured accurately in meter scale.
The Virtual Scene Scale Factor is a simple mechanism to transform all your Vuforia Targets into a virtual scene scale you wish to use.
Vuforia Engine requires the size of all targets to be defined in meters and configured as accurately as possible since this information is used to compute the target's pose—its position and orientation in space.
If the target size is misconfigured, poses computed from the camera image and the sensors do not match, which will cause various tracking issues.
Set the Virtual Scene Scale¶
The setting for adjusting the Virtual Scene Scale Factor is under Vuforia Configuration.
Change the Physical Scale of a Model Target¶
The physical size of a target is stored in the dataset file but can be configured in the Unity inspector for a particular target. A Model Target GameObject has physical dimensions in length, width, and height displayed in the inspector.
Because targets must be configured in meter scale, all virtual content used as augmentations must be scaled in meters to match the same size.
However, scaling your virtual content up or down may cause various issues with your digital assets.
Example Scenario¶
For example, you might want to create an AR experience where a virtual character interacts with a Model Target car, but you are using a toy replica to test with.
In this scenario, your virtual content will likely be on a different scale than the toy car: The toy car in this example is 1:18 in scale, but the digital character is 1.75m tall.
Scaling down the digital assets to match the physical size of the target may be possible. However, it can often cause issues in Unity, particularly if you use physics or particle systems.
Instead, use the Virtual Scene Scale Factor to scale your Model Target to match the virtual content.
The Virtual Scene Scale Factor configures how many Unity scene units correspond to one meter in the physical world. Poses reported by Vuforia will be transformed accordingly, but scene content will not be scaled.
In our example, we want the poses calculated from our 1:18 toy model to be transformed into a virtual scene that contains assets matching the size of the real-sized car. This is done by setting the Virtual Scene Scale Factor to 18 in the Vuforia Configuration. The screenshot above shows that the Model Target is automatically adjusted in scale. However, no application content will be changed; this includes the Occlusion Object and Target Representation.
At runtime, the Virtual Scene Scale is automatically applied, allowing you to build your scene in the proper scale you need for your final application while tracking and testing the target with a differently scaled replica.
NOTE: The HoloLens and Magic Leap devices do not support the Virtual Scene Scale Factor. On those platforms, head tracking poses are not controlled by Vuforia Engine, and all scene content must be in meters. Therefore, the Virtual Scene Scale Factor is forced to be the value of 1.0.
Set the Virtual Scene Scale Factor at Runtime.¶
By calling the following value from any script, you can change the Virtual Scene Scale Factor at runtime and toggle between tracking the real and toy-sized physical cars:
NOTE: You must also adjust the target size at runtime by calling modelTarget.setHeight(1/18f)
.