Transcript
Page 1: View frustum in the context of head tracking

View frustum in the context of head tracking

How to define a correct frustum, thus the projection matrix?

NaΓ«m Baron - 2014

Page 2: View frustum in the context of head tracking

Regular frustum

Far clip distance

Near clip distance

Frustum

Camera/HeadTop View

A frustum illustrate a Projection matrix usually defined by :

near clip distance, far clip distance, FOV and aspect ratio.

NaΓ«m Baron - 2014

Page 3: View frustum in the context of head tracking

Projection matrix PThe Projection matrix P is usually defined with the following relations :

NaΓ«m Baron - 2014

𝑷 = 𝑓 π‘›π‘’π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘“π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, 𝐹𝑂𝑉𝑦, π‘Ÿπ‘Žπ‘‘π‘–π‘œ

or

𝑷 = 𝑓 π‘›π‘’π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘“π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘›π‘’π‘Žπ‘Ÿπ‘ƒπ‘™π‘Žπ‘›π‘’π‘Šπ‘–π‘‘π‘‘β„Ž, π‘›π‘’π‘Žπ‘Ÿπ‘ƒπ‘™π‘Žπ‘›π‘’π»π‘’π‘–π‘”β„Žπ‘‘

Page 4: View frustum in the context of head tracking

Frustum’s extent

Left extent

Right extent

Top View

Far clip distance

Near clip distance

Camera/Head

A Frustum can also be defined using the β€œextents” at near clip distance in place of the FOV + aspect ratio.

NaΓ«m Baron - 2014

Page 5: View frustum in the context of head tracking

Frustum’s extent

Left extent

Front View

Right extent

Bottom extent

Top extent

Left/right/top/bottom extent is the distance from the center…

in the left/right/top/bottom direction at the near clip distance.

Far clip plane

Near clip plane

NaΓ«m Baron - 2014

Page 6: View frustum in the context of head tracking

Projection matrix PA new relations to define P:

NaΓ«m Baron - 2014

𝑷 = 𝑓 π‘›π‘’π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘“π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, 𝐹𝑂𝑉𝑦, π‘Ÿπ‘Žπ‘‘π‘–π‘œ

or

𝑷 = 𝑓 π‘›π‘’π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘“π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘›π‘’π‘Žπ‘Ÿπ‘ƒπ‘™π‘Žπ‘›π‘’π‘Šπ‘–π‘‘π‘‘β„Ž, π‘›π‘’π‘Žπ‘Ÿπ‘ƒπ‘™π‘Žπ‘›π‘’π»π‘’π‘–π‘”β„Žπ‘‘

or

𝑷 = π‘“π‘›π‘’π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘“π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’,

𝑙𝑒𝑓𝑑𝐸π‘₯𝑑𝑒𝑛𝑑, π‘Ÿπ‘–π‘”β„Žπ‘‘πΈπ‘₯𝑑𝑒𝑛𝑑, π‘‘π‘œπ‘πΈπ‘₯𝑑𝑒𝑛𝑑, π‘π‘œπ‘‘π‘‘π‘œπ‘šπΈπ‘₯𝑑𝑒𝑛𝑑

Page 7: View frustum in the context of head tracking

Adding the screen

Far clip distance

Near clip distance

Camera/Head

Screen

Top View

In immersive virtual reality system like CAVEβ„’ or Wall, the frustum has to β€œfit” to the screen…

NaΓ«m Baron - 2014

Page 8: View frustum in the context of head tracking

Adding the screen

Far clip distance

Top View

In immersive virtual reality system like CAVEβ„’ or Wall, the frustum has to β€œfit” to the screen… …wherever the Camera/Head is positioned.

NaΓ«m Baron - 2014

Extents: Left β‰  Right

Asymmetric frustum

Page 9: View frustum in the context of head tracking

Projection matrix PWhich function to choose ?

NaΓ«m Baron - 2014

𝑷 = 𝑓 π‘›π‘’π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘“π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, 𝐹𝑂𝑉𝑦, π‘Ÿπ‘Žπ‘‘π‘–π‘œ

or

𝑷 = 𝑓 π‘›π‘’π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘“π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘›π‘’π‘Žπ‘Ÿπ‘ƒπ‘™π‘Žπ‘›π‘’π‘Šπ‘–π‘‘π‘‘β„Ž, π‘›π‘’π‘Žπ‘Ÿπ‘ƒπ‘™π‘Žπ‘›π‘’π»π‘’π‘–π‘”β„Žπ‘‘

or

𝑷 = π‘“π‘›π‘’π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’, π‘“π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’,

𝑙𝑒𝑓𝑑𝐸π‘₯𝑑𝑒𝑛𝑑, π‘Ÿπ‘–π‘”β„Žπ‘‘πΈπ‘₯𝑑𝑒𝑛𝑑, π‘‘π‘œπ‘πΈπ‘₯𝑑𝑒𝑛𝑑, π‘π‘œπ‘‘π‘‘π‘œπ‘šπΈπ‘₯𝑑𝑒𝑛𝑑

Symmetric frustum only

Asymmetric frustum

How to define the extents according to the head and screen positions ?How to compute P using the extents ?

Page 10: View frustum in the context of head tracking

To get the projection matrix according to the head position :

1. Define the head position relative to the screen center. β„Žπ‘’π‘Žπ‘‘π‘ƒπ‘œπ‘ π‘†π‘π‘Ÿπ‘’π‘’π‘› = π‘ π‘π‘Ÿπ‘’π‘’π‘›. πΌπ‘›π‘£π‘’π‘Ÿπ‘ π‘’π‘‡π‘Ÿπ‘Žπ‘›π‘ π‘“π‘œπ‘Ÿπ‘š β„Žπ‘’π‘Žπ‘‘π‘ƒπ‘œπ‘ π‘Šπ‘œπ‘Ÿπ‘™π‘‘ *

2. Using the screen size (width, height) you can define the frustum’s extent at the screen distance.

π‘ π‘π‘Ÿπ‘’π‘’π‘›πΈπ‘₯𝑑𝑒𝑛𝑑. 𝐿𝑒𝑓𝑑 = βˆ’π‘€π‘–π‘‘π‘‘β„Ž

2+ β„Žπ‘’π‘Žπ‘‘π‘ƒπ‘œπ‘ π‘†π‘π‘Ÿπ‘’π‘’π‘›. 𝑋 **

3. Convert the frustum’s extent at screen distance in frustum’s extent at near clip distance. Using Intercept theorem:

𝑒π‘₯𝑑𝑒𝑛𝑑. 𝐿𝑒𝑓𝑑 =π‘›π‘’π‘Žπ‘ŸπΆπ‘™π‘–π‘π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’

π‘ π‘π‘Ÿπ‘’π‘’π‘›π·π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’βˆ— π‘ π‘π‘Ÿπ‘’π‘’π‘›πΈπ‘₯𝑑𝑒𝑛𝑑. 𝐿𝑒𝑓𝑑

4. Compute the Projection matrix using the near clip extents.____________________________________________________________________________________________________________

projMtx.m00 = (2.0f * nearClipDistance) / (extent.Right - extent.Left);

projMtx.m02 = (extent.Right + extent.Left) / (extent.Right - extent.Left);

projMtx.m11 = (2.0f * nearClipDistance) / (extent.Top - extent.Bottom);

projMtx.m12 = (extent.Top + extent.Bottom) / (extent.Top - extent.Bottom);

projMtx.m22 = -(farClipDistance + nearClipDistance) / (farClipDistance - nearClipDistance);

projMtx.m23 = (-2.0f * farClipDistance * nearClipDistance) / (farClipDistance - nearClipDistance);

projMtx.m32 = -1.0f;

____________________________________________________________________________________________________________

P from head and screen positions

* InverseTransform convert position from world space to screen local space** X, Y or Z depending on the coordinate system

NaΓ«m Baron - 2014

Page 11: View frustum in the context of head tracking

Intercept Theorem ?

A

B

C

D

E

𝐷𝐸 β€– 𝐡𝐢

𝐴𝐷

𝐷𝐡=

𝐴𝐸

𝐸𝐢

and

𝑫𝑬

𝑩π‘ͺ=[𝑨𝑫]

[𝑨𝑩]

Math proof: http://math.stackexchange.com/questions/92929/similar-triangle-theorem-in-the-incommensurable-case/92933#92933

Simple explanation:∠BAC and ∠DAE are β€œproportionally” the same.Thus, the sides are also β€œproportionally” the same.In fine, the respective quotients of the sides are equals.

NaΓ«m Baron - 2014

Page 12: View frustum in the context of head tracking

Back to frustum

Top View

We can use the β€œIntercept Theorem” to convert the screen extents to near clip extents.

A

BC

DE

𝐴𝐷 = π‘π‘’π‘Žπ‘Ÿ 𝑐𝑙𝑖𝑝 π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’π΄π΅ = π‘†π‘π‘Ÿπ‘’π‘’π‘› π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’π΅πΆ = 𝐿𝑒𝑓𝑑 π‘ π‘π‘Ÿπ‘’π‘’π‘›β€²π‘  𝑒π‘₯𝑑𝑒𝑛𝑑𝑫𝑬 = ?

𝐷𝐸 =𝐴𝐷

π΄π΅βˆ— 𝐡𝐢

𝐷𝐸 is the left extent at near clip distance.

NaΓ«m Baron - 2014

Page 13: View frustum in the context of head tracking

Final note

At each tracking frame (not rendering frame):

NaΓ«m Baron - 2014

1

β€’ Define the head position relative to the screen center.

2

β€’ Define the frustum’s extent at the screen distance.

3

β€’ Extent at screen distance Extent at near clip distance.

4β€’ Compute Projection matrix

Left, Right, Top, Bottom

Left, Right, Top, Bottom

Page 14: View frustum in the context of head tracking

return;

NaΓ«m Baron

Naem.Baronβ€”gmailβ€’com

Additional resources:http://paulbourke.net/stereographics/stereorender/http://schabby.de/projection-matrix/http://simply3d.wordpress.com/2009/05/30/perspective-projection-part-3/http://msdn.microsoft.com/en-us/library/windows/desktop/bb205353(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/dd373537(v=vs.85).aspx


Recommended