29,99 €
Written by experts with decades of rendering experience, this cookbook equips you with practical, hands-on recipes to master modern 3D graphics development by using bindless Vulkan.
Focusing on Vulkan 1.3, this second edition starts by setting up your development environment, and quickly transitions to building a robust 3D rendering framework using self-contained recipes. Each recipe helps you incrementally enhance your codebase, integrating a variety of 3D rendering techniques and algorithms into a cohesive project. You’ll get to grips with core techniques, such as glTF 2.0 physically based rendering, image-based lighting, and GPU-driven rendering. The chapters help you grasp advanced topics, including glTF animations, screen-space rendering techniques, and optimization strategies. You’ll also learn how to use glTF 2.0 advanced PBR extensions and handle complex geometry data, ensuring your rendering engine is both powerful and performant. These new additions will enable you to create dynamic and realistic 3D graphics environments, fully utilizing Vulkan’s capabilities.
By the end of this 3D rendering book, you’ll have gained an improved understanding of best practices used in modern graphic APIs and be able to create fast and versatile 3D rendering frameworks.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 902
Veröffentlichungsjahr: 2025
Vulkan 3D Graphics Rendering Cookbook
Second Edition
Implement expert-level techniques for high-performance graphics with Vulkan
Sergey Kosarevsky
Alexey Medvedev
Viktor Latypov
Vulkan 3D Graphics Rendering Cookbook
Second Edition
Copyright © 2025 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Portfolio Director: Rohit Rajkumar
Relationship Lead: Kaustubh Manglurkar
Content Engineer: Anuradha Vishwas Joglekar
Program Manager: Sandip Tadge
Growth Lead: Namita Velgekar
Copy Editor: Safis Editing
Technical Editor: Tejas Mhasvekar
Proofreader: Anuradha Vishwas Joglekar
Indexer: Manju Arasan
Presentation Designer: Ajay Patule
Marketing Owner: Nivedita Pandey
First published: August 2021
Second edition: February 2025
Production reference: 2090725
Published by Packt Publishing Ltd.
Grosvenor House
11 St Paul’s Square
Birmingham
B3 1RB, UK.
ISBN 978-1-80324-811-0
www.packt.com
Dedicated to my grandmother, Liudmila Fedorovna Sitorkina, and my mother, Irina Leonidovna Kosarevskaya.
– Sergey Kosarevsky
Dedicated to my family, friends, colleagues and Khronos fellows. I’m thankful, grateful and blessed to have you all in my life!
– Alexey Medvedev
In the modern ocean of GPU APIs, Vulkan is gaining popularity for rendering, thanks to its high performance and cross-platform nature. Thanks to the dedication of the authors, this book covers a lot of ground, from the very first steps to modern and advanced topics. A graphics programmer who wants to start with Vulkan can find an easy-to-follow guide on how to set up the system and get to the first frame. A seasoned practitioner can find modern practices of physically based rendering, advanced resource management, and GPU-side optimizations. What I really like is the “There’s more…” section at the end of every section, where the authors make the topic truly open-ended, leaving useful references, suggestions, and room for you to improve upon the material in the future.
One thing that makes this book special is its practicality, with the abundance of code available and explained right in the book. This way, you can both immediately see how Vulkan works and read about the reasons behind it. The book also goes way beyond just the API level, introducing higher-level rendering pipeline architecture and related concepts, such as the material system or geometry and asset formats. This enables you to be able to write not just a Vulkan-based renderer but also a small end-to-end experience with user interaction and advanced content.
The authors are well-renowned experts in the field with a lot of experience writing real-time engines and shipping AAA game titles, so you are in good hands. I was delighted to see the second edition of this book coming out with more elaborate and advanced topics. If you were looking for a comprehensive handbook on Vulkan and modern real-time rendering, you are holding it!
Anton Kaplanyan
VP, Graphics Research at Intel Corp.
Sergey Kosarevsky is a former rendering lead at Ubisoft RedLynx. He currently leads Vulkan development at Meta. He worked in the mobile industry at SPB Software, Yandex, Layar and Blippar, TWNKLS, and DAQRI, where he designed and implemented real-time rendering technology. He has more than 20 years of software development experience and more than 12 years of mobile and embedded 3D graphics experience. In his Ph.D. thesis, Sergey employed computer vision to solve mechanical engineering problems. He is also a co-author of several books on 3D graphics and mobile software development in C++, including 3D Graphics Rendering Cookbook.
I want to express my heartfelt gratitude to my dedicated reviewer and friend, Alexander Pavlov, for his incredible commitment over the past 13 years, meticulously reviewing all our books. I also extend my sincere thanks to all my friends, colleagues, and reviewers whose support made this book possible!
Alexey Medvedev is the AR Tech Lead at Meta, with over 20 years of experience in software development, primarily in game development. He has worked as an engine, graphics, and rendering engineer at renowned companies like Crytek, Blizzard, and Hangar 13, contributing to the release of several AAA games. At the time of writing this book, Alexey also serves as the Khronos Chair of the 3D Formats Working Group, which develops the glTF standards.
I would like to first and foremost thank my family for their continued support, patience, and encouragement throughout the long process of writing this book.
Viktor Latypov is a software engineer specializing in embedded C/C++, 3D graphics, and computer vision. With more than 15 years of software development experience and a Ph.D. in applied mathematics, he has implemented a number of real-time renderers for medical and automotive applications over the last 10 years. Together with Sergey, he has co-authored two books on mobile software development in C++.
Marco Castorina is the co-author of Mastering Graphics Programming with Vulkan. He has been working on graphics since completing his Masters in Digital Games at the Dublin Institute of Technology. First as a hobby and then as his day to day job when he joined Samsung as a driver developer. Here he got familiar with Vulkan and mobile rendering architecture. Later he developed a 2D and 3D renderer in Vulkan from scratch for a leading media-server company. He currently works on the games graphics performance team at AMD, focusing on DX12. In his spare time he keeps up to date with the latest techniques in real-time graphics, likes to cook and make music.
David Sena is a Graphics Technnical Director at NaturalMotion where he works on the CSR Racing game series. Before that, he was a Senior Graphics Software Engineer at Samsung R&D UK where he worked on solutions for different mobile devices and platforms. While at Samsung, David did research on solutions for global illumination, point clouds and VR/AR. David has been working as a graphics software engineer for over 12 years, with a focus on real-time rendering as well as developing and researching novel graphics solutions for mobile and handheld console platforms.
Alexander Pavlov is a Senior Software Engineer at Google with over 20 years of experience in industrial software development. He specializes in large-scale system design, many of the systems he has worked on are used daily by millions of people. His areas of interest include compiler theory and 3D graphics. Alexander also contributed as a technical reviewer and proofreader for the Android NDK Game Development Cookbook and the 3D Graphic Rendering Cookbook (1st ed.), published by Packt.
Preface
Who this book is for
What this book covers
To get the most out of this book
Get in touch
Establishing a Build Environment
Getting the most out of this book – get to know your free benefits
Setting up our development environment on Microsoft Windows
Getting ready
How to do it...
Microsoft Visual Studio 2022
Git
CMake
Python
There’s more...
Setting up our development environment on Linux
Getting ready
How to do it...
Installing the Vulkan SDK for Windows and Linux
Getting ready
How to do it...
There’s more...
Managing dependencies
Getting ready
How to do it...
How it works...
There’s more...
Getting the demo data
How to do it…
Creating utilities for CMake projects
Getting ready
How to do it...
There’s more...
Using the GLFW library
Getting ready
How to do it...
How it works...
There’s more...
Multithreading with Taskflow
Getting ready
How to do it...
There’s more...
Compiling Vulkan shaders at runtime
Getting ready
How to do it...
How it works...
There’s more...
Compressing textures into the BC7 format
Getting ready
How to do it...
There’s more...
Getting Started with Vulkan
Technical requirements
Initializing Vulkan instance and graphical device
Getting ready
How to do it...
How it works...
Initializing Vulkan swapchain
Getting ready
How to do it...
Setting up Vulkan debugging capabilities
Getting ready
How to do it...
There’s more…
Using Vulkan command buffers
Getting ready…
How to do it...
How it works…
There’s more…
Initializing Vulkan shader modules
Getting ready
How to do it...
Initializing Vulkan pipelines
Getting ready...
How to do it...
How it works…
There’s more…
Working with Vulkan Objects
Technical requirements
Dealing with buffers in Vulkan
Getting ready
How to do it...
How it works…
Implementing staging buffers
Getting ready…
How to do it…
There’s more…
Using texture data in Vulkan
Getting ready
How to do it...
How it works…
There’s more…
Storing Vulkan objects
Getting ready
How to do it…
How it works…
Using Vulkan descriptor indexing
How to do it...
How it works…
There’s more…
Adding User Interaction and Productivity Tools
Technical requirements
Rendering ImGui user interfaces
Getting ready
How to do it...
How it works…
Integrating Tracy into C++ applications
Getting ready
How to do it...
How it works...
Using Tracy GPU profiling
Getting ready
How to do it...
How it works...
Adding a frames-per-second counter
Getting ready
How to do it...
Using cube map textures in Vulkan
Getting ready
How to do it...
There’s more...
Working with a 3D camera and basic user interaction
Getting ready
How to do it...
How it works...
There is more...
Adding camera animations and motion
Getting ready
How to do it...
How it works...
There’s more...
Implementing an immediate-mode 3D drawing canvas
Getting ready
How to do it...
How it works…
Rendering on-screen graphs with ImGui and ImPlot
Getting ready
How to do it...
How it works...
Putting it all together into a Vulkan application
Getting ready
How to do it...
Working with Geometry Data
Technical requirements
Generating level-of-detail meshes using MeshOptimizer
Getting ready
How to do it...
How it works…
There’s more...
Implementing programmable vertex pulling
Getting ready
How to do it...
There’s more...
Rendering instanced geometry
Getting ready
How to do it…
How it works…
There’s more…
Implementing instanced meshes with compute shaders
Getting ready
How to do it…
How it works…
There’s more…
Implementing an infinite grid GLSL shader
Getting ready
How to do it...
There’s more...
Integrating tessellation into the graphics pipeline
Getting ready
How to do it...
There’s more...
Organizing mesh data storage
Getting ready
How to do it...
How it works...
There’s more...
Implementing automatic geometry conversion
Getting ready
How to do it...
How it works...
Indirect rendering in Vulkan
Getting ready
How to do it...
Generating textures in Vulkan using compute shaders
Getting ready
How to do it...
Implementing computed meshes
Getting ready
How to do it...
How it works…
There’s more…
Physically Based Rendering Using the glTF 2.0 Shading Model
An introduction to glTF 2.0 physically based shading model
Getting ready
What is PBR?
Light-object interactions
Energy conservation
Surface properties
Types of reflection
Transmission
Fresnel equation
Microfacets
What is a material?
glTF PBR specification
There’s more...
Rendering unlit glTF 2.0 materials
Getting ready
How to do it…
Precomputing BRDF look-up tables
Getting ready
Why precompute?
How to do it...
How it works...
There’s more...
Precomputing irradiance maps and diffuse convolution
Getting ready
How to do it...
There’s more...
Implementing the glTF 2.0 metallic-roughness shading model
Getting ready
How to do it…
How it works…
There’s more...
Implementing the glTF 2.0 specular-glossiness shading model
What is specular-glossiness?
Getting ready
How to do it...
There’s more...
Advanced PBR Extensions
Introduction to glTF PBR extensions
Getting ready
How is the glTF 2.0 PBR model designed?
Getting ready
How to do it…
There’s more...
Implementing the KHR_materials_clearcoat extension
Clearcoat parameters
Specular BRDF for the clearcoat layer
Getting ready
How to do it…
There’s more...
Implementing the KHR_materials_sheen extension
Sheen parameters
Simulating the sheen effect
Getting ready
How to do it…
There’s more...
Implementing the KHR_materials_transmission extension
Transmission parameters
Transmission BTDF
Getting ready
How to do it…
There is more…
Implementing the KHR_materials_volume extension
Volumetric parameters
Getting ready
How to do it…
There is more…
Implementing the KHR_materials_ior extension
IOR parameters
Getting ready
How to do it…
There is more…
Implementing the KHR_materials_specular extension
Specular parameters
Specular-Glossiness conversion
Getting ready
How to do it…
There is more…
Implementing the KHR_materials_emissive_strength extension
Getting ready
How to do it…
Extend analytical lights support with KHR_lights_punctual
Image-Based Lighting vs Punctual lights
Getting ready
How to do it…
Graphics Rendering Pipeline
How not to do a scene graph
Using data-oriented design for a scene graph
Getting ready
How to do it...
There’s more...
Loading and saving a scene graph
Getting ready
How to do it...
There’s more...
Implementing transformation trees
Getting ready
How to do it...
There’s more...
Implementing a material system
Getting ready
How to do it...
How it works...
Implementing automatic material conversion
Getting ready
How to do it...
How it works...
There’s more...
Using descriptor indexing and arrays of textures in Vulkan
Getting ready
How to do it...
How it works...
Implementing indirect rendering with Vulkan
Getting ready
How to do it...
How it works...
Putting it all together into a scene editing application
Getting ready
How to do it...
How it works...
There’s more...
Deleting nodes and merging scene graphs
Getting ready
How to do it...
Rendering large scenes
Getting ready
How to do it...
How it works...
There’s more...
glTF Animations
Technical requirements
Introduction to node-based animations
Introduction to skeletal animations
Importing skeleton and animation data
Getting ready
How to do it…
How it works…
Implementing the glTF animation player
Getting ready
How to do it…
How it works…
There’s more…
Doing skeletal animations in compute shaders
Getting ready
How to do it…
How it works…
Introduction to morph targets
Loading glTF morph targets data
Getting ready
How to do it…
Adding morph targets support
Getting ready
How to do it…
How it works…
There’s more…
Animation blending
Getting ready
How to do it…
How it works…
There’s more…
Image-Based Techniques
Technical requirements
Implementing offscreen rendering in Vulkan
Getting ready
How to do it…
How it works…
Implementing full-screen triangle rendering
Getting ready
How to do it…
There’s more...
Implementing shadow maps
Getting ready
How to do it…
How it works…
There’s more…
Implementing MSAA in Vulkan
Getting ready
How to do it…
How it works…
There’s more…
Implementing screen space ambient occlusion
Getting ready
How to do it...
How it works…
There’s more...
Implementing HDR rendering and tone mapping
Getting ready
How to do it...
How it works…
There’s more...
Implementing HDR light adaptation
Getting ready
How to do it...
There’s more...
Advanced Rendering Techniques and Optimizations
Technical requirements
Refactoring indirect rendering
Getting ready
How to do it…
How it works…
Doing frustum culling on the CPU
Getting ready
How to do it…
How it works…
There’s more...
Doing frustum culling on the GPU with compute shaders
Getting ready
How to do it…
How it works…
There’s more...
Implementing shadows for directional lights
Getting ready
How to do it...
There’s more...
Implementing order-independent transparency
Getting ready
How to do it…
How it works…
There’s more…
Loading texture assets asynchronously
Getting ready
How to do it...
How it works…
There’s more...
Putting it all together into a Vulkan demo
Getting ready
How to do it...
There’s more…
Unlock Your Book’s Exclusive Benefits
How to unlock these benefits in three easy steps
Need help?
Other Books You May Enjoy
Index
Cover
Index
Once you’ve read Vulkan 3D Graphics Rendering Cookbook, Second edition, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.