Ogre / Oculus Rift DK2 Progress

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

Ok, more testing.
It seems the ovr_CreateSwapTextureSetD3D11 call ignores the specified number of swap textures to make and always makes 2. I told it to make 1, so my code was only replacing the first one. I'm now replacing both, no difference.

I even modified the layer object so it was passing in null texture pointers, it still rendered the original oculus texture. The layer object is accessed, changing it's texture set pointers to null crashes, but changing the texture pointers inside of the texture set does nothing.
I've gone over hex dumps of the layer, texture sets and textures in memory, no hidden pointers to the originals in there. Somewhere in the oculus sdk it's keeping it's own pointer to the textures and using that instead of the ones we pass in.
I'm going to try using some different layer types (I'm using the most common one: eyefov. There's others for things like floating billboards).

Edit: I tried the Direct layer (bypasses distortion, just dumps the texture straight to the headset), it still uses the old texture, even with it's texture pointers set to null.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

I've now got a basic Oculus 0.8 / Ogre 2.1 wrapper working. It's using the texture copy method. Works fine though.

Still a lot to do:
- many functions to add
- it's DX11 only so far
- no shutdown or cleanup (crashes ogre on exit)
- no error checking
- probably a lot more

But it's working, so yay for slight progress.
arkeon
Goblin
Posts: 272
Joined: Fri Dec 04, 2009 6:02 pm
x 38

Re: Ogre / Oculus Rift DK2 Progress

Post by arkeon »

Great ! good job !

I just got a quick look on the steam openVR it seems interesting too.
OpenSpace 3D Project manager
http://www.openspace3d.com
User avatar
cybereality
Hobgoblin
Posts: 563
Joined: Wed Jul 12, 2006 5:40 pm
x 12

Re: Ogre / Oculus Rift DK2 Progress

Post by cybereality »

Great work, Kojack.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: Ogre / Oculus Rift DK2 Progress

Post by mkultra333 »

Good stuff Kojack. I'm still following this with great interest.

I'll be trying to hack your work into 1.8 or 1.10 probably, so hopefully the techniques won't be too different.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

Most of it should be pretty similar between 1.8 and 2.1, it's mainly the compositor system that's different. In Ogre 1.x you wouldn't need the compositor, just render into textures. In Ogre 2.1 compositors are needed for all rendering.

Hmm, what am I going to use as a demo scene? I need some equivalent of the oculus tuscany demo, a nice little simple scene that looks good. My original idea was a combination of skyx and hydrax to make a tiny desert island, but I have a feeling those two don't support ogre 2.1.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

Working on opengl support...
Damn it, oculus and ogre headers are fighting over control of opengl headers.
If oculus headers are included first, the ogre headers give compiler errors inside of gl headers.
If the ogre headers are first, the oculus headers abort compiling because they detected ogre included gl headers before oculus.
Either works fine on their own. But I need both in one cpp. Time to dig into the include tree, to see wtf is going on.
(Or just stick to dx11 which is working)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

OpenGL build errors now seem to be over, I can get back to actual coding.
Argh, I hate debugging deeply nested header errors.

Here's what I had to do: insert these lines between the oculus and ogre headers:

Code: Select all

#undef GL_VERSION_1_1
#undef GL_VERSION_3_0
#undef GL_VERSION_3_1
#undef GL_VERSION_3_2
#undef GL_VERSION_3_3
#undef GL_VERSION_4_0
#undef GL_VERSION_4_1
#undef GL_VERSION_4_2
#undef GL_VERSION_4_3
#undef GL_VERSION_4_4
The oculus sdk has a custom alternative to gl3w.h and glcorearb.h called capi_gle_gl.h (over 4800 lines of typedefs and #defines). It does roughly the same stuff, but seems to miss some of it. When Ogre tries to include gl3w.h, each GL version section is skipped because they think they are already defined, but they are only 99% complete, there's some missing typedefs from each version. I can't just put gl3w.h with the complete definitions first, because the oculus header explicitly checks for that and throws a #error to prevent it.
Undefining means a ton of macro redefinitions, but it at least gets past the includes without errors.

Now to actually put the code into use and see if opengl at least runs with a black screen, then search for a way to copy opengl textures over each other. (I'm not a GL coder)

(I think I need a shower after all that, I feel icky)
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

OpenGL running without crashing. But the texture copy isn't working.
I'm trying to use glCopyImageSubData (apparently it should be fast), but it just returns GL_INVALID_VALUE. There's 15 parameters, 14 of them can cause that error.

DirectX11 is SO much nicer to use.

I've had enough for now, going to play a game for a while instead.
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Ogre / Oculus Rift DK2 Progress

Post by frostbyte »

there's too much suffering here...maybe take a short-cut?...
https://www.opengl.org/registry/specs/NV/DX_interop.txt dont worry about it being nvidia only - its not...https://community.amd.com/thread/166698
https://github.com/jherico/OculusRiftIn ... nterop.cpp
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

That could work, I'll take a look. Although that means we'd need both opengl and directx contexts running at the same time (so opengl ogre can give a valid directx device context to the oculus sdk before copying an opengl-shared-as-directx texture).

I got one frame to copy via opengl from ogre to oculus. Then it stops. That was by doing evil things like bypassing the higher level texture system and creating a lower level ogre gl3 texture class (it's constructor takes a texture id, but we aren't supposed to call it directly). Opengl freaked out and gave 5000+ error messages. :)

But I think I know what to do now based on learning a bit more about opengl and reading ogre's gl3+ code. I just haven't tried it yet (been busy fighting misinformation in the CV1 preorder rampage and became a godfather).

I also know one thing I want in a demo. Been doing a little blender work. :)
kubiak54
Gnoblar
Posts: 2
Joined: Thu Jan 14, 2016 5:29 am

Re: Ogre / Oculus Rift DK2 Progress

Post by kubiak54 »

Hello Kojack,

I am loving your work, its awesome!
I would love to ask you for help, I am running Oculus on Ubuntu on ROS (robotic operating system) using Rviz (which is using Ogre). I am using this package https://github.com/OSUrobotics/oculus_rviz_plugins where a lot of your code is used.
I have been struggling to get it to work a lot and now finally have it working - unfortunatelly without an undistortion.
Original code is using this piece of code "m_compositors->setEnabled(true);" which actually makes rendering not working properly for me.
Please see attached 1.png and 2.png - Its rendering big squares getting actually right color depending on what I am looking at but no shapes or anything, just totally solid color all over. All scripts (compositors, materials) are loaded. By examining files I think problem is somewhere in warp.vert or warpWithChromeAb.frag as I can again "correct" everything by commenting some lines.
See 3.png how correct not undistorted image look like.
It would be so awesome if you could help me with this.

Great work and thank you.
Jakub

1.png http://s7.postimg.org/fdzid40bv/image.png
2.png http://s7.postimg.org/42wuoqtgr/image.png
3.png http://s7.postimg.org/ldn9grl4b/image.png
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

I've got it working in OpenGL now.
I'm using the Ogre::GL3PlusFBOManager's two temporary FBOs. I use raw opengl to bind one FBO as reading from the Ogre render texture, the other FBO for writing to the Oculus texture, then call glBlitFramebuffer.
So that's both DX11 and GL3+ working with oculus. Now I can start on cleaning up all this mess and making a friendlier wrapper.

kubiak54 wrote: By examining files I think problem is somewhere in warp.vert or warpWithChromeAb.frag as I can again "correct" everything by commenting some lines.
Hmm, those aren't my files. My original oculus code only supported CG. Those opengl shaders appear to have been made by the osurobotics devs.

Are there any errors showing up in the ogre.log?
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

Rather than improve the code, I got distracted by playing with PBS materials in the HLMS, with textures exported from Substance Designer. I've got a nice shiny bumpy metal floor now for my current test scene. :)
Although shiny doesn't work as well for a floor when there's a statue sitting on it without reflection, but it's good enough for now.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

I just creeped myself out.

I've changed from the Athene statue to the ninja. I have a Substance brushed copper material on him, he looks a bit like a copper version of Gort the robot from The Day The Earth Stood Still.
All my testing is sitting down. I've held the rift to my face a few hundred times yesterday while playing with material settings.

Anyway, I just tried a standing experience. I stood up, adjusted the camera (in engine and in real life) and got really close to the ninja. I was almost nose to nose with him, moving around looking at the reflections on his face close up. It just felt so uncomfortable and unsettling. I kept expecting a sudden jump scare, even though I wrote the damn program and know that's impossible.
:)


Some actual progress though, I've now the choice of gl3+ vs dx11 to be both preprocessor and runtime based. It can decide which one to use (it has to do various low level stuff with them directly) based on the current ogre render system, but if you know you will never use one of them you can remove it's define and none of it's headers and stuff will pollute the project.
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: Ogre / Oculus Rift DK2 Progress

Post by xrgo »

Kojack wrote:I just creeped myself out.
Lol, I work with VR too and is f'ing amazing :lol:
I am highly interested in your work =) we are using a very old sdk so it works in linux but we are going to port our engine to windows soon.
Is it working with every feature? time warping? chromatic ab.? etc?
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

Yep, all that works. The sdk does it all (so we don't have to make shaders that do those features).
kubiak54
Gnoblar
Posts: 2
Joined: Thu Jan 14, 2016 5:29 am

Re: Ogre / Oculus Rift DK2 Progress

Post by kubiak54 »

Hi Kojack,
well I cant seem to find any ogre.log absolutely anywhere in my computer, I did run nautilus and run searching there so every file in the computer is being searched but nothing to find, even similar in name.
Can you suggest?
Or maybe suggest what is going on without log? My friend managed to run this on other graphic card - so i guess its cobnnected with just some particular GPUs.
Thank you!
Jakub
User avatar
zarthrag
Greenskin
Posts: 128
Joined: Sat Jul 24, 2004 9:07 am
Location: Tulsa, Oklahoma

Re: Ogre / Oculus Rift DK2 Progress

Post by zarthrag »

It's been quite a while since I've posted here... Glad to see you guys are still so active! ORGE has always been my goto tool for putting together quick visualizers testing tools for our hardware/product development efforts. We're currently in the middle of a VR project, and am not really familiar with all the new changes in OGRE. (The last time I used it was in 2012 - https://www.youtube.com/watch?v=zyTpPFM2iDE)

Kojack, are there any code/examples posted anywhere to play with, on this? And, also, have you looked at openVR/steamVR? I'm looking to be able to overlay data using the various compositors. I'll be glad to assist with integration of these directly into OGRE - we have a Vive/Oculus on preorder...just DK2 units until then. Our own goal is to build an application that supports VR directly, but can also use the compositor to display it's own data on top of other VR applications
ZarthCode LLC
User avatar
cybereality
Hobgoblin
Posts: 563
Joined: Wed Jul 12, 2006 5:40 pm
x 12

Re: Ogre / Oculus Rift DK2 Progress

Post by cybereality »

Good stuff, Kojack.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

There's always something in my way. :(
Mainly work, over the last 6 weeks it's been artificial intelligence. We had a robot tournament today using a framework I wrote, most of my coding time has been working on that.

Anyway...
I haven't touched much recently because I'm waiting for SDK 1.0. Previous changes have undone too many things I'd already done, so I'm waiting for the stable one. I've got a CV1 on preorder for april, so not long now. :)

I've been thinking of looking into OpenVR too, I may have access to a Vive via work, but no idea when that will be.
At least the rift will run on it too even if I don't have a Vive.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: Ogre / Oculus Rift DK2 Progress

Post by mkultra333 »

I assume OpenVR is DX11 and up. I had a look around but couldn't find anything on what DirectX it supports. I'm assuming the Vive needs DX11 at least.

I'm going to buy either an Oculus Rift or a HTC Vive next month, but I don't know what to get at the moment. I'm leaning toward the Vive because it has the whole Steam integration and OpenVR thing. Although I know OpenVR is supposed to support Oculus Rift as well. It looks a bit like Vive might be easier to work with as a developer.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Ogre / Oculus Rift DK2 Progress

Post by Kojack »

Oculus sdk 1.3 is now available.
Sadly it breaks compatibility with everything released so far (not unexpected for the first 1.x release to go public, but I'm sure they said 0.8 stuff would work in it).
The sdk change notes make it sound like a bunch of stuff has changed, so back to the drawing board...

The 1.x series is supposed to not break compatibility from here on, so maybe I can finally start work on this thing seriously. (Sadly it released 4 days into my 5 day weekend and I have stuff to prepare for tomorrow's class)
mkultra333 wrote: Although I know OpenVR is supposed to support Oculus Rift as well.
It did, but not as well as the native oculus sdk. OpenVR acted as a wrapper around the Oculus 0.8 sdk if it detects a rift, so it just adds extra overhead and lacks full feature support. Due to the way render textures are treated, I'm guessing internally it does what I'm doing, copying the texture over the oculus one.
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: Ogre / Oculus Rift DK2 Progress

Post by xrgo »

Keep it up Kojack!
while I am still waiting for linux support =(
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Ogre / Oculus Rift DK2 Progress

Post by dark_sylinc »

Kojack wrote:Oculus sdk 1.3 is now available.
Sadly it breaks compatibility with everything released so far (not unexpected for the first 1.x release to go public, but I'm sure they said 0.8 stuff would work in it).
The sdk change notes make it sound like a bunch of stuff has changed, so back to the drawing board...
TBH I feel that's a total lack of respect.

The Oculus guys have been obsessed with low latency, performance and no man-in-the-middle that could add latency. Completely understandable since that tends to ruin the VR experience. However in that pursuit, they've been trying to come with all sorts of hacks to eliminate all middle guys (compositor, driver, hardware), while neglecting the simple solutions that would work everywhere without major hacks, such as split screen.

While their pursuit of the perfect VR experience is commendable, the extreme level of their pursuit has only caused delays, pushed deadlines, increased costs, removed support for multiple OSes, and completely mistreated their devs with non-backwards-compatible SDKs.

/rantoff
Post Reply