Skip to content

DDreher/DX11Sandbox

Repository files navigation

DirectX 11 Sandbox

A small collection of DirectX 11 projects I built while learning the API.

Disclaimer

"A person who never made a mistake never tried anything new." -- Albert Einstein (or maybe Theodore Roosevelt, Matt Bellamy or even your cat. It's not so clear.)

The code inside this repository was only written for learning purposes. I never really tried to make it beautiful, easy to read, performant or 100% correct. In the end, all I wanted to do is to explore the API. Now I share my code so other people doing the same may be inspired by my journey.

Tl;dr: I know the code's dirty ;) Don't judge me.

How to build (Win64)

  1. Install a Windows SDK if you haven't already (OS: Windows 8 or higher).
  2. Run GenerateProjectFiles.bat.
  3. Open the generated DX11Sandbox.sln with VS2022.
  4. Build and run the desired project the desired configuration (Debug / DebugRender / Release)

Subprojects

Image of Subproject: 01-HelloTriangle

Explored topics:

  • Setting up a bare minimum render pipeline
  • Write, load and compile bare minimum shaders
  • Draw a colored triangle

Image of Subproject: 02-TexturedCube

Explored topics:

  • Rendering of meshes from in-memory data
  • Usage of constant buffers
  • Texture bindings
  • Different blend states and their complications (e.g. transparency)

Image of Subproject: 03-Mesh

Explored topics:

  • Loading of meshes from files using Assimp
  • Revisited quaternions to calculate mesh transforms
  • Further abstractions of graphics resources (shaders, textures, buffers, materials,...)

ChunkyKnight_tint.mp4

Explored topics:

  • Setting up material parameters via shader reflection (input layouts, cbuffers, resource bindings,...)
  • Exposing an API to change material parameters during runtime
  • Rendering a simple UI with Imgui

Image of Subproject: 05-Models

Explored topics:

  • Import of glTF models using Assimp (using Sponza as showcase)
  • Building a scene graph
  • Using resource pools with handles instead of smart pointers
  • Introduction of render queues - one for opaque materials, one for transparent materials
  • Introduction of render work items as foundation for draw call batching
  • Building shader permutations with macros (e.g. for alpha cutoff depending on material configuration)
  • Movable camera (FPS style, WASD to move, hold right mouse button to change camera direction)

Image of Subproject: 06-Lighting

Explored topics:

  • (Blinn-)Phong reflection model
  • Directional lights
  • Spot lights
  • Point lights

Image of Subproject: 07-NormalMapping

Explored topics:

  • Normal Mapping
  • TBN Matrices
  • Fixing tangents on models with mirrored UVs
  • Automatically generating mip maps during run-time

Image of Subproject: 08-ShadowMapping Image of Subproject: 08-ShadowMapping, Debug Visualization of Cascades

Explored topics:

  • Basic shadow mapping for directional lights, spot lights and point lights
  • Fitting view frustums to scene
  • Percentage Closer Filtering (PCF)
  • Cascaded Shadow Maps (CSM)
  • Stabilized CSM with Texel Snapping

Dependencies

Acknowledgments

Learning Resources