Skip to main content
Up and Coming
May 11, 2014

Strange effect using Sdk 0.3.1

Hi All,

I've been writing some code interfacing a .NET application with the new Rift 0.3.1 code. But it's producing some strange effects.

I'm using the SDK rendering (a texture per eye) and although I get something showing up when I render, the are pushed out to the side. The cube is rendered dead centre of the texture but comes out like the picture below.

edit

Just to say that this is using OpenGL with OpenTK driving the GL on the .NET side.

The Setup follows the examples as far as I can see.
		
eyes[0].Eye = ovrEye_Left;
eyes[1].Eye = ovrEye_Right;
eyes[0].Fov = hmdDesc.DefaultEyeFov[0];
eyes[1].Fov = hmdDesc.DefaultEyeFov[1];
eyes[0].TextureSize = renderTargetSize;
eyes[1].TextureSize = renderTargetSize;
eyes[0].RenderViewport.Pos = Vector2i(0,0);
eyes[0].RenderViewport.Size = Sizei(renderTargetSize.w, renderTargetSize.h);
eyes[1].RenderViewport.Pos = Vector2i(0,0);
eyes[1].RenderViewport.Size = Sizei(renderTargetSize.w , renderTargetSize.h);

eyeRenderDesc[0] = ovrHmd_GetRenderDesc(hmd, eyes[0]);
eyeRenderDesc[1] = ovrHmd_GetRenderDesc(hmd, eyes[1]);

Cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
Cfg.OGL.Header.Multisample = 0;
Cfg.OGL.Header.RTSize.w = hmdDesc.Resolution.w;
Cfg.OGL.Header.RTSize.h = hmdDesc.Resolution.h;
Cfg.OGL.WglContext = wglGetCurrentContext();
Cfg.OGL.Window = HWND(hwnd);
Cfg.OGL.GdiDc = wglGetCurrentDC();

int l_RenderCaps = 0;
int l_DistortionCaps = ovrDistortion_Chromatic | ovrDistortion_TimeWarp;

ovrHmd_ConfigureRendering(hmd, &Cfg.Config, l_RenderCaps, l_DistortionCaps, eyes, eyeRenderDesc);

EyeTexture[0].OGL.Header.API = ovrRenderAPI_OpenGL;
EyeTexture[0].OGL.Header.TextureSize.w = renderTargetSize.w;
EyeTexture[0].OGL.Header.TextureSize.h = renderTargetSize.h;
EyeTexture[0].OGL.Header.RenderViewport = eyes[0].RenderViewport;
EyeTexture[0].OGL.TexId = tid1;

EyeTexture[1].OGL.Header.API = ovrRenderAPI_OpenGL;
EyeTexture[1].OGL.Header.TextureSize.w = renderTargetSize.w;
EyeTexture[1].OGL.Header.TextureSize.h = renderTargetSize.h;
EyeTexture[1].OGL.Header.RenderViewport = eyes[1].RenderViewport;
EyeTexture[1].OGL.TexId = tid2;




NOTE:
Also using the SDK rendering seems to screw up OpenGL state something awful. My VBOs are stomped on and I need to re-upload the data each frame. :(

Any ideas?

    24 replies

    TeraBitAuthor
    Up and Coming
    May 12, 2014
    Well I eventually got it to look about right by changing the viewport position configuration from (0,0) to (-268,0) & (268,0)

    eyes[0].RenderViewport.Pos = Vector2i(-268,0);
    eyes[0].RenderViewport.Size = Sizei(renderTargetSize.w, renderTargetSize.h);
    eyes[1].RenderViewport.Pos = Vector2i(268,0);
    eyes[1].RenderViewport.Size = Sizei(renderTargetSize.w, renderTargetSize.h);

    I don't know why it works or what's going on, but has anyone else done this with two separate textures as opposed to one big one with two viewports on it?
    Regards, Lee Page TeraBit Software
    Up and Coming
    May 12, 2014
    I haven't tried two textures.
    Buy maybe you could use this example, modify it for two textures and see if there are any surprises.
    Thanks,
    Daniel
    TeraBitAuthor
    Up and Coming
    May 12, 2014
    "DoZo1971" wrote:
    I haven't tried two textures.
    Buy maybe you could use this example, modify it for two textures and see if there are any surprises.
    Thanks,
    Daniel


    Thanks. I followed that example mostly in the setup of my own initial scene. I think I try converting my own one to a single texture and see what happens. :)
    Regards, Lee Page TeraBit Software
    TeraBitAuthor
    Up and Coming
    May 13, 2014
    Also,

    Timewarp is eating all my CPU... If I add

    int l_DistortionCaps = ovrDistortion_Chromatic | ovrDistortion_TimeWarp;

    rather than:

    int l_DistortionCaps = ovrDistortion_Chromatic;

    I use 100% of a CPU at 120 FPS instead of 1% without it. :?

    But curiously only cuts about 100 fps without Vsync (860 -> 760).
    Regards, Lee Page TeraBit Software
    Inspiring
    May 13, 2014
    I think there is a waiting period to sync up with the refresh rate or something. So it may be hitting 100% CPU but most of that is probably idle time used for synchronization.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    TeraBitAuthor
    Up and Coming
    May 13, 2014
    "cybereality" wrote:
    I think there is a waiting period to sync up with the refresh rate or something. So it may be hitting 100% CPU but most of that is probably idle time used for synchronization.


    If it's just spinning, I don't think it would be using 100% CPU. VSync does something similar (and sometimes I have emulated it on systems that don't have Vsync), it just releases time to be used elsewhere.

    Either something is wrong with it, or it is doing something useful until the last second.

    Here's the results at different FPS:
    TimeWarp vs Non-TimeWarp
    30 FPS = 6% vs 0.4%
    60 FPS = 12% vs 0.6%
    120 FPS = 13.37% vs 0.94%

    BTW: This happens if I just have the BeginFrame and EndFrame without rendering the eyes.
    Regards, Lee Page TeraBit Software
    Up and Coming
    May 14, 2014
    I experience the same effect with my application taking a full core with Timewarp and VSync On. With Timewarp off, it takes only 10-12% of a core. With VSync off there's practically no difference in FPS. And that's without an actual Rift plugged in.

    In a normal game I guess this isn't really an issue as it will hog your CPU anyway but for some cases (like Virtual Desktop) I want to be minimizing the CPU usage as much as possible.

    Good find terabit!
    Virtual Desktop Developer
    Inspiring
    May 14, 2014
    I might be mistaken, I haven't really dug too deep into the code.

    Let me see what I can find out.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    May 14, 2014
    Since I tested this without a Rift, this means I used ovrHmd_CreateDebug() to create my HMD. How about you TeraBit, was this with an actual rift or a debug hmd?
    Virtual Desktop Developer
    TeraBitAuthor
    Up and Coming
    May 14, 2014
    "guygodin" wrote:
    Since I tested this without a Rift, this means I used ovrHmd_CreateDebug() to create my HMD. How about you TeraBit, was this with an actual rift or a debug hmd?


    This is with a DK1.

    The Oculus World Demo that comes with 0.3.1 also eats almost all CPU at 60 FPS, but drops from 12% to 7% if you turn off timewarp (O Key).
    Regards, Lee Page TeraBit Software