Jump to content


Photo

I'm working on a VR version - early alpha


  • Please log in to reply
231 replies to this topic

#1 cabalistic

cabalistic

    Member

  • Member
  • PipPip
  • 80 posts

Posted 22 July 2017 - 11:13 AM

*
POPULAR

Hey guys,

 

I've been wanting to familiarize myself with VR development for a while, and I thought it would be nice to convert an existing (open source) game as an exercise. I picked The Dark Mod, because given that there are already two VR mods for Doom3 out there, it seemed like an obvious choice for some learning-by-copying. Of course, that was before I realized that The Dark Mod is based on an older engine version and that there have been some significant changes to the renderer ;)

 

Anyway, I still went forward, and I got basic stereoscopic rendering and headtracking working, so I wanted to share my progress with you. Before I get your hopes up, this is nowhere near the two Doom3 VR mods. In fact, stereo rendering and headtracking is pretty much all you get right now, so it's only suitable as a seated experience, and even then it's more a preview than something actually playable.

 

I had to make a few changes to the renderer, specifically I added very basic FBO support to render to the two required eye textures. The most significant challenge I faced was performance, though. VR needs consistent 90fps times two across the board, and I struggled with getting that on my 3 years old Core i5. In the end, I had to put the game tics and frontend drawing on a separate thread to run parallel with the backend, because otherwise performance was just not stable enough. This turned out to be a major pain in the ass, because even though the engine might originally have been designed to run in parallel like that, there were still hidden interactions leading to race conditions and memory leaks. No guarantees I got them all, too - it seems to run pretty stable now, but the great thing about race conditions is you never know when they'll strike :)

 

Anyway, if you want to try it out, you can find a first early release here: https://github.com/f...er/thedarkmodvr

Please note that all GUI elements will still render 2D (I haven't gotten around to adapting them yet), so GUI and HUD are not usable in the headset. Please remember to set your seated position in SteamVR. Also, given that this still uses keyboard and mouse movement, you need some serious VR legs for this, so please be careful - there are no comfort options right now.

 

Going forward, my plans are first and foremost to adapt GUI elements, so that we get at least a usable seated VR experience. There's also some bug with shadow drawing, where some shadows are rendered inconsistently between the left and right eye, which leads to annoying graphical artefacts. I do of course dream about a full-on roomscale conversion, but that is going to be a lot of work, and I don't know how much time I can really invest. So I don't want to make any promises.

 

Finally, even if you are not interested in VR, but you have some weaker hardware, this exe might still give you a slight performance increase due to the threaded renderer.


  • Bikerdude, AluminumHaste, Judith and 12 others like this

#2 AluminumHaste

AluminumHaste

    Darkmod Contributor

  • Development Role
  • PipPipPipPipPip
  • 5761 posts

Posted 22 July 2017 - 11:26 AM

Well this is freaking awesome.


I always assumed I'd taste like boot leather.

 

#3 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 596 posts

Posted 22 July 2017 - 12:12 PM

The idea is great, but many missions aren't optimised to run in high FPS. And it's not as much a GPU problem, but CPU -> GPU bottleneck, so you cant just offset that by buying a modern card.



#4 cabalistic

cabalistic

    Member

  • Member
  • PipPip
  • 80 posts

Posted 22 July 2017 - 12:20 PM

I know, the engine is entirely CPU-bound, in large part due to it being effectively single-threaded. That's why I added threading in the first place, and it helped quite a bit. I might try to do more; but for now getting GUI usable takes priority.


  • Bikerdude, Judith and Anderson like this

#5 AluminumHaste

AluminumHaste

    Darkmod Contributor

  • Development Role
  • PipPipPipPipPip
  • 5761 posts

Posted 22 July 2017 - 12:23 PM

So, the threaded work you've done, is it easily adaptable to other parts of the engine? Such as physics running on it's own thread, sound etc?


I always assumed I'd taste like boot leather.

 

#6 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 579 posts

Posted 22 July 2017 - 12:24 PM

Respect.

What version is your work based on?

We have unlocked fps, rudimentary FBO, buggy unfinished threaded game tics in source svn.

Regarding low end PC's: I think 90 tics per second could be too taxing in some places.

Try the spider cavern in NHAT for example.



#7 cabalistic

cabalistic

    Member

  • Member
  • PipPip
  • 80 posts

Posted 22 July 2017 - 12:28 PM

2.05.

I would have developed against svn, but without compatible assets, that wasn't possible :)

 

So, the threaded work you've done, is it easily adaptable to other parts of the engine? Such as physics running on it's own thread, sound etc?

No, I effectively just "restored" the threading of frontend and backend, as was originally intended in the Doom3 engine. Anything else will have to be investigated separately. I also wouldn't necessarily look at adding more threads dedicated to a specific purpose, but rather looking for parallelisation with the help of worker threads. E.g. spreading physics calculations on multiple cores. Intel's threading building blocks library would be a good choice, provided one can identify places where this kind of parallelisation works.

I originally tried it that way with certain parts of the frontend renderer, similar to how it's done in the Doom 3 BFG edition. But unfortunately I hit a few roadblocks, so I postponed that approach for a later reinvestigation.


  • Anderson likes this

#8 AluminumHaste

AluminumHaste

    Darkmod Contributor

  • Development Role
  • PipPipPipPipPip
  • 5761 posts

Posted 22 July 2017 - 12:30 PM

Ah, okay thank you


I always assumed I'd taste like boot leather.

 

#9 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 596 posts

Posted 22 July 2017 - 12:55 PM

I know, the engine is entirely CPU-bound, in large part due to it being effectively single-threaded. That's why I added threading in the first place, and it helped quite a bit. I might try to do more; but for now getting GUI usable takes priority.

 

Adding optimised assets will help a lot too, but that will take time. Or maybe someone will make VR-focused missions, that would be interesting to see.



#10 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 579 posts

Posted 22 July 2017 - 01:30 PM

2.05.

I would have developed against svn, but without compatible assets, that wasn't possible :)

Would you be interested in incorporating your version into trunk provided you were given access to assets svn?



#11 cabalistic

cabalistic

    Member

  • Member
  • PipPip
  • 80 posts

Posted 22 July 2017 - 01:34 PM

The threading work? Sure, although I'd say let's take the current alpha build for a few more test runs first, to make sure I didn't miss any potential race conditions... :)

 

The VR portion I'd say let's keep it separated for now as it's really just an experiment.


  • Anderson likes this

#12 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 579 posts

Posted 22 July 2017 - 02:05 PM

The threading work? Sure, although I'd say let's take the current alpha build for a few more test runs first, to make sure I didn't miss any potential race conditions... :)

One thing I failed on was disappearing dynamic models (e.g. guards) in the frobable area - did you get that right?



#13 cabalistic

cabalistic

    Member

  • Member
  • PipPip
  • 80 posts

Posted 22 July 2017 - 04:10 PM

I just played with the training mission a bit, picked stuff up, stole the key from the guard, knocked a guard down and picked up his body. Nothing was disappearing, all seemed fine. I found two other problems though:

- Fullscreen is borked. Might have something to do with the additional OpenGL context I'm creating. You'll need to run the build in windowed mode for now.

- There is some issue with lighting and shadows with some flickering that isn't there in the base 2.05 build. Not sure if this is related to the threading, but there's definitely something wrong.

 

Oh, also I noticed that I accidentally put VR mode to disabled by default. So if you actually want to test the VR output, you'll ned to set vr_enable to 1 in your autoexec.cfg.


  • Anderson likes this

#14 cabalistic

cabalistic

    Member

  • Member
  • PipPip
  • 80 posts

Posted 23 July 2017 - 04:33 AM

Never mind, I fixed the problem with the flickering lighting and shadows. It was a remnant of a previous failed experiment. I reverted those changes, and now it's fine again. I uploaded a fixed version.


  • duzenko and Anderson like this

#15 Anderson

Anderson

    Advanced Member

  • Member
  • PipPipPip
  • 788 posts

Posted 23 July 2017 - 06:47 AM

Swell news. My microwave laptop could see the other thread being used as a good performance hike.

 

Wasn't aware TDM runs on an older version of Doom 3. 


 "I really perceive that vanity about which most men merely prate — the vanity of the human or temporal life. I live continually in a reverie of the future. I have no faith in human perfectibility. I think that human exertion will have no appreciable effect upon humanity. Man is now only more active — not more happy — nor more wise, than he was 6000 years ago. The result will never vary — and to suppose that it will, is to suppose that the foregone man has lived in vain — that the foregone time is but the rudiment of the future — that the myriads who have perished have not been upon equal footing with ourselves — nor are we with our posterity. I cannot agree to lose sight of man the individual, in man the mass."...

 

 

- 2 July 1844 letter to James Russell Lowell from Edgar Allan Poe.

 


#16 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7821 posts

Posted 23 July 2017 - 03:04 PM

Cool stuff.

Not that I'm a expert in this area but I've read that Mutex performance is pathological on Windows:

https://www.arangodb...-mutex-rwlocks/

http://demin.ws/blog...spinlock-mutex/

Did you try using Atomics instead?
  • duzenko likes this
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#17 cabalistic

cabalistic

    Member

  • Member
  • PipPip
  • 80 posts

Posted 23 July 2017 - 03:13 PM

There isn't actually any locking going on in the two code paths. The only use of mutexes is to synchronize when frontend and backend should start and stop working, and there mutexes should be perfectly fine.


  • stgatilov likes this

#18 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 579 posts

Posted 23 July 2017 - 03:16 PM

Cool stuff.

Not that I'm a expert in this area but I've read that Mutex performance is pathological on Windows:

https://www.arangodb...-mutex-rwlocks/

http://demin.ws/blog...spinlock-mutex/

Did you try using Atomics instead?

Probably won't be much difference here because it's only waiting once per frame per thread.

I couldn't build the vr version quickly due to missing DXSDK that 2.05 required and 2.06 does not.



#19 wesp5

wesp5

    Advanced Member

  • Member
  • PipPipPip
  • 513 posts

Posted 23 July 2017 - 03:43 PM

So a side effect of this development could be that TDM 2.06 will use two threads and may run much better than 2.05?


  • jaxa and CarltonTroisi like this

#20 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7821 posts

Posted 23 July 2017 - 09:19 PM

@Duzenko:

 

The commit log is missing some events apparently. Here is one of interest:

 

 

https://github.com/f...3c9dfaa95625da8


  • jaxa likes this
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#21 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 579 posts

Posted 24 July 2017 - 05:14 AM

After building with DXSDK I get a startup error: Unknown value "testEvent1" when loading script\tdm_player.script

Current mission is Inn Business.



#22 cabalistic

cabalistic

    Member

  • Member
  • PipPip
  • 80 posts

Posted 24 July 2017 - 10:35 AM

Hm, works for me with 2.05 assets. Is it possible you tested with SVN assets? Or it's a mismatched dll/exe pair, that gave me some script-related assertions once?



#23 duzenko

duzenko

    Advanced Member

  • Active Developer
  • PipPipPip
  • 579 posts

Posted 24 July 2017 - 02:23 PM

Hm, works for me with 2.05 assets. Is it possible you tested with SVN assets? Or it's a mismatched dll/exe pair, that gave me some script-related assertions once?

Yes, svn assets


  • Anderson likes this

#24 cabalistic

cabalistic

    Member

  • Member
  • PipPip
  • 80 posts

Posted 24 July 2017 - 02:33 PM

Then try 2.05 assets :)


  • nbohr1more and Anderson like this

#25 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 7821 posts

Posted 24 July 2017 - 09:33 PM

I haven't had time to build my own but I tried both v1 and v1.1 and they both produce some visual artifacts,

random black tris around animating objects (etc). Still, better than the whole AI flickering when you get up close.


  • Anderson likes this
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users