artoolkitx / arunityx

artoolkitX for Unity, providing high-performance video acquisition, marker and texture tracking and full Unity Editor support
https://www.artoolkitx.org/
Other
41 stars 22 forks source link

Add support for video background "fill" mode #56

Closed philip-lamb closed 1 year ago

philip-lamb commented 1 year ago

In AR applications, the camera frustum is the same aspect ratio as the video background texture, but this may differ from the aspect ratio of the display. In video background "fill" mode, the video background texture completely fills the display, such that some of the video background may be outside the display bounds (i.e. cropped left/right or top/bittom).

Normally, this is done by scaling the viewport. See e.g. https://github.com/artoolkitx/artoolkitx/blob/master/Source/ARX/ARVideoView.cpp#L118. However, Unity doesn't accept negative values for a Camera's viewport left or bottom values, therefore an alternate approach is needed.

One such approach would be to crop the video background (set vertices to the same shape as the display, and adjust texture coordinates to match) but this also necessitates adjusting the generated artoolkit camera frustum; a little more complex! See https://github.com/artoolkitx/artoolkitx/blob/master/Source/ARX/AR/paramChangeSize.c

philip-lamb commented 1 year ago

Fixed by https://github.com/artoolkitx/arunityx/pull/77