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
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 »

"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 »

That one was pretty good (although a simplistic game).
Zeal wrote:
For my one, it's an addon provided as a couple of source files you can add to your C++ project.
Have you (or anyone) released the source for your wrapper/plugin? Or is everyone rolling their own?
I released the DK1 sdk wrapper a while ago, but I haven't given out any code for the later sdks.
It will be out at some point (MIT licensed), when I get time. I also don't feel like working on it while waiting for my CV1 to arrive. My programming time is being diverted to Imgen (procedural texture generation) now
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 »

Yeah, the game didn't look that great but her reactions were a laugh.

I'm constantly agonizing over Rift or Vive. As I've said before, I'm leaning strongly to Vive but I'm reading and watching lots of comparisons and there are pros and cons both ways. It's not exactly cheap to get either. Pro for Rift seems to be slightly less weight and slightly better lenses, pro for Vive is slightly better tracking, on board camera, room VR and Steam integration. The Vive also has the two hand controllers, though this makes it more expensive, and Rift will supposedly have hand controllers soon. Also possible Rift might end up with some exclusive "killer app" game, they say they're planning in exclusives.

Feels like having to choose between VHS or Beta in the early days.

I'll probably go with Vive and live with it. Both are supposed to be really good, plus odds are I'll be upgrading to something much better in 2 or 3 years anyway.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Re: Ogre / Oculus Rift DK2 Progress

Post by Zeal »

I released the DK1 sdk wrapper a while ago, but I haven't given out any code for the later sdks.
It will be out at some point (MIT licensed), when I get time. I also don't feel like working on it while waiting for my CV1 to arrive. My programming time is being diverted to Imgen (procedural texture generation) now
Any good tutorials you would recommend for somebody trying to implement rift support (dk2?). I'm just looking to get basic functionality working while we wait for your wrapper.

*also should note, I am not interested in positional tracking (yet) for this little app. So I would imagine it will be pretty easy to get just the basic functionality going in ogre?

*holy crap it's hard to find tutorials for this! Everything is for unity... The only thing I found was...

http://www.charlesodale.com/c-hello-wor ... sdk-1-3-0/

which is a little scary... Does the oculus store really launch every time you run your app? And that tutorial doesn't even touch how you implement rendering.
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 »

There's lots of official documentation.

https://developer.oculus.com/documentation/

Also, implementing head-tracking is probably the easiest thing and taking it out won't make things any easier (but may make you sick, lol).
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Re: Ogre / Oculus Rift DK2 Progress

Post by Zeal »

Thanks cyber! I usually like to try and find user created tutorials/examples, but for this one looks like I will need to rely on the 'official' manual.

Good to see you on the Ogre forums!
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Re: Ogre / Oculus Rift DK2 Progress

Post by Zeal »

So reading through...

https://developer.oculus.com/documentat ... distortion

How are you guys creating the texture swap chain? In other words, how do we pass a Ogre render target to the rift?
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'll put some texture code up when i get home.

My college just got our Vive today and my oculus cv1 is still MIA, so I might start looking at OpenVr integration. There should be a lot of shared code.
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 »

We can't give an ogre texture to the oculus sdk. We also can't tell ogre to render into an oculus sdk texture.
But what we can do is copy an ogre texture over the top of an oculus texture.
The code varies by render system. I've got dx11 and gl working, dx9 would be different again (I'm now Ogre 2.1 only, so don't have dx9).

Here's the actual updating (happens just after ogre renders a frame):

Code: Select all

		int index = 0;
		ovr_GetTextureSwapChainCurrentIndex(g_HMD, g_textureSwapChain, &index);

		#ifdef OGREOCULUS_DX11
			if(!g_usingGL)
			{
				ID3D11Texture2D* texture = nullptr;
				ovr_GetTextureSwapChainBufferDX(g_HMD, g_textureSwapChain, index, IID_PPV_ARGS(&texture));
				g_deviceContext->CopyResource(texture, ((Ogre::D3D11Texture*)g_ogreRenderTexture[0].get())->GetTex2D());
				texture->Release();
			}
		#endif
		#ifdef OGREOCULUS_GL
			if (g_usingGL)
			{
				GLuint err;
				Ogre::GL3PlusTexture* gt = ((Ogre::GL3PlusTexture*)g_ogreRenderTexture[0].get());
				bool outfsaa;
				GLuint srcid = gt->getGLID(outfsaa);
				GLuint dstid;// = ((ovrGLTexture *)g_textureSet[0]->Textures)[g_textureSet[0]->CurrentIndex].OGL.TexId;
				ovr_GetTextureSwapChainBufferGL(g_HMD, g_textureSwapChain, index, &dstid);
				Ogre::GL3PlusFBOManager *fboMan = static_cast<Ogre::GL3PlusFBOManager*>(Ogre::GL3PlusRTTManager::getSingletonPtr());
				glBindFramebuffer(GL_READ_FRAMEBUFFER, fboMan->getTemporaryFBO(0));
				glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboMan->getTemporaryFBO(1));
				glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, srcid, 0);
				glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dstid, 0);
				glBlitFramebuffer(0, 0, g_idealTextureSize.w - 1, g_idealTextureSize.h - 1, 0, 0, g_idealTextureSize.w - 1, g_idealTextureSize.h - 1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
				err = glGetError();
				glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
				glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
			}
		#endif
		
		ovr_CommitTextureSwapChain(g_HMD, g_textureSwapChain);

		ovrLayerHeader* layers = &g_layer.Header;
		ovrResult result = ovr_SubmitFrame(g_HMD, g_frameIndex, 0, &layers, 1);
In dx11 I use CopyResource to copy the texture over the oculus one.
In gl I use Ogre's two temporary Frame Buffer Objects to do a blit operation (a copy).

I've attached my current test code for the rift wrapping. It's not finished and is mainly just crappy code to get things on screen, not ready for actual release to the public yet. But it might help you (since there's so many little steps that need to go together for any of this to work. Not the actual project, that's using a framework I can't release. But the ogre to oculus wrapper code.
Only a couple of steps are needed to use it:
After Ogre is started, call:
OgreOculus::initOculus(m_sceneManager, m_window);
This will build the render textures, set up the compositor for stereo, make the cameras, init the rift, etc.
Then in your main loop replace your ogre rendering (such as renderOneFrame) with this call:
OgreOculus::update();
That updates the cameras based on the hmd, does an ogre render, does timewarp, etc.
Note: this is all Ogre 2.1 code. Most of it might work in lower ogres, but the entire compositor section will need to be rewritten in that case.
Attachments
ogreoculus.7z
(4.17 KiB) Downloaded 215 times
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Re: Ogre / Oculus Rift DK2 Progress

Post by Zeal »

Thanks!

Will check this out when I get home!
cherrychalk
Gnoblar
Posts: 6
Joined: Wed May 11, 2016 5:15 pm
x 1

Re: Ogre / Oculus Rift DK2 Progress

Post by cherrychalk »

I got your test code plugged into a few of the 2.0 samples -- great work!

Is the plan (if there is one) still to continue along this route with oculus sdk as opposed to openvr? As-is it's just oculus/vive, but I fear as new competitors spring up we'll be drowning in SDKs

Or, maybe to get acceptable performance we have to target them individually.
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 »

From what I've heard, native OculusSDK integration gives better results than OpenVR integration when you are using a rift. Both will work fairly well, but since OpenVR redirects through the same Oculus SDK we are using, it just adds an extra layer of indirection over the top, causing more latency and a little less flexibility.
Using OpenVR does give the widest audience, but I think a separate build for each would be the best option for the end user. That will probably be needed anyway since OpenVR probably won't fully support all the features of the Oculus Touch when it comes out (the capacitive buttons for finger gestures, etc).

Luckily 90% of the system is the same for both.

It should be possible to support multiple sdks via the one wrapper, using a combination of preprocessing and runtime checks to choose which vr system to use. The Ogre side just needs to be given the settings to use (fov, ipd, head pos and orientation).
cherrychalk
Gnoblar
Posts: 6
Joined: Wed May 11, 2016 5:15 pm
x 1

Re: Ogre / Oculus Rift DK2 Progress

Post by cherrychalk »

Kojack wrote: Luckily 90% of the system is the same for both.
Yesterday I was going to say that wasn't true-- then I realized my mistake. I was doing way more work than I needed to.
I have OpenVR working with OpenGL now. DirectX shouldn't be too bad but I haven't gotten there yet.

The main difference in OpenVR is that you submit your textures to each eye independently -- so instead of setting up 1 workspace with half left eye and half right, you just render each camera to its own. Easy.
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 »

Hi Kojack, I'm working on HTC Vive integration, and cherrychalk has made some code available that uses your code. Could you tell me an official license for your code? MIT or public domain or whatever? I'm a bit paranoid, I hate using code without a license.
"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 »

It's going to be MIT.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Ogre / Oculus Rift DK2 Progress

Post by OGREHEAD »

I am using a dk2 and messing around with the Oculus sample code posted earlier and get blue and orange edges the further away from the center view an object is.
The Oculus sample code works fine apart from this problem.

On my normal monitor I do not get the problem, but inside the Oculus this happens.
So I was thinking that perhaps I need to adjust parameters directly for rift, but I am not sure if this can be done or this is the actual problem.

Is there any way to fix this and remove the blue and orange edges?
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 »

Hmm, that's odd. That sounds like the oculus sdk isn't doing chromatic aberration correction (the lenses form the coloured edges, so the sdk creates the opposite error to cancel them out).
In the past this used to be done in shaders by us, but it's all hidden in the sdk now, we don't really have control of it).

Which sdk version are you using?
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 »

Hey Kojack. I've made my first test demo of OpenVR integration with Ogre 1.10 DX11, over in the thread http://www.ogre3d.org/forums/viewtopic. ... 28#p526128

Hope you don't find it presumptuous, I've included you in the license as Kojack and put you down as MIT. I don't actually know which code I copied from cherrychalk is yours. If you'd like me to change any of the info, let me know.
"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 »

No prob, sounds cool. :)

My CV1 is 12km away, should be delivered tomorrow.
Shame my workload has bumped up. I won't have much free time before friday. I'm teaching network programming tomorrow, then have another 12 hours of classes to prepare tomorrow night.
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Ogre / Oculus Rift DK2 Progress

Post by OGREHEAD »

I am using sdk 0.5.0.1 for linux.

The rift tuscany demo is working perfect.

I tried disabling the compositor completely but still the Oculus has the blue and orange edges or chromatic aberration problem.
When I remove the physical lenses from the rift I am not able to see the edges, but obviously this is not a solution and it is probably there anyway, even though it can not be seen easily.

Also the view is skewed when I tilt the hmd, so there is something wrong with the initialization of the hmd I guess.
Although it seems that the hmd renders my desktop correctly, when I do not run the ogre app, with no skewing.

So I get skewing and colored edges and probably either need to disable something when initializing oculus hmd or set some matrix or similar, just do not know how or what.
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 tried my new CV1 with Ogre for the first time.
Wow. Being able to walk around the ninja (with his shiny polished brass substance material) is great. Standing and moving a little with the DK2 was cool, but the cable was short and the camera was low fov. The CV1 has a 4m cable and much better camera.

Walking up to the wall of Ogre PBS spheres was great too.

Of course the biggest problem is not seeing any part of my body. I'll really need to fix that, I need hands! Not Oculus Touch, I doubt they'd give them to me without a commercial game nearing completion. Not Vive wands either. Leap Motion is the true VR hand tracker! I've got the new Leap VR mount for CV1/Vive shipping from america right now. I've already got a Leap on my DK2, but the front of the CV1 is curved and won't sit the mount frame well. The new mount is curved too.

Seeing how good Ogre looks on the CV1 has reinvigorated me, I might do some VR coding this weekend. Adding Leap support will be a priority.
Or I'll just play Dark Souls 3. Hard to tell. :)

Image
(Image is actually side by side stereo, the right side is cropped by the forum, open the image separately to view it all)
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 hadn't seen the Leap Motion controller. They look neat, I might get one at a later stage, they aren't too expensive either. I only know from the Vive that having some kind of "hand" seems integral to the VR experience. Having used 3DVision for a long time, stereo vision is no biggie to me. Head tracking is huge, but without hands I'd feel like a disembodied ghost. And actually "holding" a gun in each hand is a lot of fun. In Hover Junkers, I'm often ducked down on the floor, hiding behind a piece of junk metal scrap, and reaching up over the top blasting away with an uzi.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Ogre / Oculus Rift DK2 Progress

Post by frostbyte »

RUIS is a nice project( but no c++ backend??? ) http://blog.ruisystem.net/about
as i understand it's main feature is binding all supported devices( ??? ) to the same coordinate system + otherstuff
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
OGREHEAD
Goblin
Posts: 260
Joined: Tue Feb 02, 2010 6:25 pm
x 2

Re: Ogre / Oculus Rift DK2 Progress

Post by OGREHEAD »

OK I almost fixed my problems.

Skewing was happening because of two scaled cameras.

I updated the compositor to do chromatic aberration and that helped quite a bit.
Only problem I have left is perfecting the chromatic aberration values.

I use these values for chromab:
Ogre::Vector4(0.996f, -0.004f, 1.014f, 0.0f);
I am not sure what the values should be exactly and I am not able to get the values out of the hmd, which I have tried to get like something this:
HMDInfo.ChromaAbCorrection[0]
But HMDInfo is not accepted, so I am not sure the chroma values are correct and I would like to get relevant velues from the oculus hmd.

So what are the correct values for chromab and how do I access oculus hmd to get chromab and other values such as the fov and ipd?
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Ogre / Oculus Rift DK2 Progress

Post by frostbyte »

ogre-leapMotion integration...
https://github.com/anilbey/HandVisualiser
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
Post Reply