pouët.net

Advice on learning DirectX/3D graphics programming

category: code [glöplog]
Hi,

as Revision draws near and my first ever entry is about to be finished, it's time to plan ahead what to do next. I had chosen an retro platform (Atari 2600) for my first prod because its unique and weird architecture was very intriguing, but also because it's not too complex and was quickly to learn with the tiny amount of spare time I have.

But now I'd really like to have more freedom of expression than essentially being limited to oldskool effects, so I'm toying with the idea of learning how to code PC demos next. However, I'm having a hard time to assess the amount of learning time involved until I'm at a level where I can enter a competition without being ashamed too much of my prod. Smash's opinion that demos should employ the latest-and-greatest tech and hardware or why bother, and people waving current research papers at each other are not very encouraging in that regard. ;-)

Unlike others, my day job has nothing to do with (3D) graphics programming (I'm an ICS security researcher). I know C/C++ and Windows internals, but have no knowledge yet about the math or APIs involved in 3D programming. I'm a good learner, but don't have much spare time. So maybe you could help me with some questions so I can assess for myself if it's worth trying or not.


1) I'd like to use DirectX. My instincts tell me to start learning the latest version. Would that be best, or should I begin with older versions because the latest is too overwhelming for a beginner?


2) I read in a review of Frank Luna's book on DirectX 11 that Microsoft has deprecated D3DX11, which looks like to offer a lot of convenience functions and is used in many books and tutorials. Should I ignore D3DX11 and focus only on DX11, because otherwise I'd have to "unlearn" too much later? Or can I use D3DX11 (with an older version of DirectX?) and later replace its functionality easily once I've grasped the basics?


3) I'd love to learn the basics by using a textbook, not (only) by tutorials, API docs or code examples. At first, Frank Luna's book looked perfect, until I read that he relies on D3DX11. Would that be a problem, and can someone recommend other books?


4) Any other tips on what to read, which forums to join, what else to do or whether I should better go for another oldskool platform instead? ;-)


This is all a bit confusing, so I'd appreciate some hints. Thanks in advance!
added on the 2014-03-19 11:35:10 by Kylearan Kylearan
If you want to learn D3D, the DX SDK is always the best place to start; the samples themselves are well-written and easily readable.

Not sure what to recommend as reading as far as 3D graphics programming goes though.
added on the 2014-03-19 11:37:35 by Gargaj Gargaj
Quote:
2) I read in a review of Frank Luna's book on DirectX 11 that Microsoft has deprecated D3DX11, which looks like to offer a lot of convenience functions and is used in many books and tutorials. Should I ignore D3DX11 and focus only on DX11, because otherwise I'd have to "unlearn" too much later? Or can I use D3DX11 (with an older version of DirectX?) and later replace its functionality easily once I've grasped the basics?


If you want to use D3D11, I suggest that you skip D3DX altogether. That way you can use the same D3D11 code on Windows tablets and phones as well (where D3DX is not available).
There are a number of replacements for the D3DX functionality:
- D3DCompiler
- DirectXTK
- DirectMath

If you start with those right away, you won't have to remove the legacy D3DX crud from your code later, as I had to do.
I wrote a blog about it, might contain useful links and info about D3DX and the newer alternatives: http://scalibq.wordpress.com/2013/04/23/just-keeping-it-metro/
added on the 2014-03-19 11:51:26 by Scali Scali
I started from nowhere with the great NeHe tutorials :)
added on the 2014-03-19 12:18:38 by rez rez
(ho, and it's purely OpenGL btw).
added on the 2014-03-19 12:19:16 by rez rez
NeHe tutorials are fifteen years out of date. Steer clear.
added on the 2014-03-19 12:24:02 by Preacher Preacher
Yeah, NeHe is quite old. I like this site pretty much - it also got quite current tutorials: http://ogldev.atspace.co.uk/

Okay, that's still OpenGL =p
added on the 2014-03-19 12:58:06 by neoman neoman
I successfully migrated from DirectX9 to DirectX11 thanks to these tutorials: http://www.rastertek.com/tutdx11.html
added on the 2014-03-19 13:50:14 by xTr1m xTr1m
Shameless plug: My NVScene talk will present some tips on how to simplify tedious DX11 stuff like management of API objects etc.
Also:
Keep your framework simple, don't write super-general management code:
You can get very far with keeping things to a minimum:
- just use a single vertex layout
- don't expose all the DX11 objects to your demo code, just create the state objects you really need (a handful of blending, culling, depth and sampler states) and make them easily accesible by your framework
- constant buffer objects can be completely hidden behind a custom "map/unmap"-style API
- Loading DDS/TGA/BMP files yourself is just a few lines of code
- using the standalone fxc shader compiler can also be an option, no need for runtime compilation via D3DCompiler
- ...
added on the 2014-03-19 15:16:26 by arm1n arm1n
Quote:
- using the standalone fxc shader compiler can also be an option, no need for runtime compilation via D3DCompiler


Microsoft actually wanted to enforce this on mobile devices: the compiler is not available at all. VS2012 allows you to easily compile shaders as part of your project, and link them to your app.
However, I believe Windows Phone 8.1 will ship with a compiler again.
added on the 2014-03-19 15:35:08 by Scali Scali
Thanks Scali, the section on D3DX and alternatives in your blog post helped to clarify some things for me. I guess I can use books like Frank Luna's then who still use D3DX, as long as I convert these parts of the code to the newer alternatives. That shouldn't invalidate the basic principles or confuse a beginner like me too much.

Actually I found another book, "Real-Time 3D Rendering with DirectX and Hlsl: A Practical Guide to Graphics Programming" by Paul Varcholik, which looks like an interesting alternative, although it's not published yet (it will come out end of May). It's hard to judge how far I'll still be away from being able to code a proper demo after going through these books and/or tutorials, but I guess I'll try and see.

I'm determined to use DirectX and not OpenGL, but thanks anyway for the links others have posted.
added on the 2014-03-19 15:49:30 by Kylearan Kylearan
Quote:
Microsoft actually wanted to enforce this on mobile devices: the compiler is not available at all. VS2012 allows you to easily compile shaders as part of your project, and link them to your app.
However, I believe Windows Phone 8.1 will ship with a compiler again.


Same for desktop, actually. In Win8 they didn't ship the compiler and actively prohibited Metro apps from using it; in Win8.1 they reversed that decision and now there's a d3dcompiler_47.dll bundled with the OS \o/
added on the 2014-03-19 19:16:05 by kb_ kb_
May I ask exactly why you're so insistent that it HAS to be DirectX, and not OpenGL? If you don't know DirectX, how do you know that that is the one to learn? Doesn't Windoze strike you as pretty shitty? (I haven't used any version since XP at any length myself). Since you're not dependent on Win for your livelihood, you can surely pick and choose what platform you choose to do your demos on, right? :)

Thank God somebody made that post on Linux tuts despite what you said, I'd go there if I were you. And of course, now with Steam on Linux, you'd hardly be the sole torch-bearer :)
Quote:
Doesn't Windoze strike you as pretty shitty? (I haven't used any version since XP at any length myself).

I hope you realize this does make you look quite foolish.

And no, Windows does not strike me as shitty. Neither does Linux. I use both on a daily basis, in different versions and for different tasks, both on bare metal and virtualized. And I've seen so many silly platform wars in my lifetime, I have no interest in being dragged into one now.
added on the 2014-03-19 19:59:35 by Kylearan Kylearan
Quote:
you can surely pick and choose what platform you choose to do your demos on, right? :)


Apparently he has.
added on the 2014-03-19 20:44:00 by Scali Scali
Quote:
you can surely pick and choose what platform you choose to do your demos on, right? :)


Yeah, feel free to choose whatever platform you want, as long as it's not windoze, herp derp.
added on the 2014-03-19 21:21:08 by xTr1m xTr1m
Quote:
NeHe tutorials are fifteen years out of date. Steer clear.


People have a right to use what they want. Don't they?
added on the 2014-03-20 08:44:09 by mudlord mudlord
Especially when fifteen years old technology like display lists still are top-notch performance-wise.
added on the 2014-03-20 09:18:53 by arm1n arm1n
actually, GL display lists are much much older than that :)
added on the 2014-03-20 09:19:28 by arm1n arm1n
Quote:
Quote:
NeHe tutorials are fifteen years out of date. Steer clear.


People have a right to use what they want. Don't they?


I had already written in my first post that my instincts tell me to learn the latest version of an API, in my case DirectX. So Preacher's warning is appreciated (and does not infringe upon my right to choose what to use whatsoever ;) ).
added on the 2014-03-20 09:32:08 by Kylearan Kylearan
If you really want to learn the *latest* version of DirectX, it might make sense to wait another two days :)
added on the 2014-03-20 09:40:08 by KeyJ KeyJ
don't worship false idols.

the exact version of API you use is irrelevant. the same holds true for programming language, platform, etc.

just do awesome stuff.

how much time do you have per week for demo coding?
does it really make sense to spend 6-12 months upfront on complex engine tech?
just keep in mind that smash did professional graphics coding for sony computer entertainment as a day job, for example..
added on the 2014-03-20 09:45:56 by arm1n arm1n
Quote:
People have a right to use what they want. Don't they?

Sure, and people also have a right to offer actual good advice.
added on the 2014-03-20 09:59:38 by gloom gloom
Going with the very latest API is a good idea in some ways, but think it through first.

For me (doing iPhone dev as a living) that would mean OpenGL ES 3 (well, 3.1 perhaps). Which would be great, and I'd be nicely future proof. On the other hand, there are no devices that support 3.1, and probably 90% of devices only support 2.0, so short term I'd be pretty much fucked.

That may or may not be relevant to what you want to do, but if it is have a good look at the versions :) (And yeah, DX12 announcement is due any time now, your DX11 plan is going to be obsolete fast :D)
added on the 2014-03-20 10:18:19 by psonice psonice

login