View frustum in the context of head tracking
How to define a correct frustum, thus the projection matrix?
NaΓ«m Baron - 2014
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
Projection matrix PThe Projection matrix P is usually defined with the following relations :
NaΓ«m Baron - 2014
π· = π πππππΆππππ·ππ π‘ππππ, ππππΆππππ·ππ π‘ππππ, πΉπππ¦, πππ‘ππ
or
π· = π πππππΆππππ·ππ π‘ππππ, ππππΆππππ·ππ π‘ππππ, πππππππππππππ‘β, ππππππππππ»πππβπ‘
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
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
Projection matrix PA new relations to define P:
NaΓ«m Baron - 2014
π· = π πππππΆππππ·ππ π‘ππππ, ππππΆππππ·ππ π‘ππππ, πΉπππ¦, πππ‘ππ
or
π· = π πππππΆππππ·ππ π‘ππππ, ππππΆππππ·ππ π‘ππππ, πππππππππππππ‘β, ππππππππππ»πππβπ‘
or
π· = ππππππΆππππ·ππ π‘ππππ, ππππΆππππ·ππ π‘ππππ,
ππππ‘πΈπ₯π‘πππ‘, πππβπ‘πΈπ₯π‘πππ‘, π‘πππΈπ₯π‘πππ‘, πππ‘π‘πππΈπ₯π‘πππ‘
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
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
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 ?
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
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
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
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
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