Open Superbstingray opened 1 month ago
Hi! Sorry for the delayed reply. I don't understand what you're trying to fix here. What is the problem you're having? It looks like you're trying to shift the L/R cameras forwards or backwards (I don't remember whether -Z here is forwards or backwards haha) from the center position. Why? Last I checked the portals are still working for me and other players on our headsets. If something's not working for you, can you let me know the issue, and what headset you're using?
Thanks for responding, and sorry for not providing an explaination for this change. It's a little hard to explain exactly why we want to offset the camera backwards by half the separation value when trying to mimic Unity VR rendering with render textures, as this behavior is undocumented by Unity. But it can observed with video:
https://github.com/user-attachments/assets/74fa1477-52e6-4a01-a5da-0edd6a04b9ad
https://github.com/user-attachments/assets/cdd33f05-9704-4528-a16f-46cbfbf009cb
The SteamVR world scale is altered to exaggerate the problem for the video. The slight visual inaccuracy from not offsetting the camera Z position is obviously not normally that noticeable.
Applying this change fixes this: PortalBehaviour.cs#L259-L264
This removes the need for the 'hack' of using thick frames around the portals to mask the stereo inaccuracy, as it makes the separation values/position true to the actual VRC player eyes. I've tested this change with the Index and the original Vive so I can only assume this improvement will translate to other headsets. If/when you have time I would recommend testing this change if you have doubts about whether it's good, or works as intended.
Hmmm, I'm confused about this one. The warbling you show in the first video is something I worked very hard to eliminate while developing this prefab, and in my own testing it doesn't happen at all. The thick frames in my demo world are actually just intended to be aesthetic; in another world I'm working on (the world I actually made this prefab for in the first place!) I have a few completely seamless portals that you don't even notice walking through. They have no frames, just like the portal in your video. At least on my headset (Index) and the Bigscreen Beyond (while I had it, before I returned it lol), I had zero misalignment with my existing code.
Now, the thing you said here is interesting me:
The SteamVR world scale is altered to exaggerate the problem for the video. The slight visual inaccuracy from not offsetting the camera Z position is obviously not normally that noticeable.
I suppose it's possible that I just haven't noticed any misalignment since I haven't exaggerated the world scale. Can you tell me how to do that so I can try to reproduce it myself?
Theoretically, if the existing code already works perfectly for me, then applying this edit should make it worse for me. So I'll try out the edit and see what happens.
Here's where you can adjust the world scale:
Oh I didn't know about that setting! Super cool.
So I just tested out this edit in a modified version of my demo world where I added a frameless portal. The portal mesh is the same "SquarePortalSurface" mesh I provide with the prefab, except I raised the ground quad of the cube up by 1cm to avoid z-fighting, since the mesh is otherwise flush with the ground. Looks like this in the editor:
Ok so here's what it looks like in VR without this edit:
https://github.com/user-attachments/assets/8fbee7c9-04f4-46c1-a61a-b0da26161cc5
It's essentially perfect. There's a very slight seam, but that's an issue with antialiasing. Disabling antialiasing in vrc's settings makes it go away completely, and then there's zero seam. I also tried it at 300% world scale like you showed, and it's the same.
Here's what it looks like with this edit:
https://github.com/user-attachments/assets/d55e3a42-5469-4201-8bc6-b1250b1172c6
I'm now getting the same misalignment effect that you're getting without the edit.
So the question is, why are we having different behavior? I've tested my portals with a lot of people, and I've specifically asked about their experience with the seamlessness, and I haven't had anyone say it's misaligned. (To be fair, it's possible that they just didn't notice, because it's very subtle. Ideally I'd get videos from a lot of people so I can see for myself.) So I'm inclined to believe that the misalignment issue you're seeing is the exception, not the norm -- but I don't really have enough data to be sure haha.
My first thought as to why you're getting the misalignment is something unusual about your avatar. Have you tried a different avatar? Just so we can try to have similar conditions: I just tested with the VRChat standard public avatar "Nana the Clownfish" (can get it in the Avatars > Public list), on my Index, without FBT enabled, and with my real user height set to 5'7", and I had no visible misalignment even at 300% scale.
Another suspect is always GPU, of course. I'm on a RTX 3080, but I've confirmed with someone with a Radeon RX5700 XT that they don't have a misalignment issue either.
(Edit: Just to be clear -- the fact that I use & provide a cube-ish shape for the portal mesh, rather than just a flat quad, has nothing to do with alignment. It's to prevent flicker when traveling through the portal at angles. For example, with a flat quad, if you walk into the portal sideways-on in VR, one eye will go through the mesh before the center of your head does. That will cause you to see behind the portal in just one eye for a frame or two. And then as soon as you teleport, the other eye will suddenly be behind the other portal. There are multiple ways to address this flicker issue, but I found the simplest is just to make the portal mesh have thickness. It should work fine in most cases where the portals are static geometry. Trying to do something like making the game Portal, where you can place a portal on any flat surface, is much harder and has a lot of extra issues beyond the scope of a generic prefab, so I didn't really try to solve that.)
I did some more testing with someone who helped me with my original portal prefab before I discovered you had published this one, along with some new testers using the same headsets: Index and the original Vive. The new testers noted that passing through the portal didn't look entirely seamless with the change that makes it seamless for a few others, including myself. After adjusting every setting I could find on VRChat and SteamVR's side including settings reset and reinstall I’m at a complete loss as to what the difference could be, but I'll keep investigating to see if I can find why and also if theres a way to detect it and account for it. I can mostly rule out that the problem isn't headset, avatar, or in game height related but I will continue testing.
As for the thick portal mesh I understand the usage in doing so, it makes perfect sense. However my assumtion was about the frame around the actual portal which in my case does happen to serve the secondary purpose of masking if it's not rendering with 100% accuracy as it is for me, sorry for the misunderstanding. And I'm running a GTX 1070Ti, driver version 565.90 in the odd chance that even has anything to do with it.
Update to make the Stereo Calculation accurate to VRChat's Camera/Stereo values.