Skip to main content
Inspiring
November 18, 2015

Free DX 12 Rift Engine Code

Hi,

if you want to write code for the Rift using DirectX 12 you might want to take
a look at the code I provided on GitHub https://github.com/ClemensX/ShadedPath12.git

The sample engine is extremely limited on draw abilities: I can only draw lines!
But it may serve as a learning playground for DirectX 12 and Rift programming.

I find it fascinating how a bunch of simple lines suddenly become great if you can walk around them and view them from any direction when you wear the Rift!

The current state of the code is a first step to porting my older DX 11 engine to DX 12.
If you want you are allowed to use any code you like in your own projects.

I want to express gratitude to galopin, who came up with a detailed 8-step guide on how to combine
DirectX 12 with Oculus SDK rendering. See this thread https://forums.oculus.com/viewtopic.php?f=20&t=25900
When I found out that using oculus API ovr_CreateSwapTextureSetD3D11 on a
D3D11On12Device throws NullPointerExceptions I would have given up if he had not given this advice!

Some features of the code example:

  • Engine / Sample separation. Look at Sample1.cpp to see what you can currently do with this engine and see how it is done.

  • Oculus Rift support (head tracking and rendering). See vr.cpp

  • Post Effect Shader: Copy rendered frame to texture - Rift support is built on top of this feature

  • Use Threads to update GPU data. See LinesEffect::update()

  • Synchronize GPU and CPU via Fences

  • Free float camera - use WASD or arrow keys to navigate. Or just walk/turn/duck if you wear the Rift


Any feedback welcome.

    56 replies

    Participant
    April 19, 2017

    lamour42 said:
    Do your touch controllers work fine in other apps like Oculus Home?
    If yes please post the application log. Either directly from Visual Studio Output window if you run a debug build. If you run a release build you will find the file xapp_run.log somewhere inside your installation.



    Touch controllers works fine in other apps (for example in "Oculus World Demo" and etc.). Oculus full calibrated. Hands are visible. From xapp_run.log ('+' for you):
    xapp registered: Avatar
    xapp registered: HangOn
    xapp registered: HangOnFull
    xapp registered: Logo
    xapp registered: MassTest
    xapp registered: ObjectViewer
    xapp registered: Sample1
    xapp registered: Soundtest
    xapp registered: TestDotcross
    xapp registered: TestLinetext
    xapp registered: TestTextures
    xapp registered: TouchOdyssey
    |vr|
    |app=Sample1|
    |w=1200|
    |h=676|
    |disableLineShadersX|
    ++++ 1200
    isFullscreen: 0
    ovrRendering: 1
    LibOVR initialized ok!
    Oculus Boundary system activated!! pak file entry: default.dds
     pak file entry: vac_03.dds
     pak file entry: metal1.dds
     pak file entry: dirt6_markings.dds
     pak file entry: grassdirt8.dds
     pak file entry: mars_6k_color.dds
     pak file entry: vac_00.dds
     pak file entry: vac_01.dds
     pak file entry: vac_02.dds
     pak file entry: vac_04.dds
     pak file entry: vac_05.dds
     pak file entry: vac_06.dds
     pak file entry: vac_07.dds
     pak file entry: vac_08.dds
     pak file entry: vac_09.dds
     pak file entry: 2create_brick_0001.dds
     pak file entry: vac_10.dds
     pak file entry: vac_11.dds
     pak file entry: met1.dds
     pak file entry: white.dds
    PostEffect init for 3 frames called


    lamour42Author
    Inspiring
    April 21, 2017
    Thanks, but that is not from a run of the 'TouchOdyssey' sample. In that case it should contain a line like this:

    |app=TouchOdyssey|

    Could you maybe delete all xapp_run.log files you find and try again? The log file is only written if you run a release build. It should be easier to just run a debug build and look at the VisualStudio Output Window. As I just reinstalled a test version and confirmed it works for me I assume I made some error if another user is running this. It would be really helpful if you could help me finding the error. Thanks!
    Participant
    April 21, 2017
    I'm very glad that I can help you. I decided that it's too early for me to switch to DirectX12 and I'll start with the 11th version. I brought to home glasses and sensors to do it on the weekend. The truth is that tomorrow we should go to the clinic with the childrens :( >:) . And when I have an free time I'll try to check your example. I bought a laptop about I wrote. Best regards.
    lamour42Author
    Inspiring
    April 23, 2017
    I found the error. Thanks for helping me out!

    Unfortunately it has to do with using the Avatar and Platform SDK. As your Oculus user is not registered to be part of this apps test users you cannot use these APIs properly. 

    I will need some time to find a workaround...
    lamour42Author
    Inspiring
    April 23, 2017
    Ok, was easier than I thought: What I didn't know you actually don't need a proper Platform SDK initialization if you only want to use your own Avatar. Now your avatar assets including hands and touch controller models will be downloaded and used regardless of Plaform SDK initialization.

    Already fixed in branch new-object-rendering. Will integerate with master branch after some testing...
    Participant
    April 23, 2017
    I unfortunately could not check your code at home. For some reason the sensors did not work - how many did not try. I do not understand what happened to them.
    Participant
    April 24, 2017
    I figured out my problem with the RIFT sensors. It was exactly the same as it was there. It turned out that there was not enough power on the laptop USB bus and I connect sensors and HMD through the USB hub. I downloaded your code and tomorrow I can check it. Thank you for your work. Please tell me is much differs code DirectX 11 from the code DirectX 12? If someone showed me an example of the code of work on DirectX 11 in Oculus Touch, then I would be just happy!
    Participant
    April 25, 2017
    lamour42 said:
    ...
    Already fixed in branch new-object-rendering. Will integerate with master branch after some testing...
    lamour42 - branch 'new-object-rendering' can not be compiled since contains an error (no header file). This error you had before. But I thought that you will correct it this time. But no. Need a header files - CompiledShaders/MObjectVS.h and CompiledShaders/MObjectPS.h . Maybe they stayed on your computer. In folder: "D:\msvc\dev\repos\SP12\OVRPlatformSDK\Include" for example. May be. I don't know. But I know that I can not check your code. Thank you very much for your work. If you were allowed to check up to the end of your great work, then I would be happy.
    lamour42Author
    Inspiring
    April 25, 2017
    The files are in the repo, but I did not update the VisualStudio project files. I now committed a new version of ShadedPath12.vcxproj and its filters file. You may have to merge if you changed some of the options. (Like manually adding or changing the path to the Platform SDK include folder.)

    Thanks again for helping!
    Participant
    April 25, 2017

    lamour42 said:

    ... I now committed a new version of ShadedPath12
    ...


    Nice music.... :) Now it is being compiled. Runs. I just ran it - I pressed "Run"(both in "Debug" and "Release") and that's it. Maybe there some additional options were needed? Displays meteorites on the Monitor Screen with music. But in the Oculus Headset Monitor shows a "house with a hearth" (Oculus Home Application) and hands (!).