Giter Site home page Giter Site logo

justinstenning / direct3d-rendering-cookbook Goto Github PK

View Code? Open in Web Editor NEW
95.0 14.0 27.0 74 MB

Direct3D Rendering Cookbook - companion source code

Home Page: http://spazzarama.com/direct3dbook

License: MIT License

C# 70.42% C++ 2.38% HLSL 27.20%

direct3d-rendering-cookbook's Introduction

Direct3D Rendering Cookbook - companion source code

This repository contains the up-to-date companion source code for my book Direct3D Rendering Cookbook published in January 2014 by Packt Publishing.

Direct3D Rendering Cookbook cover image

Any questions or issues can be posted in the issues

Update 2017-03-27: this repository has been updated to work with SharpDX 3.1.1. You can find the previous version of the source code that is used in the book here.

Build Instructions

To build all projects:

  1. open the relevant solution,
  2. restore NuGet packages (right click solution in solution explorer and select Restore NuGet Packages)
  3. right-click the root node within the Solution Explorer and select Rebuild Solution.

NOTE: If you get an error on Windows 10 and Visual Studio 2015 while trying to create the Direct3D device in debug mode, you may need to enable the DirectX Developer Runtime https://blogs.msdn.microsoft.com/chuckw/2015/08/05/where-is-the-directx-sdk-2015-edition/ or by running the command:

Dism /online /add-capability /capabilityname:Tools.Graphics.DirectX~~~~0.0.1.0

NOTE 2: If for some reason the MeshContentTask build target does not function correctly for you, the compiled assets are available separately from OneDrive, they just need to be copied to the correct build output location. You know if the MeshContentTask is not working when the *.fbx files do not get converted to *.cmo in your build output directory.


  • All desktop recipes (compatible with VS2012, VS2013 and VS2015): .\D3DRendering.sln

  • All Windows Store apps recipes (VS2013 only): .\D3DRendering.vs2013.WinRT.sln

  • D3DCompiler redistributable .\External


Shared projects:

  • Desktop apps

    .\Common\Common.csproj

  • Windows Store apps

    .\Common.WinRT\Common.WinRT.csproj


Chapter 1: Getting Started with Direct3D

  • Building a Direct3D 11 application with C# and SharpDX

    .\Ch01_01EmptyProject\

  • Initializing Direct3D 11.1 device and swap chain

    .\Ch01_02Direct3D11_1\

  • Debugging your Direct3D application

    .\Ch01_03Debugging\



Chapter 2: Rendering with Direct3D

  • Building a simple rendering framework

    .\Common\Common.csproj

  • Rendering primitives

    .\Ch02_01RenderingPrimitives\

  • Adding texture

    .\Ch02_02AddingTexture\


Chapter 3: Rendering Meshes

  • Cube and Sphere

    .\Ch03_01CubeAndSphere\

  • Material and Lighting

    .\Ch03_02MaterialAndLighting\

  • Material and Lighting with cube mapping

    .\Ch03_02WithCubeMapping\

  • Load mesh from file

    .\Ch03_03LoadMesh\


Chapter 4: Animating Meshes with Vertex Skinning

  • Vertex Skinning

    .\Ch04_01VertexSkinning\

  • Bone Animation

    .\Ch04_02Animate\


Chapter 5: Applying Hardware Tessellation

  • Tessellation basics

    .\Ch05_01TessellationPrimitives\

  • Tessellation of a mesh

    .\Ch05_02TessellatedMesh\


Chapter 6: Adding Surface Detail with Normal and Displacement Mapping

  • Displacement Mapping

    .\Ch06_01DisplacementMapping\

    .\Ch06_01DisplacementMapping_TangentSpace\

  • Displacement Decals

    .\Ch06_02DisplacementDecals\


Chapter 7: Performing Image Processing Techniques

  • Image processing (compute shaders)

    .\Ch07_01ImageProcessing\


Chapter 8: Incorporating Physics and Simulations

  • Physics (with BulletSharp)

    .\Ch08_01Physics\

  • Particles (compute shaders with append\consume buffers)

    .\Ch08_02Particles\


Chapter 9: Rendering on Multiple Threads and Deferred Contexts

  • Multithreaded rendering - benchmark

    .\Ch09_01Benchmark\

  • Multithreaded Dynamic Cube Environment Map

    .\Ch09_02DynamicCubeMapping\

  • Multithreaded Dual Paraboloid Environment Mapping

    .\Ch09_03DualParaboloidMapping\


Chapter 10: Implementing Deferred Rendering

  • Deferred rendering

    .\Ch10_01DeferredRendering\

    • NOTE: the textures for the CryTek Sponza scene can be downloaded from the CryTek CryENGINE 3 downloads page or directly here. These should then be placed into the directory: .\Ch10_01DeferredRendering\textures

      The project will also compile and render without these textures


Chapter 11: Integrating Direct3D with XAML and Windows 8.1

  • Direct3D CoreWindow Windows Store app

    .\Ch11_01HelloCoreWindow\

  • Direct3D SwapChainPanel Windows Store app

    .\Ch11_02HelloSwapChainPanel\

  • Loading resources asynchronously

    .\Ch11_03CreatingResourcesAsync\

    • NOTE: If you do not see the model, clean and rebuild the project again. This is because the .cmo file does not yet exist the first time you build. Cleaning and building again will correctly add the model to the Windows Store apps' AppX package.

direct3d-rendering-cookbook's People

Contributors

justinstenning avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

direct3d-rendering-cookbook's Issues

Need Freedom In Learning (Malaysia Chinese)

I am from Malaysia, I recently started to learn about game programming for fun without any commercial purpose, but I could not download and compile your code, I have tried for weeks but still failed, because my country is a bit conservative, there is a constraint of learning imposed on elites by some dictators politician, most of them are from Malay community. We are not allowed to learn, our freedom of learning are limited by them. I am sure this will not happen in a modern country like US. My country is a Islamic country which consist of three major races, Malay, Chinese and Indians. Majority race, Malay always implement a lot of racism policies to bully minority race. Our countries is like Israel, always have a lot of conflict between Yehudi and Islamic. Malay government has controlled all the ISP industries, our media is strictly controlled. A lot of Internet resources are filtered out by government. Very hard to explain to you in just a few words about my condition. Can you burn the whole code including all the dependancies libraries, and the user manual to compile and run the code into a DVD. And then send it to me? May be I can pay you some delivery fees. I really interested in learning you game engine. Just for learning purpose.

Padding and input layout (question)

Hi,

I have a question about the padding in hlsl structs and the corresponding c# structs:
In "Using C# structures with HLSL constant buffers" you describe the importance of padding:
One conclusion: The members must not cross the 16-byte boundary but be padded correctly (either by using explicit memory layout or implicit by addtional members).

But in the sample code:

I am very confused now. Could you please explain, why your sample code works? (no offense just confused)
My guess is that the driver reads the memory as described (without special padding) and inserts padding on GPU-side. But the buffers are created with an exact size... so there must be a "better" explanation.

Thank you very much,

Gitii

(seemingly related to a question on stackoverflow which is essentialy the same)

sample for VS2015 & SharpDX 3.0

Hi, Did you try those sample codes in VS2015 with SharpDX 3.0 ?

I got a lot errors via SharpDX 3.0, even got 2 error via Sharp2.6.3 (Cannot find type System.MarshalByRefObject in module mscorlib.dll)

question about Ch08_02Particles/ParticleRenderer.cs

hi i have questions
there is a line of code
this.ParticlesPerBatch = (int)(maxParticles * 0.0128f);
how did you derived the 0.0128 value?
and what is the "limiter"? i still can't understand it
thanks
peter

How to compile with VS2017 (MeshContentTask.targets)

This is because the MeshContentTask.targets is referring to the wrong VS installation folder.

The following should fix that:

 <UsingTask TaskName="Microsoft.VisualStudio.Graphics.Api.MeshContentTask" AssemblyFile="$(VSInstallDir)\Common7\IDE\Extensions\Microsoft\VsGraphics\Microsoft.VisualStudio.Graphics.Api.dll" />

Need Freedom In Learning (Malaysia Chinese)

I am from Malaysia, I recently started to learn about game programming for fun without any commercial purpose, but I could not download and compile your code, I have tried for weeks but still failed, because my country is a bit conservative, there is a constraint of learning imposed on elites by some dictators politician, most of them are from Malay community. We are not allowed to learn, our freedom of learning are limited by them. I am sure this will not happen in a modern country like US. My country is a Islamic country which consist of three major races, Malay, Chinese and Indians. Majority race, Malay always implement a lot of racism policies to bully minority race. Our countries is like Israel, always have a lot of conflict between Yehudi and Islamic. Malay government has controlled all the ISP industries, our media is strictly controlled. A lot of Internet resources are filtered out by government. Very hard to explain to you in just a few words about my condition. Can you burn the whole code including all the dependancies libraries, and the user manual to compile and run the code into a DVD. And then send it to me? May be I can pay you some delivery fees. I really interested in learning you game engine. Just for learning purpose.

Ch08_02Particles/ParticleRenderer.cs - initialize the initial particles on CPU

Unable to open the Vertex Skinning sample with VS2015

Hi!
Just like in the Title.
I cannot open the Vertex Skinning sample project, the solution is crashing, probably because of the Mesh Targets for visual studio 2013.
When I remove them (the Mesh Render Targets), I can't see my Character on the scene (but the rest is ok). Is there any possibility to open the Vertex Skinning sample with Visual Studio 2015 and without any bugs ?

EDIT: I have found the MeshContentTask files in the Visual Studio 2015's files, then I've added them like in the book, but I still can't see the model (I see only grid).

is possible to offer a very simple SharpDX template for Windows 10 UWP app ?

I'm new in Visual Studio and C# with Xaml

Can you offer a very simple SharpDX template for Windows 10 UWP Xaml app ?

it would be super helpful for someone who like me :)

is possible just put a SwapChainPanel in MainWindow.xaml, and create device in code and using Swap Chain from SwapChainPanel which just be created.

render a solid background color or simple rect in MainWinodw.cs ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.