C++ 3D Game Tutorial Series: 19 | Directional Lighting | Early Access | Source Code on GitHub
The nineteenth tutorial of C++ 3D Game Tutorial Series is finally available in early access on GitHub!
Saturday 1st August 2026

C++ 3D Game Tutorial Series: 19 | Directional Lighting | Source Code on GitHub


 

 

The source code of the 19th tutorial of the C++ 3D Game Tutorial Series is now available in early access on GitHub!

This tutorial introduces a fundamental change to the rendering pipeline by adding directional lighting support.

Here’s a breakdown of the core changes:

Shader & Material Refactoring: The traditional VSMain/PSMain entry points have been replaced by thin wrapper functions VSMain/PSMain) that route through new MaterialVSOut and MaterialPSOut structs. Material shaders now actively populate diffuse, specular, and shininess values, effectively decoupling asset data from core rendering logic.

Lighting & Normal Pipeline: A new DirectionalLightComponent and corresponding HLSL function (ComputePhongDirectionalLight) have been introduced. The engine now correctly parses vertex normals from mesh files, threads them through the vertex shader, and applies them to a dedicated rigidWorld matrix to ensure accurate surface shading and specular highlights.

Renderer & Data Management: The WorldRenderer now manages a dedicated EnvironmentData constant buffer to pass light direction, intensity, and color to the GPU. Camera data has been expanded to include the viewer's world position for accurate vector calculations, and object matrices are cleanly split into affineWorld (position/scale) and rigidWorld (normal transformation).

Scene Overhaul & Animation: The original floor and teapot have been swapped for a brick pedestal and a marble bust model to better showcase the new lighting. A directional light has been added to the scene and is dynamically rotated each frame in onUpdate to demonstrate real-time shading behavior.

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!