MeRoPE: Metric Rotary Position Embedding for Camera-Controlled Video Generation

Zhijian Qiao1, Xinjiang Wang2, Jiajie Chen2, Haoming Huang2, Meng Li2, Chih-Chung Chou2, Jing Wang2, Shaojie Shen1

1HKUST    2Zhuoyu Technology

arXiv pending moderation Code coming soon

Every video token has a ray

A language model uses positional encoding to tell words where they sit in a sequence. MeRoPE gives video tokens their geometric positions instead: where each camera ray starts and where it points.

The small x/y/z axes describe 3D space, t indexes time, and H is the prediction horizon. Together they form a 4D space-time coordinate. Every token is tagged by its time and by the origin and direction of its camera ray.

Given only calibrated camera rays, attention can learn from data how to relate tokens across cameras and time. No external 3D reconstruction model—such as VGGT [1] or Depth Anything 3 [2]—is needed to first produce point clouds or depth maps as guidance for generation.

How geometry enters attention

UCPE [3] turns every calibrated camera ray into a ray-local frame: its origin is where the ray starts, and one axis follows the ray direction. MeRoPE keeps this useful abstraction but refines how the frame orientation is chosen using a minimum rotation (MinRot). The exact construction and singularity analysis are given in the paper.

Once every token has a local frame, the relative geometry between a query token \(a\) and a key token \(b\) can be inserted directly into their attention comparison:

\[ \underbrace{\frac{\mathbf{q}_a^\top\mathbf{k}_b}{\sqrt d}}_{\text{standard attention}} \quad\longrightarrow\quad \underbrace{\frac{\mathbf{q}_a^\top\mathcal{U}_{ab}\mathbf{k}_b}{\sqrt d}}_{\text{geometry-aware attention}}. \]

Here \(\mathbf{q}_a\) and \(\mathbf{k}_b\) are the query and key feature vectors, \(d\) is their dimension, and \(\mathcal{U}_{ab}\) describes the geometric relation between the two tokens. Standard attention uses the left dot product; geometric PE adds only the relative operator shown on the right.

Homogeneous geometric PEs such as GTA [4], PRoPE [5], and UCPE [3] place the relative transform between two frames directly inside this operator:

\[ \mathcal{U}^{\mathrm{hom}}_{ab} = \begin{bmatrix} R_{ab} & \mathbf{t}_{ab}\\ \mathbf{0}^\top & 1 \end{bmatrix}. \]

The matrix \(R_{ab}\) and vector \(\mathbf{t}_{ab}\) are the rotation and translation from the key ray-local frame to the query ray-local frame, and \(\mathbf{0}\) is a three-dimensional zero vector. Splitting the corresponding query and key channels into 3D vectors \(\mathbf{u}^{q},\mathbf{u}^{k}\) and scalars \(h_q,h_k\) exposes what reaches the attention score:

\[ \begin{bmatrix}\mathbf{u}^{q}\\h_q\end{bmatrix}^{\!\top} \mathcal{U}^{\mathrm{hom}}_{ab} \begin{bmatrix}\mathbf{u}^{k}\\h_k\end{bmatrix} = (\mathbf{u}^{q})^\top R_{ab}\mathbf{u}^{k} +\underbrace{h_k(\mathbf{u}^{q})^\top\mathbf{t}_{ab}}_{\text{metric-translation term}} +h_qh_k. \]

The middle term shows the central issue: metric translation changes the attention score directly.

Why metric translation can dominate

Ray origins are measured in meters. If the same motion is scaled by a factor \(\lambda>0\), then \(\mathbf{t}_{ab}\) becomes \(\lambda\mathbf{t}_{ab}\), and the translation term above becomes

\[ h_k(\mathbf{u}^{q})^\top\mathbf{t}_{ab} \quad\longrightarrow\quad \lambda h_k(\mathbf{u}^{q})^\top\mathbf{t}_{ab}. \]

Its magnitude can therefore grow with camera baseline even when visual similarity does not. After the softmax, this unbounded geometric term can pull attention toward a distant frame simply because it is far away.

UCPE assigns excessive attention to the most distant early frame, while MeRoPE preserves a local temporal profile
Temporal attention from the center token of the final frame. Frame 0 is the farthest key frame and frame 12 is the query frame. In trained UCPE [3], the baseline-dependent term creates a distant-frame attention surge; MeRoPE removes it.

MeRoPE keeps the same metric relative-pose information, but represents it with rotations whose output norm cannot grow with distance.

Replace metric translation with rotations

The relative rotation \(R_{ab}\) between ray-local frames is already norm preserving, so MeRoPE keeps this rotation PE and changes only the translation part. Let \(C_a\) map the query camera coordinates into the world frame, and let \(\mathbf{o}_a\) and \(\mathbf{o}_b\) be the two ray origins. MeRoPE first expresses their displacement in the query camera:

\[ \Delta\mathbf{o}_{b\mid a}=C_a^\top(\mathbf{o}_b-\mathbf{o}_a). \]

The factor \(C_a^\top\) depends on the query, so subtracting two independent world-frame phases cannot recover this relative translation. MeRoPE computes it first, then encodes each coordinate with multi-frequency 2D RoPE rotations [6]:

\[ \mathcal{U}^{\mathrm{trans}}_{ab} =\bigoplus_{c\in\{x,y,z\}}\;\bigoplus_{k=0}^{K-1} \operatorname{Rot}\!\left(\omega_k[\Delta\mathbf{o}_{b\mid a}]_c\right), \qquad \operatorname{Rot}(\theta)= \begin{bmatrix} \cos\theta & -\sin\theta\\ \sin\theta & \cos\theta \end{bmatrix}. \]

The index \(c\) selects one of the three translation coordinates, \(K\) is the number of frequencies, \(k\) indexes them, and \(\omega_k\) is the corresponding angular frequency. The direct-sum symbol \(\oplus\) places these independent 2D rotations on the diagonal. Distance now changes rotation angle \(\theta\), not feature magnitude.

Geometry suggests where a match may lie

In principle, the pose PE above already achieves our primary goal: every token is represented by a calibrated ray. In practice, multi-view geometry in static scenes provides an additional cue that can further improve camera-pose controllability.

Consider the key ray in the figure below. As the unknown scene depth varies, its possible matching direction in the query camera moves along the purple spherical arc, from \(\mathbf{u}_\infty\) at infinite depth toward the epipole \(\mathbf{e}\). MeRoPE samples a few bounded angular anchors—the purple dots—along this arc. These anchors act like interpolation knots rather than mutually exclusive guesses: their joint responses give the network a coarse coordinate system along the continuous arc, from which it can infer intermediate disparities. Each anchor direction is turned into a local frame in the same way as a token ray, and the rotation from the query ray frame to that anchor frame becomes one positional block.

Disparity anchors sampled on the spherical epipolar arc between a transformed key ray and the epipole
Geometry in the query camera frame. The points \(\mathbf{o}_i\) and \(\mathbf{o}_j\) are the query and key ray origins, \(\Delta\mathbf{o}_{j\mid i}\) is their metric baseline expressed in the query camera, and \(\mathbf{e}_x,\mathbf{e}_y,\mathbf{e}_z\) are the query-camera basis axes. The frames \(A_{i,q}\) and \(A_{j,k}\) are ray-local coordinate systems constructed with MinRot, which rotates each camera's canonical \(\mathbf{e}_z\) axis onto its query or key ray. The direction \(\mathbf{u}_\infty\) is the transformed key ray at infinite depth, while \(\mathbf{e}\) is the epipole direction; \(A_{i,\mathbf{u}_\infty}\) and \(A_{i,\mathbf{e}}\) are the local frames at these two endpoints. The purple arc is the continuous set of possible correspondence directions as depth varies, and the purple dots are MeRoPE's sampled anchors. Each anchor supplies a reference rotation: exact alignment gives the identity rotation, but intermediate directions can be inferred from the response pattern across anchors.

The rotations induced by all sampled anchors form the disparity component \(\mathcal{U}^{\mathrm{disp}}\).

Put the geometric cues together

We now have three geometric components: anchor-frame rotations \(\mathcal{U}^{\mathrm{disp}}\), the retained relative ray-frame rotation \(\mathcal{U}^{\mathrm{rot}}\), and the new metric translation RoPE \(\mathcal{U}^{\mathrm{trans}}\). MeRoPE places them beside the backbone's native time and image-coordinate RoPE, denoted by \(\mathcal{U}^{\mathrm{native}}\).

Block-diagonal MeRoPE operator between query and key features
Block-diagonal structure of \(\mathcal{U}_{ab}\) (Figure 3 in the paper). Separate feature bands encode anchor-frame rotations, relative ray-frame rotation, metric translation, and the backbone's native time/image coordinates; the off-diagonal zero blocks keep the four components independent.
\[ \mathcal{U}_{ab} =\mathcal{U}^{\mathrm{disp}}\oplus\mathcal{U}^{\mathrm{rot}} \oplus\mathcal{U}^{\mathrm{trans}}\oplus\mathcal{U}^{\mathrm{native}}, \qquad \mathcal{U}_{ab}^\top\mathcal{U}_{ab}=I. \]

The identity matrix \(I\) in the second equation makes the key property explicit: every block is a rotation, so \(\mathcal{U}_{ab}\) changes geometric phase without changing feature length. MeRoPE can therefore encode both ray geometry and metric camera motion without letting a longer baseline amplify the query-key score by construction.

Camera-controlled video generation on nuScenes

We apply MeRoPE to a Wan2.2 TI2V-5B predictive video model [7] on the autonomous-driving dataset nuScenes [8]. Each video places the commanded and recovered camera paths beside the generated frames. The predictions follow the requested motion while preserving coherent roads, vehicles, and surrounding structure. Quantitative comparisons and component ablations are reported in the paper.

More nuScenes results

Generalization across camera optics

The same ray-based encoding also applies to PanShot, a benchmark for diverse camera optics introduced with UCPE [3], using a Wan2.1 T2V-1.3B backbone [7]. These videos span indoor and outdoor scenes, low light, and very wide fields of view.

More PanShot results

Grounding video prediction in the real world

A video model usually sees only the current clip. As prediction moves beyond its observed field of view, the model may lose the identity and layout of the real location.

A historical image here is a calibrated image retrieved from another traversal of the same location, possibly captured by another vehicle, at another time, or under different weather. It is not a record of the current dynamic state: moving objects need not match. Instead, it provides real observations of persistent scene structure, such as roads, buildings, and vegetation.

History SA places the retrieved image directly in temporal self-attention, while MeRoPE tells the model how its rays relate to the rays being predicted. The image can therefore act as a long-horizon visual anchor. On nuScenes, only History SA, rather than History CA, preserves retrieval-supported static structure over time, including when the retrieved and target traversals have different weather.

History self-attention preserves retrieved scene appearance over time, unlike cross-attention
History SA preserves the retrieved scene appearance, including in the cross-weather example.
More history-anchor results

BibTeX

@article{qiao2026merope,
  title  = {MeRoPE: Metric Rotary Position Embedding for Camera-Controlled Video Generation},
  author = {Qiao, Zhijian and Wang, Xinjiang and Chen, Jiajie and Huang, Haoming and
            Li, Meng and Chou, Chih-Chung and Wang, Jing and Shen, Shaojie},
  year   = {2026}
}

References

  1. VGGT: Visual Geometry Grounded Transformer.
  2. Depth Anything 3: Recovering the Visual Space from Any Views.
  3. Unified Camera Positional Encoding for Controlled Video Generation.
  4. GTA: A Geometry-Aware Attention Mechanism for Multi-View Transformers.
  5. Cameras as Relative Positional Encoding.
  6. RoFormer: Enhanced Transformer with Rotary Position Embedding.
  7. Wan: Open and Advanced Large-Scale Video Generative Models.
  8. nuScenes: A Multimodal Dataset for Autonomous Driving.