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

    lamour42Author
    Inspiring
    April 25, 2017
    Sounds like you have to reset your run options to something like -vr -app=TouchOdyssey -w=1200 -h=676 to enable VR mode and select the right app.
    Participant
    April 25, 2017
    lamour42 You are God in programming, probably. It seems so to me. Your program (TouchOdyssey) works just like on video. I have newbie questions in such programming - can I ask? I would very much like to do something at the DirectX 11 first. Do you need any logs from running your app and etc? I have never programmed Direct X before. But now I am intensively studying DirectX 11. Can you have any small example on DirectX 11 to just implement (rendering) a simple "managed hand"? Thanks you.
    Participant
    April 25, 2017
    .
    lamour42Author
    Inspiring
    April 29, 2017
    Thanks!

    For DirectX 11 it depends on what kind of examples you want to have:
    • For Oculus examples I would propose the samples in the Oculus SDK. There are a lot of small examples for many different topics of programming for the Rift in DX11.
    • For learning DX 11 in general (not Rift related) I would propose Introduction to 3D Game Programming with DirectX 11 from Frank Luna. I have a number of book on Graphics programming, but the books from Frank Luna always were at the core of my learning.
    • For learning to program with the touch controllers and displaying hands you can have a look at the Mirror sample in the Oculus Avatar SDK. Unfortunately this is no easy example. Setting up a dev / debug environment is a pain. Once you have it running you can learn a lot from it. Practically all my knowledge about Touch programming comes from studying this example, even though it is programmed in OpenGL.
    Participant
    April 30, 2017


    lamour42 said:

    Thanks!

    For DirectX 11 it depends on what kind of examples you want to have:
    • For Oculus examples I would propose the samples in the Oculus SDK. There are a lot of small examples for many different topics of programming for the Rift in DX11.
    • For learning DX 11 in general (not Rift related) I would propose Introduction to 3D Game Programming with DirectX 11 from Frank Luna. I have a number of book on Graphics programming, but the books from Frank Luna always were at the core of my learning.
    • For learning to program with the touch controllers and displaying hands you can have a look at the Mirror sample in the Oculus Avatar SDK. Unfortunately this is no easy example. Setting up a dev / debug environment is a pain. Once you have it running you can learn a lot from it. Practically all my knowledge about Touch programming comes from studying this example, even though it is programmed in OpenGL.


    Yes of course it's all true, but:
    1. I need Avatar SDK (for design with hands);
    2. Thank you for reference. 
    I have not heard about this book yet. It would be necessary to look. I am trained mainly in Microsoft's examples. They are not bad. Even not bad at all.
    3. Oh sure. There (in Avatar) really is an even worse option - the SDL library (wrapper). For compatibility, probably Oculus so did.

    I just thought that you can have something left, from what was written before, under DirectX11. Something very simple for hang (touch) on DirectX11 is enough for me. But you seem to have just started writing under DirectX12. It's too early for me to go to the 12th.... Well, there's something to be done, even if there's something on the 12th version. Are the differences strong between them? How do you think? When I first wrote to you, I did not know much about DirectX (!). I will then deal here myself. Let's see what happens here with me. Thank you.
    lamour42Author
    Inspiring
    May 1, 2017
    Sorry, I do not have DX11 code for Touch. By the time Touch came out I had already moved to DX12. 
    Yes, unfortunately differences between DX12 and DX11 are big. I started out with DX 9 some years ago and migrating to newer Direct3D versions always was a pain, but going from 11 to 12 was by far the biggest challenge.