Demonstration of Depth of Field (DOF) implementation as a post-processing effect in a custom DirectX 9 rendering engine.
- Engine Layer: Modular rendering system with render target management, camera, and resource handling
- Demo Layer: Scene management and DOF effect implementation
- Shader Layer: HLSL pixel shaders for Gaussian blur post-processing
- Multi-pass render-to-texture pipeline
- Separable Gaussian blur (horizontal + vertical passes)
- Split-screen comparison (blurred vs sharp)
- Debug visualization modes
- Scene Pass: Render geometry to off-screen texture
- Horizontal Blur: Apply 5-tap Gaussian blur horizontally
- Vertical Blur: Apply 5-tap Gaussian blur vertically
- Composite: Display split-screen or full-screen result
- 5-tap weighted Gaussian kernel
- Separable implementation for performance
- Configurable blur radius via shader constants
- Visual Studio 2022 or later
- Windows SDK 10.0+
- DirectX SDK (June 2010)
- vcpkg (for WIL library)
quick_build.batcl /EHsc /O2 /std:c++latest ^
/I"D:\tools\vcpkg\installed\x64-windows\include" ^
/I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared" ^
/I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um" ^
/DWIN32 /D_WINDOWS /DUNICODE /D_UNICODE ^
main.cpp engine/*.cpp demo/*.cpp ^
/link ^
"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.26100.0\um\x64\d3d9.lib" ^
"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.26100.0\um\x64\d3dx9.lib" ^
user32.lib gdi32.lib ^
/out:DirectX9_DOF_Demo.exe- F1: Split-screen mode (blur left, sharp right)
- F2: Full-screen blur only
- F3: Full-screen sharp only
- ESC: Exit
├── engine/ # Core rendering engine
│ ├── RendererDX9 # DirectX 9 device management
│ ├── RenderTarget # Render-to-texture wrapper
│ ├── Camera # View/projection matrices
│ └── FullscreenQuad # Post-process quad rendering
├── demo/ # Demo scene implementation
│ └── DemoScene # Scene management and DOF logic
├── shaders/ # HLSL shader files
│ ├── blur_h_ps.hlsl # Horizontal Gaussian blur
│ ├── blur_v_ps.hlsl # Vertical Gaussian blur
│ └── scene_*.hlsl # Scene rendering shaders
└── main.cpp # Application entry point
- Scene RT: A8R8G8B8 with D24S8 depth buffer
- Blur RTs: A8R8G8B8 without depth (post-process only)
- Vertex Shaders: vs_2_0
- Pixel Shaders: ps_2_0
- Separable blur reduces complexity from O(n²) to O(2n)
- Render targets sized to match backbuffer (1024x768)
- No dynamic memory allocation in render loop
- Fixed resolution (1024x768)
- Simplified scene geometry (test triangles)
- No depth-based DOF blending (split-screen demonstration only)
- DirectX 9 constraints (Shader Model 2.0)
Educational demonstration project.