Author Topic: It's a good time for VR, since one can have HMD for $20+smartphone. I'll show.  (Read 296 times)

0 Members and 1 Guest are viewing this topic.

Offline ksotar

  • 24
It's a good time for VR, since one can have HMD for $20+smartphone. I'll show.
I have found several threads here about VR. Almost all of them ended with 2 main statements:
  • developers don’t have/can’t afford VR gear to test this feature;
  • VR will not be implemented until it can be done properly, that means after engine will be properly optimized.

First, I’ll show my VR experience with Freespace 2, which I see with my low-priced smartphone (Xiaomi Redmi 4 prime, 5” FullHD) inside BoboVR z4 mini VR goggles. Video was recorded on the smartphone itself, so as you may guess if I’m not recording, it all runs smoother. I believe this video can be watched in other HMDs to see the 3D effect.

I have developed 2 conclusions while testing this:
  • cheap alternative to Oculus, HTC Vive etc. is real, at least in space sim genre (where your character mainly sits in a chair just like you do in front of your PC);
  • it is widespread overstatement that for VR you necessarily need much more powerfull PC then for the standard mode (more on this will follow).

So there is a way to run many games for Windows in Side-By-Side (SBS) stereo mode even if they don’t support it natively, and you even don’t need paid software like TriDef. There is a tool, Reshade, that allows to inject your own shaders in Direct3D or OpenGL, and it also grants you access to the Depth buffer. It appears to be enough for the stereo 3D. Quote from Nvidia:

Traditionally, VR applications have to draw geometry twice -- once for the left eye, and once for the right eye. Single Pass Stereo uses the new Simultaneous Multi-Projection architecture of NVIDIA Pascal-based GPUs to draw geometry only once, then simultaneously project both right-eye and left-eye views of the geometry. This allows developers to effectively double the geometric complexity of VR applications, increasing the richness and detail of their virtual world.

I’d say: or otherwise, we can have VR with the same geometry complexity and little overhead compared to usual game (and not necessarily with Nvidia). And there is a shader that implements a likewise technique: Depth3D. Being properly configured it can provide quite decent Stereo 3D quality, with a really little overhead.

My setup
I plan to update this post with more information on my setup, so anyone could went VR on a cheap with Freespace. For now I just attach the principle architecture: (IDK how to change image size here, so it is a link).

As you can see we can have some decent VR experience with Freespace even without native support. Current Engine is more than enough. But of course there are some problems, and things could be better.

First off all, most phone HMDs have 16:9 aspect ratio, but images placed SBS will be at 8:9. So if the game runs in 16:9 natively, we either will have black stripes on top and bottom or will break AR, or will lose resolution. I describe it in detail here. Or there is a way that I implement: run FreeSpace in 1920x2160 (it’s 8:9) resolution then it all will become as in the aforementioned video of mine. My GTX 750 handles it fine, but my laptop - unlikely. It is quite a waste, of course - render in 1920x2160 when we only need 960x1080.

I have a roadmap in my head of what could be improved even more, but one thing at a time.

What could help right now?
If we could run Freespace in 960x1080 but stretched to 1920x1080 window it will allow to run Depth3D variant VR with a decent performance boost. I believe many old notebooks that are capable of running Freespace could handle 960x1080 as well.

Secondly, just adding native SBS support in Freespace will allow “true VR” for those who can’t run Reshade. And likely it will not be much overhead either, to render 960x1080 twice, compared to 1920x1080 once. From my experience, it is already enjoyable, so if there is an easy way to implement it, it is definitely worth to do, not waiting for some proper time.

Does anybody have thoughts on how to do it, or could help with it?

Any questions also welcome.
« Last Edit: November 23, 2017, 06:20:55 am by ksotar »


Offline ksotar

  • 24
Re: It's a good time for VR, since one can have HMD for $20+smartphone. I'll show.
Well, I tried to hook the WindowCreate call, and with some success. Game actually starts in 960x1080, then window hook makes window size to 1920x1080 (that apparently adjusts Backbuffer size as well). Then I modified Depth3D to draw Left and Right eye images side-by-side without squeezing them.

Good thing is that my GPU load went down from 100% to ~33%.
Bad thing here is that we have lost Stereo 3D effect - there is no depth in that video in fact. It must be because Depth3D shader looses correct connection between Backbuffer/DepthBuffer and/or their sizes. That means I need to figure out, how Depth3D actually works etc. It happens to be not so easy, and its author has no time to help me.

So, if I am to figure out how to draw SBS renders, I'll better try with FSO itself. And here I stuck too. I wanted to start with window size of 1920x1080 but to override viewport to 960x1080.

Basically every time there's a call to glViewport you can duplicate the renderer to split it into each eye. I used to have code to do that. I need to reimplement it and update it. My thinking was implement two viewports that split the screen in half then figure out howto turn the two views slightly, one to the left, one to the right to simulate the eye offset. Then just had to implement barrel distortion.

Well, I tried that. Looks like introducing SDL2 library lead to some changes in code, perhaps. I found only one call to glViewport in 3_8_0 version. It is in gropengl.cpp at line 1574. I tried to pass width = 960 there. That only led to half a screen rendered in start menues (no change of renderer to w960). And then I managed to start a flight, it appears to bee in fullscreen 1920x1080. So something else was called, what has changed the resolution back, I can't even figure out what.

Can someone to point me to the right direction?
« Last Edit: December 02, 2017, 11:15:24 am by ksotar »


Offline ksotar

  • 24
Re: It's a good time for VR, since one can have HMD for $20+smartphone. I'll show.
I have the following information now:

Quote from: m!m
If you mean framebuffers then you are correct and FSO uses them for the entire scene (which is also the reason why you can use the depth buffer in your shader). glViewport simply tells OpenGL where the render output should be sent to on the screen.
On current master the relevant calls are in gropengldraw.cppLine 698, gropenglpostprocessing.cpp Line 194 and gropengltnl.cpp Line 602.
gr_set_viewport is only called in matrix.cpp at the moment.

Will try to move on.