diff --git a/tutorial/book/src/model/depth_buffering.md b/tutorial/book/src/model/depth_buffering.md index 3afcde53..8323d11a 100644 --- a/tutorial/book/src/model/depth_buffering.md +++ b/tutorial/book/src/model/depth_buffering.md @@ -114,14 +114,15 @@ The problem is that the fragments of the lower square are drawn over the fragmen The first approach is commonly used for drawing transparent objects, because order-independent transparency is a difficult challenge to solve. However, the problem of ordering fragments by depth is much more commonly solved using a *depth buffer*. A depth buffer is an additional attachment that stores the depth for every position, just like the color attachment stores the color of every position. Every time the rasterizer produces a fragment, the depth test will check if the new fragment is closer than the previous one. If it isn't, then the new fragment is discarded. A fragment that passes the depth test writes its own depth to the depth buffer. It is possible to manipulate this value from the fragment shader, just like you can manipulate the color output. -Before we continue, there is one issue we need to fix. The perspective projection matrix generated by `cgmath::perspective` in `App::update_uniform_buffer` uses OpenGL depth range of `-1.0` to `1.0`. We want to use the Vulkan range of `0.0` to `1.0` instead so we'll pre-multiply the generated perspective matrix with a [correction matrix](https://matthewwellings.com/blog/the-new-vulkan-coordinate-system) that maps the OpenGL range to the Vulkan range: +Before we continue, there is one issue we need to fix. The perspective projection matrix generated by `cgmath::perspective` in `App::update_uniform_buffer` uses the OpenGL depth range of `-1.0` to `1.0`. We want to use the Vulkan range of `0.0` to `1.0` instead so we'll pre-multiply the generated perspective matrix with a [correction matrix](https://matthewwellings.com/blog/the-new-vulkan-coordinate-system) that maps the OpenGL range to the Vulkan range: ```rust,noplaypen let correction = Mat4::new( 1.0, 0.0, 0.0, 0.0, - 0.0, -1.0, 0.0, 0.0, // we're also handling Y-flipping here + // We're also flipping the Y-axis with this line's `-1.0`. + 0.0, -1.0, 0.0, 0.0, + 0.0, 0.0, 1.0 / 2.0, 0.0, 0.0, 0.0, 1.0 / 2.0, 0.0, - 0.0, 0.0, 1.0 / 2.0, .0, ); let proj = correction @@ -132,8 +133,8 @@ let proj = correction 10.0, ); -// this line can be deleted now, because we're already handling the Y-axis flip -// with the correction matrix +// This line should be deleted because we're now accomplishing the Y-axis flip +// using the new correction matrix. // proj[1][1] *= -1.0; ``` diff --git a/tutorial/book/src/uniform/descriptor_layout_and_buffer.md b/tutorial/book/src/uniform/descriptor_layout_and_buffer.md index c26ad941..5a9d1818 100644 --- a/tutorial/book/src/uniform/descriptor_layout_and_buffer.md +++ b/tutorial/book/src/uniform/descriptor_layout_and_buffer.md @@ -71,7 +71,7 @@ Note that the order of the `uniform`, `in` and `out` declarations doesn't matter ## Descriptor set layout -The next step is to define the UBO on the Rust side and to tell Vulkan about this descriptor in the vertex shader. First we add a few more imports and several type aliases: +The next step is to define the UBO on the Rust side and to tell Vulkan about this descriptor in the vertex shader. First we add a few more imports and a type alias: ```rust,noplaypen use cgmath::{point3, Deg}; @@ -91,7 +91,7 @@ struct UniformBufferObject { } ``` -We can exactly match the definition in the shader using data types in `cgmath` crate. The data in the matrices is binary compatible with the way the shader expects it, so we can later just copy a `UniformBufferObject` to a `vk::Buffer`. +We can exactly match the definition in the shader using data types in the `cgmath` crate. The data in the matrices is binary compatible with the way the shader expects it, so we can later just copy a `UniformBufferObject` to a `vk::Buffer`. We need to provide details about every descriptor binding used in the shaders for pipeline creation, just like we had to do for every vertex attribute and its `location` index. We'll set up a new function to define all of this information called `^create_descriptor_set_layout`. It should be called right before pipeline creation, because we're going to need it there. @@ -333,7 +333,7 @@ let model = Mat4::from_axis_angle( ); ``` -The `Mat4::from_axis_angle` function creates a transformation matrix from given rotation angle and rotation axis. Using a rotation angle of `Deg(90.0) * time` accomplishes the purpose of rotating 90 degrees per second. +The `Mat4::from_axis_angle` function creates a transformation matrix from the given rotation angle and rotation axis. Using a rotation angle of `Deg(90.0) * time` accomplishes the purpose of rotating 90 degrees per second. ```rust,noplaypen let view = Mat4::look_at_rh( @@ -343,7 +343,7 @@ let view = Mat4::look_at_rh( ); ``` -For the view transformation I've decided to look at the geometry from above at a 45 degree angle. The `Mat4::look_at_rh` function takes the eye position, center position and up axis as parameters. `rh` stands for "right-handed" coordinate system, which is the coordinate system that Vulkan uses. +For the view transformation I've decided to look at the geometry from above at a 45 degree angle. The `Mat4::look_at_rh` function takes the eye position, center position and up axis as parameters. The `rh` at the end of this function indicates that it uses the "right-handed" coordinate system which is the coordinate system that Vulkan uses. ```rust,noplaypen let mut proj = cgmath::perspective(