Occulus rift, seems there is a 20 fps hard cap

Hey, it feels strange to post an actual question on the forum, so bare with me :smiley:

I got my hands on an ocullus DK2 lately. I’ve setup the occulus rift support jars in a project, and all is working fine (I use it against 3.1 master, not the custom build).

I made a scene that runs on my work mac at around 70 fps on conventional display. Whenever I start the dual view display mode (even without the occulus rift plugged in), it is a lot slower. at first i was putting this on the fact that the scene was rendered twice and all. So I tried some optimisation, like removing SSAO, reducing texture fetches in my materials, but it didn’t increase the FPS.

I tried with an empty scene, and I still have low fps. I finally displayed the fps in the console (using 1/tpf) and it seems they are hard capped to 20 fps…

Is there something I’m missing? Did anyone got similar issue?

My SimpleApp extends OVRApplication and i call

app.preconfigureOVRApp(false, false, false, true);

I also call the super.simpleInitApp()

What are your samplescenes stats (screenshot?)?
Maybee you reach another issue here, like fillrate or similar?

Well here is the scene

Stats are ok, IMO.

The thing is, with an empty scene , I get 1600 fps on conventional display. As soon as I activate the occulus dual view mode, I have 20 fps precisely (1/fps returns 20 + or - 0,0000n).

I also tried with the given test cases in the repo (TestOVRApplication for example) and I also got 20 fps precisely.

From the top of my head it sounds like the cap issue when focus of the app is lost. There was a discussion in The Thread. I think you can also check phr00ts fork to see the changes required.

You’re definitely right.
There was a sleep(50) in LWJGLDisplay, now it’s a frame rate cap at 20…
It seems that the app acts as it doesn’t have the focus…

I don’t think we have been able to solve the issue. The work-around is to disable the sleep call.

ok found the issue.
It’s actually in the OVRAppState
https://code.google.com/p/jmonkeyengine-oculus-rift/source/browse/trunk/src/oculusvr/state/OVRAppState.java#125

...
   if( flipEyes ) camControl.swapCameras();
    
   app.getContext().setAutoFlushFrames(false); <-- this was causing the issue.
   app.setPauseOnLostFocus(false);
...

I guess this was needed with previous version of JME. Not anymore.
Looking at @phr00t’s build it seems that he merged latest changes in the engine, so I guess you’ll get similar issue if you pull latest version.

With the current 3.1, you should be able to get oculus working like this:

public static void main(String[] args) {
    MyApp app = new MyApp();
    app.setLostFocusBehavior(LostFocusBehavior.Disabled);
    AppSettings settings = new AppSettings(true);
    settings.setSwapBuffers(false);
    app.setSettings(settings);
    app.start();
}

You should not need to use OVRApplication or whatever.
Let me know if it doesn’t work.

You should definitely use OVRApplication, since it does a few more important things & this has been fixed. No need to specify setSwapBuffers(false) yourself – it is handled automatically by OVRApplication. I also still recommend using my github repository, although the main jME3 branch may work.

EDIT: The fix was here:

https://code.google.com/p/jmonkeyengine-oculus-rift/source/detail?r=174

Thanks, I figured about the setSwapBuffers.
However I don’t really understand the OVRApplication vs the OVRAppState. IMO all could have been done in the app state.

Anyway it’s working great and the setup is really easy. Nice work.

And I confirm that it works with latest jme master.

mhhh you pushed it 3 hours ago :stuck_out_tongue:

hello i have a problem with oculus rift on jmonkey engin
java.lang.NoSuchMethodError: oculusvr.app.OVRApplication.setLostFocusBehavior(Lcom/jme3/app/LostFocusBehavior;)V
at oculusvr.app.OVRApplication.simpleInitApp(OVRApplication.java:123)
at Main.simpleInitApp(Main.java:35)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)

You didn’t load the JNI library.

Actually, in this case the issue is that jME 3.0 is used with a plugin designed for 3.1.
The plugin can be made to be compatible with both by using reflection.

thank you for answering . but I really do not see that 's what I have to do exactly. I would be most grateful if you could enlighten me

Easiest thing is to use JME 3.1 since the plugin is not designed to work with 3.0.

I can not find JME 3.1 and I do not know how to do an update. You have a link to get jme 3.1?
thank you for your answers

Download or clone the master from github

then do this:

No need to mess with github cloning or building your own. I build 3.1 myself & provide the libraries for simplicity here:

If you need other libraries, they can be found here:

The included JAR may still work with the Oculus v0.4.4 SDK. However, we are in the process of converting it to OpenVR. It isn’t compatible with Oculus v0.5 (or v0.6).

phr00T : I come back to you I have try the solutions you 're saying but I can not run my projects.
I retrieve librarys and I imported them into my project (that’s how I should do it or there’s a way to do it?)

i have this error :
mai 15, 2015 10:27:02 PM com.jme3.app.Application handleError
Grave: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NoSuchMethodError: oculusvr.app.OVRApplication.setLostFocusBehavior(Lcom/jme3/app/LostFocusBehavior;)V
at oculusvr.app.OVRApplication.simpleInitApp(OVRApplication.java:123)
at mygame.Main.simpleInitApp(Main.java:27)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)

thank you for helping me