vulkan-guide
repository·master·Indexed 23 days ago
https://github.com/vblanco20-1/vulkan-guideA hands-on, step-by-step tutorial guide for learning Vulkan development through the Project Ascendant high-performance renderer. Project Ascendant features a deferred rendering architecture, a RenderGraph system, and specialized voxel rendering systems including a GPU-driven indirect culling pipeline, a far-field sprite raycaster, and a retained-mode MeshRenderer for arbitrary GLTF objects.
What's inside vulkan-guide
- This repository is a hands-on, step-by-step tutorial guide for learning Vulkan. It is designed to teach Vulkan development through practical application and incremental progress.
Overview of GLTF Loading in Vulkan
masterChapter 5 of the guide focuses on the implementation of GLTF file loading and the configuration of advanced rendering features within the Vulkan engine. This stage of the tutorial assumes the basic engine infrastructure has already been established.What is Vulkan and when to use it
masterVulkan is a cross-platform, high-performance, multi-threaded graphics API developed by the Khronos Group. It is designed to be explicit, reducing driver guesswork to provide low latency and consistent frame times.
When to use Vulkan:
- CPU-bound applications: If your application has many objects, big maps, or dynamic worlds, Vulkan's multi-threading capabilities can boost performance.
- Mobile development: On devices with good drivers, Vulkan offers lower CPU overhead and better battery efficiency.
- Compute tasks: Vulkan can be used in headless mode for GPU calculations like raytracing or saving images to disk without a display.
When to avoid Vulkan:
- GPU-bound applications: If the bottleneck is already on the GPU, Vulkan may not provide enough benefit to justify the complexity.
- Complexity concerns: Vulkan is significantly harder to use than OpenGL and requires longer development times.
Overview of Project Ascendant
masterProject Ascendant is a prototype framework designed for exploring large-scale voxel RPG development, specifically focusing on procedural generation and advanced graphics techniques. It is inspired by Minecraft and Daggerfall and serves as a technical playground for features that are often difficult to iterate on in commercial engines like Unreal Engine.
Key characteristics include:
- Purpose: Prototyping rendering features and procedural generation rather than shipping a commercial game.
- Technical Foundation: Built exclusively on Vulkan 1.3, targeting high performance on hardware like the Steam Deck.
- Relationship to VkGuide: The codebase is a direct continuation of the VkGuide 2.0 tutorial, expanding upon topics like draw indirect and lighting.
- Core Gameplay Loop: Includes procedural landscapes with biomes, resource gathering, crafting, and combat (sword, bow, magic) to validate the underlying architecture.
Understand the Ascendant Deferred Rendering Pipeline
masterThe Ascendant engine uses a deferred rendering architecture. The frame follows this general sequence:
- G-Buffer Pass: Renders meshes/voxels into Color (RGBA16), Normal (RGBA8), and Depth (D32) images.
- Shadow Passes: Renders cascaded shadows.
- SSAO Pass: A compute pass that reads depth/normals and outputs an SSAO texture.
- Sun Shadow Pass: A compute pass that writes sun shadow information (including contact shadows) into a render target.
- Sky & Volumetrics: Calculates atmospheric scattering (sky) and frustum-aligned 3D grid fog (volumetrics).
- G-Buffer Apply (Lighting):
- Applies ambient lighting (using SSAO and atmosphere).
- Applies sun lighting (using the sun mask).
- Applies point lights (via brute-force loop).
- Fogging: Applies volumetric and atmospheric fog to the lit image.
- Transparency: Draws transparent objects with fogging.
- Bloom: Performs downsampling/upscaling for a large-scale blur.
- Tonemapper: Combines bloom, applies exposure, performs FXAA, and converts F16 colors to the final swapchain format.
Drawing with compute and setting up Dear ImGui
masterChapter 2 focuses on implementing rendering using compute shaders. As part of this workflow, the project integrates theDearImguilibrary to provide a user interface for the application.Understand the project file structure
masterThe project is organized into a core engine and several abstraction layers located in the
project/src/directory:vk_engine.h/cpp: The main engine class containing the core logic.main.cpp: The application entry point that calls into thevk_engine.vk_initializers.h/cpp: Helpers for creating Vulkan structures.vk_images.h/cpp: Vulkan helpers for image-related tasks.vk_pipelines.h/cpp: Abstractions for Vulkan pipelines.vk_descriptors.h/cpp: Abstractions for descriptor sets.vk_loader.h/cpp: Logic for loading GLTF files.vk_types.h: A global header providing widely used default structures and includes.
The abstraction files (
vk_initializers,vk_images, etc.) are designed to be generic and have no dependencies other than Vulkan, making them reusable in other projects.Understand the Vulkan engine project layout
masterThe Vulkan engine follows a specific directory structure to simplify asset and shader path management. Note that executables are built directly into
/binrather than standard CMake build folders to keep paths consistent./assets: Textures and 3D models used throughout the guide./bin: Location where executables are built./shaders: Contains all shaders and their compiled SPIR-V output./src: Source code for the main application and engine./third_party: Contains all vendored libraries used by the project.
Drawing with compute and integrating DearImgui
masterChapter 2 focuses on implementing drawing logic using compute shaders. Additionally, this chapter covers the setup and integration of theDearImguilibrary to provide a user interface for the application.Understand the project folder layout
masterThe Vulkan engine project uses a specific directory structure to manage assets, binaries, and source code:
/assets: Contains textures and 3D models used throughout the guide./bin: The destination for built executables. This is used instead of standard CMake build folders to simplify asset and shader path resolution./shaders: Contains all shader source files and their compiled outputs./chapter-N: Contains the source code specific to each chapter of the guide./third_party: Contains all vendored-in libraries, ensuring all source code is readily available for building.
Explore Project Ascendant prototype
masterProject Ascendant is an open-world voxel RPG prototype built on top of VKGuide. It serves as a demonstration of how the foundational tutorial code can be evolved into a full-scale game engine. Unlike the standard tutorial chapters, this section is not a step-by-step walkthrough of the code, but rather a showcase of architectural directions and engine growth, similar to the concepts introduced in the GPU Driven chapter.Project Structure and File Responsibilities
masterThe project is organized into several core files located in the
project/src/directory, each serving a specific role in the Vulkan engine abstraction:vk_engine.h/cpp: The central engine class containing the main logic and lifecycle management.main.cpp: The application entry point that orchestrates theVulkanEnginelifecycle.vk_initializers.h/cpp: Helpers for creating and initializing Vulkan structures.vk_images.h/cpp: Vulkan helpers specifically for image management.vk_pipelines.h/cpp: Abstractions for Vulkan pipelines.vk_descriptors.h/cpp: Abstractions for descriptor sets.vk_loader.h/cpp: Logic for loading GLTF files.vk_types.h: A global header providing common default structures, includes, and macros used throughout the codebase.