Skip to main content
Up and Coming
June 3, 2014

DX11 related lag

Lately I have run into a really big problem. Stomach churning, throw the rift off my head, reach for a bucket, awful lag and it has nothing to do with the frame rate.

There is no choppyness associated with this lag, if anything head tracking goes "extra smooth". For instance, if you roll or nod your head, the camera lags behind, to the point where you can almost get the camera to stay stationary why your are rolling/nodding (and if you do it to much.. reaching for a bucket).



The two times I have noticed it was 1) I had loads of particles on screen, forward rendering. The weird part is, I had equal amounts of particles in all direction, but the horrible lag only occurred when I looked in one direction. If anything, there where less particles where the lag happens...


2) Point light, deferred lighting. Lots of calculations here, lots of shadows being thrown around, but zero drop in frame rate, just this horrible smooth lag.


Is it just me?

Any help fixing this, or at least ways to avoid it would be greatly appreciated!

Thanks

edited to make the subject line more relevant to the topic
    This topic has been closed for replies.

    18 replies

    June 7, 2014
    If your game changes physics behavior based on frame rate, you are doing something wrong in your code. That means your game will play differently if the user's computer can't keep a constant 60fps.

    You should be using 'void FixedUpdate()' to do any physics-based API calls like applying forces to rigidbodies. FixedUpdate runs at a near-fixed time interval and correctly applies forces across frames. You can set FixedUpdate to run at whatever interval you think is appropriate. I find for super-accurate physics, it is best to run at 200 FixedUpdate FPS (you can set this in TimeManager settings with the Fixed Timestamp parameter), but you can also set this lower so it runs below screen refresh (say 30FPS).

    Also you should generally multiply time-dependent calculations/forces by Time.deltaTime (for stuff in Update) and Time.fixedDeltaTime (for stuff in FixedUpdate) to make your code framerate independent. This also prevents glitches due to some frames taking longer than others (no game runs perfect 60fps even with vsync on).

    ccs
    August 3, 2014
    This has probably changed with 0.4.0 SDK and the new direct rendering mode, but I wanted to point out and confirm that Unity fixed (most of) the DX11 latency issues starting with build 4.5.2p2 here:

    http://forum.unity3d.com/threads/unity-patch-releases.246198/#post-1711628

    (none) : Windows Player: Performance improvements including lower latency in DirectX 11 mode.

    I confirmed the earlier workaround I posted (forcing max queued frames to 1 in driver) is no longer needed. DX11 still seems to have slightly higher latency than DX9, but it is now usable with vsync on as long as prediction is set around 40-50ms.

    Just got my DK2 in, so I'll be moving on to 0.4.0 and see how DX11 is working with the new setup.

    ccs
    Up and Coming
    August 5, 2014
    "ccs" wrote:
    If your game changes physics behavior based on frame rate, you are doing something wrong in your code.


    Yes, indeed I was... and I have since updated my code (about a month ago) but I appreciate your helpful advice on this!
    CurtisAuthor
    Up and Coming
    August 5, 2014
    "ccs" wrote:
    This has probably changed with 0.4.0 SDK and the new direct rendering mode, but I wanted to point out and confirm that Unity fixed (most of) the DX11 latency issues starting with build 4.5.2p2 here:

    http://forum.unity3d.com/threads/unity-patch-releases.246198/#post-1711628

    (none) : Windows Player: Performance improvements including lower latency in DirectX 11 mode.

    I confirmed the earlier workaround I posted (forcing max queued frames to 1 in driver) is no longer needed. DX11 still seems to have slightly higher latency than DX9, but it is now usable with vsync on as long as prediction is set around 40-50ms.

    Just got my DK2 in, so I'll be moving on to 0.4.0 and see how DX11 is working with the new setup.

    ccs


    That's great news! The bad news is that the new SDK isn't compatible with DX11. Hopefully that will be fixed in the next SDK update
    August 5, 2014
    I have been able to get DX11 to work with 0.4.0, and I'm happy to report lag is completely gone! Tracking is perfect now with my DX11 Unity project.

    Here is the formula I have found that works:

    1. IMPORTANT! turn vsync off in Unity quality settings - direct rift mode will take of this for you - if you have it on it will cap you at 60fps, not 75fps and give you terrible results (edit: for me the project actually crashes on start if vsync was on in quality settings)
    2. on the OVRCameraController, uncheck the Time Warp button - i found it sometimes causes juddering and the tracking seems way better with if off!
    3. set Rift display mode to direct HMD access in the Oculus configuration tool
    4. build & run your project (immediately exit your project when it starts)
    5. make sure the oculus configuration tool is closed (camera light should be off)
    6. go to your project folder and run the DirectToRift.exe for your project
    7. if it crashes - just run it again - it should start on 2nd try
    8. if you notice screen tearing or juddering, make sure to exit Unity before running your project
    9. if you still notice screen tearing, in the oculus configuration tool, select Tools->Advanced->Restart Service...
    10. if you still notice screen tearing, reboot your computer - don't open unity or configuration tool - just try running your project right away)

    Obviously Oculus still needs to work out some kinks because you don't get tear-free experience every time, but when it does work, it is really quite amazing.
    CurtisAuthor
    Up and Coming
    August 5, 2014
    "ccs" wrote:
    I have been able to get DX11 to work with 0.4.0, and I'm happy to report lag is completely gone! Tracking is perfect now with my DX11 Unity project.

    Here is the formula I have found that works:

    1. IMPORTANT! turn vsync off in Unity quality settings - direct rift mode will take of this for you - if you have it on it will cap you at 60fps, not 75fps and give you terrible results (edit: for me the project actually crashes on start if vsync was on in quality settings)
    2. on the OVRCameraController, uncheck the Time Warp button - i found it sometimes causes juddering and the tracking seems way better with if off!
    3. set Rift display mode to direct HMD access in the Oculus configuration tool
    4. build & run your project (immediately exit your project when it starts)
    5. make sure the oculus configuration tool is closed (camera light should be off)
    6. go to your project folder and run the DirectToRift.exe for your project
    7. if it crashes - just run it again - it should start on 2nd try
    8. if you notice screen tearing or juddering, make sure to exit Unity before running your project
    9. if you still notice screen tearing, in the oculus configuration tool, select Tools->Advanced->Restart Service...
    10. if you still notice screen tearing, reboot your computer - don't open unity or configuration tool - just try running your project right away)

    Obviously Oculus still needs to work out some kinks because you don't get tear-free experience every time, but when it does work, it is really quite amazing.



    Ah, ok I got it working now, thanks for the tips! Head tracking is still pretty weird in the editor, but seems to work just fine when I build. I haven't tested it with any heavy duty scenes yet, but it seems pretty good!
    Up and Coming
    September 16, 2014
    Seems they didn't make too much progress. Unity demos have generally more lag then UE4 demos, it's really perceivable. Just compare - say - Oculus Tuscany (add 'force-d3d11' to avoid tearing) with UE4 Coaster or Valerie Controls / Mobile Temple. Must be more than 50 ms difference or so.

    spyro
    Up and Coming
    September 17, 2014
    "ccs" wrote:
    I have been able to get DX11 to work with 0.4.0, and I'm happy to report lag is completely gone! Tracking is perfect now with my DX11 Unity project.

    Here is the formula I have found that works:

    1. IMPORTANT! turn vsync off in Unity quality settings - direct rift mode will take of this for you - if you have it on it will cap you at 60fps, not 75fps and give you terrible results (edit: for me the project actually crashes on start if vsync was on in quality settings)
    2. on the OVRCameraController, uncheck the Time Warp button - i found it sometimes causes juddering and the tracking seems way better with if off!
    3. set Rift display mode to direct HMD access in the Oculus configuration tool
    4. build & run your project (immediately exit your project when it starts)
    5. make sure the oculus configuration tool is closed (camera light should be off)
    6. go to your project folder and run the DirectToRift.exe for your project
    7. if it crashes - just run it again - it should start on 2nd try
    8. if you notice screen tearing or juddering, make sure to exit Unity before running your project
    9. if you still notice screen tearing, in the oculus configuration tool, select Tools->Advanced->Restart Service...
    10. if you still notice screen tearing, reboot your computer - don't open unity or configuration tool - just try running your project right away)

    Obviously Oculus still needs to work out some kinks because you don't get tear-free experience every time, but when it does work, it is really quite amazing.


    Wish I'd seen this a week ago! Came to the exact same conclusion independently after a bunch of testing. No VSync. No Time Warp. I kill prediction too.
    Cubicle Ninjas Custom VR App Development Guided Meditation VR for Rift, Gear, and Go