Wrote some simple SharpdDX tutorials, what do you think?

Started by
11 comments, last by DwarvesH 9 years, 7 months ago

Hello everybody!

I did not find some proper SharpDX tutorials so I started writing a few. I know that SharpDX is basically DirectX, but porting your knowledge from one to the other is not as straightforward and I did have to spend quite a while searching for things in the documentation. I finished tutorial 9 back in December and wanted to write another one, but then I got into physically based BRDF and that is a huge topic so I couldn't finish the 10th one. Sorry that I did not post them before but I needed to clean them up badly and I've been super busy in 2014.

So a few words about the tutorials: they are built on the idea that you take a very simple sample and keep adding small features to it until you have a basic but rich renderer. The code is written for people who like DirectX (i.e. having full control, manually setting device states, sampler states, shader variables, etc.) but at the same time would like to have a full set of features pretty much out of the box. So you will manually fill in buffers and set variables to achieve simple things like rendering a cube, but that cube will be rendered using normal mapping, bloom, AA. etc.

The code is for DirectX 9.

I have the scripts written for the first 10 tutorials, but I did not have time to write the articles for them yet.

The tutorials do a lot of seemingly random shit, but all of them are there to fix some strange behaviors or instabilities. The written articles would contain explanations for those sections.

What is implemented:

- master control for post processing and MSAA

- MSAA and CSAA

- FXAA and SMAA

- bloom

- directional light normal mapping with optional spherical harmonics hack ambient lighting

- good window control and input (screen capture friendly)

What I would like to add in the future:

- DirectX 10 mode

- physically based BRDF

- HDR rendering

- custom resolve for HDR with MSAA (only DirectX 10)

- flexible light composition scheme (almost done)

- depth of field

I hope I'll have time to write the articles and the rest of the tutorials, but until then I'm dropping a link here for anybody who might be interested:

Dependencies (needed only for compiling): http://dl.dropboxusercontent.com/u/45638513/sdx/Dependencies.zip

Media (needed for Tut11+): http://dl.dropboxusercontent.com/u/45638513/sdx/Media.zip

Tut01: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut01.zip

Tut02: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut02.zip

Tut03: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut03.zip

Tut04: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut04.zip

Tut05: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut05.zip

Tut06: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut06.zip

Tut07: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut07.zip

Tut08: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut08.zip

Tut09: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut09.zip

Tut10: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut10.zip

Tut11: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut11.zip

Tut12: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut12.zip

Tut13: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut13.zip

Important note: Tut11 though Tut13 need the contents of Media.zip. All Zip achieves should be unarchived. If you unarchive in foo, you should have foo/Media and foo/TutXX. If you also want to compile, you should have foo/Dependencies.

A few notes:

- you need .Net 4.0 or compatible

- you can find ready to run binaries for each tutorial in the TutXX/TutXX/bin folders (this is why the download is so big)

- the code should be ready to be compiled and run, but running will only work in release mode. For debug mode you need to copy the contents from bin/Release to /bin/Debug. I did not copy it for you in order to keep the download size smaller.

- there may be bugs. Some coding bug or some resulting from my lacking understanding of the topic. In particular bloom may seem kind of blocky in some samples.

If you find any bugs or have any feedback please let me know smile.png.

I'm learning DirectX 10 now for future tutorials. Did not manage to make any meaningful progress here because DXGI is just not cooperating and even without it rendering fullscreen with MSAA is 3-4 time slower than with DirectX 9.

Advertisement

Awesome! You're so right there is a lack of good SharpDX tutorials on the web. These tutorials are great I'd like to see more!

Thanks!

I wrote the 10th one: http://dl.dropboxusercontent.com/u/45638513/sdx/Tut10.zip

It should have the sources and a working exe. If you want to compile it you'll need this too: http://dl.dropboxusercontent.com/u/45638513/sdx/Dependencies.zip

To take control of my running away back log I'll write up the text of the tutorial before I continue!

Now that I remember, I forgot to give the controls for the demo:

  • Mouse buttons: camera control
  • P: Toggle cube rotation
  • Alt-Enter: toggle fullscreen
  • F2: Toggle VSync
  • F3: Cycle MSAA/CSAA
  • F4: Cycle FXAA/SMAA
  • F11: Toggle master post processing override. This way you can force to off the entire post processing framework. Good for debugging.
  • F12: Toggle master AA override. This way you can force to off the entire MSAA/CSAA framework. Good for debugging.
  • T: Toggle debug text.
  • +/-: Adjust bloom threshold
  • O: Toggle bloom debug overlays
  • B: Cycle though bloom modes. Mode 0 is no bloom. Mode 1 is default bloom. The rest of modes are not that useful for realistic rendering.
  • E: Cycle though render modes:
  1. Low
  2. Medium
  3. High: Default
  4. Debug: Ambient spherical harmonics lighting
  5. Debug: Diffuse lighting
  6. Debug: Specular lighting

edit: typo

This is why I don't like releasing stuff until it is 100% done :). I found some CSAA 32x and multithreading bugs. I fixed them and back-ported the fixes to each version.

I also split up the tutorials, each in its own archive to make it easier to edit one. I edited the first post with links.

DirectX 10 is not progressing at all. I'm getting super strange bugs and abysmal fullscreen MSAA performance, so I'll leave it for later.

The next tutorial is going to be on GUI. Unless someone can point me to a good lightweight but powerful GUI system for SharpDX. I couldn't find one. If you know of one please let me know.

Oh, and I should stop calling these tutorials. They are far too complex for that title. It is more like a DIY step-by-step iterative toy engine and shaders for each common rendering task.

I second ta0soft. Great stuff. Hope to see DX10/11 versions some day:) Thanks!

I second ta0soft. Great stuff. Hope to see DX10/11 versions some day:) Thanks!

Thanks! I'll get to that one day.

In the meantime tutorial 13 is in a bit of a hiatus. First I wanted to do it about physically based BRDF, but that subject is far too wide to cover in one go. I could dump in the shaders and be done with it, but that does not seem alright.

So as a next topic I investigated integrating available SSAO shaders with ease in a forward renderer. But since have never done this before, I'm not sure yet if it looks alright, I'll wait.

There are other obstacles too. I started creating a sort of "spiritual coexistor" of Neoforce Controls for XNA (it's too soon to call it a spiritual successor since Neoforce is still around). It is a light weight GUI library for SharpDX that uses roughly the same API and look & feel of Neoforce. It has less features than Neoforce, but the code base is much smaller and maintainable.

I tried getting in contact with the maintainer of Neoforce to see what to do with it. Optimally he'll like the idea and I can open-source it. But if he won't, since it is a fresh implementation, not a port, I can drop the API compatibility and create a new original skin and still open-source it.

Great work!

I signed up here just to reply this.

I'm looking forward to the GUI Tutorials. I just need that!smile.png

Why SharpDX don't have some libs like Neoforce?

SharpDX port of NeoForce controls here...

https://github.com/PlehXP/NeoforceControls-SharpDX

I echo the call for D3D11 versions :)

Speaking of SharpDX UI libraries, I'm also developing a UI library as part of my game. It uses Direct2D and does not rely on any artist resources. Controls are rendered on the fly thanks to Direct2D's capabilities and can be skinned through XML theme files. I've just finished implementing a very primitive DataBinding system so that it is possible to bind property values to ViewModel instances.

If anybody is interested, I could write a short article on how to use the library. Here is the repository. It contains two samples: MiniUI is just a basic UI sample consisting of a panel and a button, while DataBinding shows the databinding features.

Help is welcome, lots of controls needed still!

--Avengers UTD Chronicles - My game development blog

This topic is closed to new replies.

Advertisement