Custom racing game engine built from scratch with 100% ray tracing (no rasterization). Built with C++ and Vulkan 1.3 Ray Tracing extensions.
The engine is currently rendering in real-time using pure path tracing. No rasterization pipeline.
- Vulkan SDK 1.3+ (installed at C:\VulkanSDK\1.4.321.1)
- CMake 3.20+
- C++17 compiler (MSVC 2022 tested)
- NVIDIA RTX GPU (3060 Ti confirmed working)
- Windows (currently Windows-only)
cd RacingEngine
mkdir build && cd build
cmake ..
cmake --build . --config Releasecd Release
RacingEngine.exe- WASD - Move camera forward/left/back/right
- QE - Move camera up/down
- Mouse - Look around (FPS-style)
- Shift - Move faster
- ESC - Exit (or close window)
RacingEngine/
├── src/
│ ├── main.cpp # Main engine loop
│ ├── Camera.cpp/h # FPS camera with WASD + mouse
│ ├── VulkanSwapchain.cpp/h # Swapchain management
│ ├── VulkanRayTracing.cpp/h # RT storage images & commands
│ ├── VulkanAcceleration.cpp/h # BLAS/TLAS acceleration structures
│ └── VulkanRTPipeline.cpp/h # RT pipeline & SBT
├── shaders/
│ ├── raygen.rgen # Ray generation shader
│ ├── miss.rmiss # Miss shader (sky)
│ ├── closesthit.rchit # Closest hit shader
│ └── compiled/ # SPIR-V compiled shaders
├── external/
│ ├── glfw/ # Window management
│ ├── glm/ # Math library
│ ├── stb/ # Image loading
│ └── vma/ # Vulkan memory allocator
└── build/ # Build output
- Vulkan 1.3 initialization with validation layers
- Swapchain for image presentation
- Ray tracing storage images (RT output)
- Acceleration structures (BLAS + TLAS)
- Geometry system (triangle buffers with device addresses)
- RT shaders (raygen, miss, closest hit)
- RT pipeline with descriptor sets
- Shader Binding Table (SBT)
- Render loop with proper synchronization
- Command buffers with image transitions
- Free camera controls (WASD + mouse + QE for up/down)
- FPS-style camera with mouse look
- Real-time camera updates in ray tracing shaders
- Multiple geometry objects (ground plane + cubes)
- Per-object coloring based on instance ID
- Multiple BLAS system for different objects
- Improved lighting model (ambient + diffuse + specular)
- Approximate normal calculation for ground and cubes
- Sky ambient lighting with blue tint from above
- Shadow rays for accurate shadowing
- Multiple bounces for global illumination (reflection rays)
- Recursion depth 4 supporting primary, shadow, and reflection rays
- Materials and textures (PBR workflow)
- Diffuse bounces with importance sampling
- PBR materials (metallic/roughness workflow)
- Path tracing with importance sampling
- Denoising (temporal or spatial)
- HDR environment maps
- Vehicle physics (arcade-style)
- Dynamic objects (animated cars)
- Post-processing (tone mapping, bloom)
-
API: Vulkan 1.3 with KHR ray tracing extensions
- VK_KHR_ray_tracing_pipeline
- VK_KHR_acceleration_structure
- VK_KHR_deferred_host_operations
- VK_KHR_buffer_device_address
-
Shaders: GLSL with ray tracing extensions compiled to SPIR-V
-
Acceleration: Separate BLAS for each object, single TLAS for scene
-
Output: Direct write to storage image, blit to swapchain
- Resolution: 1920x1080
- Rays per pixel: 1 (single sample, no accumulation yet)
- Max recursion depth: 4 (supports multiple bounces)
- Scene: Ground plane (50x50 units) + 4 colored cubes
- Objects: 5 geometry objects with individual BLAS
- Lighting Model:
- Ambient lighting (base illumination)
- Diffuse lighting (Lambertian)
- Specular highlights (Blinn-Phong, shininess 32)
- Sky ambient (blue tint from above)
- Shadow rays for accurate shadowing of direct light
- Reflection rays for indirect lighting (global illumination)
- Normals: Approximate normals (ground=up, cubes=dominant axis)
- Global Illumination: Recursive reflection rays with 0.3 reflectivity
On NVIDIA RTX 3060 Ti:
- Real-time rendering at 1080p
- Current scene (5 objects, ~100 triangles): High FPS
- Camera movement is smooth and responsive
- Ready for more complex scenes with materials and lighting
If you want to set up dependencies manually:
# Clone dependencies
cd external
git clone --depth 1 https://github.com/g-truc/glm.git
git clone --depth 1 https://github.com/glfw/glfw.git
# Download single-header libraries
mkdir -p stb vma
curl -o stb/stb_image.h https://raw.githubusercontent.com/nothings/stb/master/stb_image.h
curl -o vma/vk_mem_alloc.h https://raw.githubusercontent.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/master/include/vk_mem_alloc.h
# Build
cd ..
mkdir build && cd build
cmake .. && cmake --build . --config ReleaseThis engine uses 100% ray tracing with no rasterization pipeline:
- Simpler architecture (no vertex/fragment shaders)
- Unified lighting model (no separate shadow passes)
- True reflections and refractions
- Better suited for photorealistic racing environments
- Device-local buffers for geometry
- Host-visible staging buffers for uploads
- Device addresses for bindless access in RT shaders
- Proper buffer usage flags for RT (VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR)
Next milestones:
Implement free camera controls✅ DONEAdd ground plane and basic environment✅ DONEImprove lighting model✅ DONEAdd shadows via shadow rays✅ DONEImplement multiple bounces for global illumination✅ DONE- Load car model (glTF)
- Add materials and textures (PBR)
- Implement diffuse bounces with importance sampling
- Add temporal accumulation for cleaner image
Custom engine for educational purposes.
- Vulkan SDK: LunarG
- GLFW: Marcus Geelnard, Camilla Löwy
- GLM: G-Truc
- stb: Sean Barrett
- VMA: AMD GPUOpen