Vulkano Tutorial
This site is intended to serve as a tutorial for using Vulkan in Rust via the Vulkano crate. This mostly documents my own experiments with learning graphical programming but I’m writing it down here in case others might find it useful. The Vulkano crate is in active development and so regularly experiences breaking changes. I will try to keep the examples updated but this is a hobby project.
Note: All code is provided under the MIT License and includes samples taken from official Vulkano examples. All text and images are licensed under the Creative Commons Attribution license (CC BY 4.0)
Requirements
The following needs to be present on your computer if you want to follow along:
1: Rust version 1.56.1 or later
2: A computer that supports Vulkan. You can check your hardware at the vendor’s website.
3: A working install of a shader pipeline as outlined in the main Vulkano documentation
Running the Lessons
This tutorial series uses Cargo’s Workspaces feature to group multiple projects into a single repo. To run cargo on a single project you can pass in the -p
flag followed by the name of the project.
All the lessons in this series are independent projects and are named lesson_{tutorial_number}
. For example, to run the first lesson navigate to the root vulkano_tutorial
directory and run cargo run -p lesson_1
.
Contents
0. Introduction
Provides a brief overview of some Vulkan considerations as well as a couple of notes on Rust.
1. Our first window
For our initial project, we will open a black window. This terminally-boring example is actually much longer and more important than you might expect. It will introduce most of the critical aspects shared by any Vulkan program.
2. Rendering a triangle
With our first project we learned how to set up and use a Vulkan program. Now in this lesson we learn how to render things to the screen. This will involve writing our first shaders as well as passing information to them.
3. Transformations
After getting your first triangle on the screen the obvious question becomes “great, so how do I make it do things?” For that we will need to learn to apply transformations via Uniform
data, which will be the other main way we feed data to our shaders in addition to the vertex data we learned about in the last lesson.
4. Depth
A shorter lesson that shows how to enable depth-testing in Vulkan. This is a necessity for the more complicated scenes we’ll be creating in later lessons.
5. Winding order
This lesson is a short one but it talks about a very important subject for rendering more complicated scenes: winding order and how you can use it to lower the amount of work your graphics hardware has to do.
6. Light I
And in the sixth lesson the programmer said “let there be light” and lo, there was light!
7. Multi-pass rendering
Now that we’re starting to get into more advanced features we’re going to need to increase the power of our rendering system. We will accomplish this by introducing multiple rendering passes into the equation.
8. Light II
Now that we’ve got our deferred rendering system set up, let’s look at how you can use it to add more than one directional light to our scene.
9. Models
Now that we’ve set up a working lighting system let’s take a step back and look at something else that would be important to any graphics application: how to load models from a file.
10. New Uniforms
After a couple of longer lessons, let’s take a short break to refactor our normals code as well as set the stage for multiple models.
11. Render System I
We’re ready now to take our first stab at making a real rendering system. We won’t introduce any new concepts in this lesson, just wrap up what we already know in a way that lets us input models to render as well as directional light sources. Think of this as a draft version of the more advanced system we’ll make in a few lessons.
11.5 Light Objects
Let’s take a bit of a break from “big picture” topics and implement a small feature that will give us the option to visually display where our light sources are in our scene.
12. Light III
We’re almost ready to move on to “advanced” topics, but first we have to revisit light one more time to complete our lighting model. This time we’ll be adding “shininess.”
13. Textures
A brief look at textures and a discussion of their uses.
14. Text
A look at how to use textures to display a timer to the user.