ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.09k stars 1.28k forks source link

Same Game Texture Inverse 'v' of uv coordinates in Openvr Driver DirectMode #488

Open vicdxxx opened 7 years ago

vicdxxx commented 7 years ago

Hi, guys. I made an Openvr Driver, which can work on Direct Mode. This job done on Jan 31 openvr version. Unfortunately, when I try some Steam games, some games turn upside down in my hmd, while some games display normal. I could guess some wrong adaptation between diff coordinate space in games and driver. I can see Steam home display correctly. But I can not find any api in IVRDriverDirectModeComponent, even in openvr_driver.h about such things. How did I know what a certain game that I should inverse the 'v' of uv coordinates of the rendered Textures(left & right) in SubmitLayer(...)? Or any api about game relevant infos ? Highly appreciate for any suggestions!

LoSealL commented 7 years ago

Can you list which game is upside-down? I'm also writing a Direct Mode driver, havn't met your issue. I am willing to help to find what's the cause and how to solve it.

vicdxxx commented 7 years ago

Thank you! like some Unity game is upside down, like Abbot's Book Demo. But unreal is normal, like Surge. Are you image is right in game Abbot's Book Demo? Is there somthing about projection or properties? I can not figure out yet.

davimeta commented 7 years ago

The same program to you! Anyone can resolve this program?

more links about upside down:

https://www.reddit.com/r/OSVR/comments/4yleaf/new_steamvrosvr_driver_available_fixes_display/

https://www.reddit.com/r/OSVR/comments/4zbg50/solved_fixing_flipped_steamvr_upside_down_180/

LoSealL commented 7 years ago

Oh, I see. I wrote something about OSVR rendermanager before, and also found this problem. In my openvr driver now, I only tested with unreal game and haven't met this issue. I will test with Unity game ASAP.

Here is my resolve for OSVR.

In Unity, game creates a texture with TYPELESS format and in a unity-like coordinate. So if you directly dump its texture in D3D, the image is upside-down. While unreal does the different thing about texture, so there is no problem in unreal.

In OSVR I can tell if the game is made of unreal or Unity, so I flip the texture from Unity in Y-axis again to correct them. So it's nothing about openvr, the problem is from Unity itself. I guess you should distinguish the game engine and flip rendertexture in Y-axis again.

Dmytry commented 7 years ago

One thing I noticed is that GetProjectionRaw has "top" and "bottom" swapped (the order is actually the same as in opengl, left right bottom top, but the parameter names in the header are left right top bottom). Then there appears to be some kind of upside down submitted texture issue on top of that.

Because you can get upside-down issues fixed by experimentation and adding another wrong, with careless coding you end up with an even number of wrongs making a right.

LoSealL commented 7 years ago

@vicdxxx I have tested "Abbot's Book Demo" in my openvr driver (for a wireless hmd, implementing IVRDriverDirectModeComponent), its image is correct in my scene, not upside-down. BTW, the tutorial inside is also made from Unity, is that normal in your driver?

vicdxxx commented 7 years ago

@LoSealL I have tested Unity, it was upside down. And so glad to knew you openvr driver is correct. I think may be your method is right, because most unity game need flip y-axis. But have you test the app Vive? it is unity made, And it doesn't need flip y-axis.

vicdxxx commented 7 years ago

@Dmytry thank you for you response. I noticed GetProjectionRaw ever. And it only could be invoked at the time of initialize openvr driver. I don't know how to call it per app. I do find some properties or settings of openvr driver named forceReprojectionXXX or somthing like that, but when I set these properties, it seems not work. How to know which app need flip Y-axis?

LoSealL commented 7 years ago

@vicdxxx What's the app Vive? I can't found it in steam, do you mean Vive Video?

vicdxxx commented 7 years ago

Oh, App Vive is a little strange one, you can find in Vive directory, or you try Revive.exe, then you can see.

LoSealL commented 7 years ago

@vicdxxx What's your GetProjectionRaw() return? And do you use VRTextureBounds_t in SubmitLayer?