HMD camera location in material

For a material I would like te have the actual HMD location in the material. If I get the current camera location and compare it with the CameraPositionWS node there is an offset (~3.5cm). I need to compare this value to a player location variable in a material parameter collection, and I would like to have this a bit more precise.

What is causing this slight offset between the CPU camera location and the one known on the GPU? And is there any way to get or calculate the actual HMD location on the cpu so I can pass it on to the GPU and compare it more accurately with the CameraPositionWS?

Have you perhaps found out anything about this? I’m having the same issue !

So I realize this is three years later, but I was looking into a similar issue and figured out a potential solution.

CameraPositionWS gives you the location of the rendering eye, which varies between the left and right eye.
If you put “GetPrimaryView().WorldCameraOrigin” into a custom hlsl node it will give you the left eye camera position. GetInstancedView().WorldCameraOrigin will give you the right eye. Averaging them should get you the actual HMD location.

(GetInstancedView().WorldCameraOrigin + GetPrimaryView().WorldCameraOrigin) * 0.5f

This was done on 4.19 with instanced stereo, so I’m not sure if it would work in other configurations