The code for all of these examples can be found on my GitHub public repository, at https://github.com/ericrrichards/dx11.
To compile and run the examples, you will need Visual Studio 2012. I have the Professional edition, but I would imagine that you should be able to use the C# Express edition as well. You will also need SlimDX, which is available either through NuGet, or from http://slimdx.org/, as well as the DirectX SDK, which can be obtained at http://www.microsoft.com/en-us/download/details.aspx?id=6812. If you are running Windows 8 or greater, DirectX is now included in the Windows SDK, so you will want to grab that for the most updated version of DirectX, at http://msdn.microsoft.com/en-US/windows/desktop/hh852363.
Some of the examples use Assimp.Net to load 3D models. You can download this from Google Code at https://code.google.com/p/assimp-net/.
If you find these tutorials helpful, please consider donating a couple bucks. While my primary goal with this site is simply learning new things and sharing that knowledge with others, I do put a lot of time and energy into these tutorials, and web hosting and domain registration have some costs. Alternatively, you could turn off AdBlock and endure a couple of banner ads...
This comment has been removed by the author.
ReplyDeleteThis is a great resource! How about you write a book like the one you used, only based on C# - I would surely buy it!
ReplyDeleteMy name is Tom. I would buy your book as
ReplyDeletewell. I have a question. In referring to
AssImpModelDemo.cs code I am having an
error. At runtime
Effects.NormalMapFX.SetDirLights(_dirLights);
gives a System.NullReferenceException.
Would you please tell me why? I am running
Windows 8.1 with the Windows8.1 SDK.
I am using Visual Studio Pro 2013.
Any help would be much appreciated.
Thank you,
Tom
Most likely you have an error in the post-build step to compile the HLSX shader code. Often times you'll need to add the directory that fxc lives in to your PATH environmental variable. Check for any warnings messages on build.
ReplyDeleteSorry for the thread necro, but I'm having the same issue, in particular with the TerrainDemo (so far).
DeleteTexturedHills runs just fine.
Win8.1, VS2012. There's a deprecation warning for every compiled shader (fxc path is set, shaders compile).
For additional info:
These lines are all null:
[code]
_view = FX.GetVariableByName("gView").AsMatrix();
_ambientMap = FX.GetVariableByName("gSsaoMap").AsResource();
_viewProjTex = FX.GetVariableByName("gViewProjTex").AsMatrix();
_shadowTransform = FX.GetVariableByName("gShadowTransform").AsMatrix();
_shadowMap = FX.GetVariableByName("gShadowMap").AsResource();
_walkMap = FX.GetVariableByName("gWalkMap").AsResource();
_unwalkableSRV = FX.GetVariableByName("gUnwalkable").AsResource();
[/code]
They do not exist in the Terrain.fx file, yet the common code tries to access them.
Also, when launching the TerrainDemo, after loading the effect files, the following error is printed (does not throw an exception):
"E_INVALIDARG: An invalid paramter was passed to the returning function (-2147024809)"
"E_FAIL: An undetermined error occurred (-2147467259)
-Corey
Hi Corey,
DeleteIt has been quite some time since I wrote that post, so it's highly possible there is some code rot. I may have some time this weekend to look through that code and see if I can reproduce it.
By the way, this blogspot site is pretty much dead, I moved off of Blogger and onto my own custom site this summer. The new site (with all of the same content as this one): http://richardssoftware.net/Home/DirectX11Tutorials
This is Tom again. I converted all the fx
ReplyDeletefiles to fxo using fxc.exe. I then set the
property to copy if newer. I am getting
this error:
An undetermined error occurred. In the
console window I get this...
Loading effects from ... (DIR)
When I click ok I get...
Object reference not set to an instance
of an object.
Am I missing an effect file?
I have already copied all the effect
files over to the FX folder. (eg Sky.fxo)
It originally gave me an error and said
it was missing.
What do you think is the error?
Any help would be much appreciated.
Thank you,
Tom
well done
ReplyDeleteHi,
ReplyDeleteI found a error that was causing trouble. In core.util.cs the static variable_unmanagedStaging is always at least 1024 long and that's not in some projects.
So I had to change :
public static byte[] GetArray(object o) {
var len = Marshal.SizeOf(o);
_unmanagedStaging = new byte[len];
Array.Clear(_unmanagedStaging, 0, _unmanagedStaging.Length);
//if (len >= _unmanagedStaging.Length) {
// _unmanagedStaging = new byte[len];
//}
var ptr = Marshal.AllocHGlobal(len);
Marshal.StructureToPtr(o, ptr, true);
Marshal.Copy(ptr, _unmanagedStaging, 0, len);
Marshal.FreeHGlobal(ptr);
return _unmanagedStaging;
}
Regards,
Michel G
Hi,
ReplyDeleteA change that has to be done for every country that use comma instead of dot.
Every Convert.ToSingle(vals[nn].Trim()) MUST be changed to : Convert.ToSingle(vals[0].Trim(), new CultureInfo("en-US"))
Regard,
Michel G
Thank you !!
ReplyDelete