How to get the relative position of the left and right eye to the head sensor?
On the host we can query the position and orientation of the head as follows:
fun getHeadPose(): Pose {
val head = Query.where { has(AvatarAttachment.id) }
.eval()
.filter { it.isLocal() && it.getComponent<AvatarAttachment>().type == "head" }
.first()
return head.getComponent<Transform>().transform
}
In a material shader we can get the position of the left and right eye via the uniforms:
g_ViewUniform.eyeCenter0 and g_ViewUniform.eyeCenter1
But is there either...
* ....a way to get the position of the head in the shader (short of passing it as a uniform attribute every frame)?
or
* ... a way to get the position (or relative position) of the left and right eye on the host?
Hi!
A note on the head pose: it will likely have better performance if you call Scene.getViewerPose() directly, than doing a query.
> a way to get the position of the head in the shader (short of passing it as a uniform attribute every frame)?
If we ever need to get the head position in a shader, we just use getMidEyeCenter() included in metaSpatialSdkCommon.glsl. This averages the eye positions to calculate a position for the head.
> a way to get the position (or relative position) of the left and right eye on the host?
Unfortunately, we do not expose this yet.