LeiaDepthFocus

The LeiaDepthFocus component samples the render texture of a depth camera to determine the best focal distance and depth factor for the LeiaDisplay.

Pros:

  • Fast

  • Accurate

  • Easy to use

  • Doesn't require setting up colliders in your scene for use with autofocus (unlike LeiaRaycastFocus).

Cons:

  • Won't work in scenes where scene objects use shaders that don't write to the depth buffer.

  • Won't work on platforms that don't support compute shaders.

Tips to get this working:

  • Clamp the near plane and far plane of your camera to as tightly encapsulate the content of the scene as possible, as LeiaDepthFocus reads it's depth as a percentage from the near plane to the far plane.

  • Having too large of a far plane can cause the depth to get squashed, flattening everything in the scene.