The source code of the 22nd tutorial of the C++ 3D Game Tutorial
Series is now available in early access on GitHub!
This tutorial introduces support for
rendering distance-based fog effect:
FogComponent: Added a new scene-level component managing fog color, start distance, and end distance, with runtime getters/setters. It is initialized during game startup and registered in the project.
Renderer & Constant Buffer: Updated WorldRenderer and EnvironmentData to extract and pack fog data with matching C++/HLSL alignment and padding.
Shader Integration: Added FogData and ComputeFogColor to calculate distance-based fog attenuation and blend it with the scene color. Fog is now applied consistently to material, terrain, and water shaders.
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!