The source code of the 16th tutorial of the C++ 3D Game Tutorial Series is now available in early access on GitHub!
This tutorial represents a meaningful architectural shift in the engine, moving away from a rigid, hardcoded shader setup toward a more flexible, asset-driven pipeline. At its core, the changes lay the groundwork for a dynamic material and resource system that decouples shader compilation, data binding, and game logic. Here’s how the pieces fit together:
Introduction of a Resource Management Framework: The engine now features a dedicated resource layer (Resource, ResourceManager, and MaterialResource). Instead of baking assets into the engine at compile time, materials can be loaded dynamically at runtime via file paths. The GameContext and GameObject APIs have been updated to expose the ResourceManager, making it seamlessly accessible from game logic and components.
Shader Architecture Reorganization: The old monolithic Basic.hlsl has been deleted and replaced with a modular approach. A new Common.hlsl file defines reusable vertex structures and camera/object constant buffers. The updated Game/Assets/Shaders/Basic.hlsl includes this common header, introduces a MaterialData constant buffer for dynamic properties (like color), and relies on the new system to compile and link it.
Rendering Pipeline Modernization: WorldRenderer has been heavily refactored to support per-object materials. All hardcoded shader compilation and pipeline state creation have been stripped from its constructor. Instead, it now dynamically fetches pipeline states from loaded MaterialResource objects. The rendering context now handles multiple constant buffers simultaneously (setConstantBuffers), cleanly separating object transforms, camera matrices, and material uniforms. The vertex structure has also been simplified, removing static color fields in favor of material-driven shading.
Game Logic & Cleanup: MainGame.cpp has been updated to showcase the new workflow: it loads the basic material, pushes dynamic color data into it, and attaches it to both the floor and the randomly generated cubes. Alongside this, several legacy/unused members (like manual rotation tracking or player state variables) have been pruned from MainGame.h and Player.h to keep the example focused and clean.
Build & Tooling Adjustments: A shadertoolsconfig.json file was added to configure include directories for the shader toolchain, ensuring the new #include directives in the HLSL files resolve correctly during development.
Overall, this tutorial transitions the engine from a
static rendering model into a dynamic, material-driven architecture. By introducing a resource manager and
decoupling shader data from the core renderer, future extensions (like lighting models, texture sampling, or
runtime material swapping) will be significantly easier to implement.
You can find the full source code
on GitHub here: GitHub Link
I hope you enjoy the tutorial, and thank you for all your support!