Is there a way to get the user’s position in relation to a bounded volume camera? For instance, if I wanted to make a transform always face the user no matter where they were in the room
Unfortunately, not on visionOS. The OS does not provide any information about the location of the user relative to a bounded volume or its contents.
Hi @RSH1 –
While everything @v_vuk said is true when it comes to accessing head position relative to a bounded camera from the CPU, it’s worth noting the GPU has access to the underlying view transform (for example, the Transformation Matrix node in “View” mode). While you can’t read this back to the CPU, you could write custom shaders to take advantage of this to orient geometry toward the user by applying appropriate per-vertex transformations.
Note that this won’t affect the underlying simulation, so for example colliders used for input wouldn’t reorient, but if you’re using this entirely for visuals – for example, billboarded imposters or something – a custom shader may be sufficient.
Hope this helps!
I think you can get hand positioning
Or hack using gaze and pinch
When I try and use the Transformation Matrix to billboard in ShaderGraph, my Shader just vanishes. It works fine in the editor but not in the sim or actual device. Any ideas?
It’s tough to say without seeing the exact shader (feel free to submit a bug report and let us know the incident number: IN-#####), but a couple of possibilities come to mind immediately. The first is the difference between visionOS and Unity “world space” as described in the shader graph docs. Using the Transformation Matrix “View” will take you from visionOS world space to view space. To get the visionOS world space, you need to start with the object space and transform it to world space using the Transformation Matrix or Transform nodes. Or just use the Transform node to transform from Object to View space.
The other possibility is just that the billboard is reversed. VisionOS doesn’t support changing the cull face for shader graph materials, so back faces are always invisible.
Appreciate the reply. It’s very possible I am also just bad at ShaderGraph. I tried playing with what you said but didn’t solve the issue. Here is the report: IN-68998
Thanks! I think one issue with the shader here is that our support for the Object node is broken at the moment; the Position output always returns zero. That’s something that’s on our list to fix in the future.
However, to simplify the logic based on what I think you’re trying to do, here’s what I would suggest: do the rotation in object space based on the camera forward vector. I would recommend using the Rotate About Axis node, but it appears that has a bug as well (the angle is the reverse of what it should be). The following should work on visionOS (but will rotate the wrong way in Unity play mode–you could use the MaterialX keyword to switch between the normal and inverted axis):
Thank you! This work! It made no sense as you said in the simulator/editor but once on device it worked perfectly.