Auto Focus
Last updated
Last updated
Choosing a correct focal distance and depth scale is essential to make the most of LeiaSR displays.
With a dynamically changing scene, often just having a fixed focal distance and depth scale isn't enough to keep everything in focus.
To help with this, Auto Focus modules are included with the Leia Unity SDK which can automatically dynamically adjust the focal distance and depth scale of the LeiaDisplay component based on the content of the scene.
NOTE: Autofocus scripts only work with a LeiaDisplay in "Camera Centric" control mode. To learn more about LeiaDisplay control modes click here.
Without Autofocus: 😵💫
With Autofocus: 🤩
Automatically adjust the Leia Display's depth factor and focal distance based on scene content.
Sample Scene can be found in Assets/Leia/Extensions/Autofocus/Examples/AutoFocusMethods
Getting the right focal distance and depth for the LeiaDisplay component can be tricky, especially for scenes where the content is constantly changing. To assist developers, we have created script modules which can be attached to the same game object as a LeiaDisplay component and automatically set the DepthFactor and FocalDistance based on the visible content in the scene. There are currently three different possible approaches, each with it's own pros and cons: a depth map based approach (LeiaDepthFocus), a raycasting approach (LeiaRaycastFocus), and a mesh-vertices based approach (LeiaTargetFocus). All three auto focus components have these common parameters:
Depth Factor Range
The minimum and maximum values that the LeiaDisplay's depth factor can be set to as a result of auto focus.
Focal Distance Range
The minimum and maximum values that the LeiaDisplay's focal distance can be set to as a result of auto focus.
Depth Scale
A scalar value used to increase or decrease the depth output by the auto depth algorithm.
Focal Distance Change Threshold
Prevent the focal distance from jittering when objects in the scene are moving by setting a threshold the focal distance target will have to change by before the actual focal distance is updated. Note the focal distance will still smoothly adjust to the new target value, not jump instantly.
Depth Factor Change Threshold
Prevent the depth factor from jittering by setting a threshold the depth factor target will have to change by before the actual depth factor is updated. Note the depth factor will still smoothly adjust to the new target value, not jump instantly.
Focus Speed
Speed at which the focal distance moves from its current value to the target value.
Depth Focus Speed
Speed at which the depth factor moves from its current value to the target value.
Focus Offset
Offset the LeiaDisplay focal distance from its computed optimal value by this amount. This can be useful to bring objects more to the foreground to make them pop out more, or push them more into the background so that (for example) UI can be drawn over them.