You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bookcontents/chapter-08/chapter-08.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,7 @@ public class ModelLoader {
105
105
}
106
106
```
107
107
108
-
We first check if the path to the 3D model and the texture directory exist. After that, we import the 3D model by invoking the `aiImportFile` Assimp function which will return an `AIScene` structure. Then, we use the `AIScene` structure to load the 3D models materials. We get the total number of materials allocating as many structures of `AIMaterial` as needed. The material will hold information related to the textures and colors for each mesh. For each of the materials we extract the values that we will need by calling the `processMaterial` method. The next step is to load the meshes data by calling the `processMesh` method. As in the case of materials, we get the total number of meshes that the `AIScene` contains and allocate as many `AIMesh` structure as needed. Once we have finished processing the model we just release the `AIScene` and return the array of the meshes present in the model. Let's analyze first the `processMaterial` method:
108
+
We first check if the path to the 3D model and the texture directory exists. After that, we import the 3D model by invoking the `aiImportFile` Assimp function which will return an `AIScene` structure. Then, we use the `AIScene` structure to load the 3D models materials. We get the total number of materials allocating as many structures of `AIMaterial` as needed. The material will hold information related to the textures and colors for each mesh. For each of the materials we extract the values that we will need by calling the `processMaterial` method. The next step is to load the meshes data by calling the `processMesh` method. As in the case of materials, we get the total number of meshes that the `AIScene` contains and allocate as many `AIMesh` structure as needed. Once we have finished processing the model we just release the `AIScene` and return the array of the meshes present in the model. Let's analyze first the `processMaterial` method:
109
109
110
110
```java
111
111
publicclassModelLoader {
@@ -198,7 +198,7 @@ public class ModelData {
198
198
...
199
199
```
200
200
201
-
Going back to the `ModelLoader`class, the remaining methods are quite simple, we just extract the position and texture coordinates and the indices:
201
+
Going back to the `ModelLoader`class, the remaining methods are quite simple, we just extract the position and texture coordinates and the indices:
202
202
203
203
```java
204
204
publicclassModelLoader {
@@ -398,7 +398,7 @@ public class Texture {
398
398
}
399
399
```
400
400
401
-
In order forVulkan to correctly use the image, we need to transition it to the correct layout an copy the staging buffer contents to the image.This is done in the `recordTextureTransition` method.
401
+
In order forVulkan to correctly use the image, we need to transition it to the correct layout an copy the staging buffer contents to the image.This is done in the `recordTextureTransition` method.
402
402
403
403
```java
404
404
publicclassTexture {
@@ -503,7 +503,7 @@ In the second case, the second `if` condition will be executed. We use the `VK_A
503
503
504
504
Once the conditions has been set we record the image pipeline barrier by invoking the `vkCmdPipelineBarrier` function.
505
505
506
-
The only missing method in t he `Texture` classis the `recordCopyBuffer`:
506
+
The only missing method in the `Texture` classis the `recordCopyBuffer`:
507
507
508
508
```java
509
509
publicclassTexture {
@@ -590,7 +590,7 @@ public class EngineProperties {
590
590
}
591
591
```
592
592
593
-
Back to the `TextureCache` class, the rest of the methods are the classical `cleanup` method to free the images and the `getTexture` method to be able to retrieve one already created `Texture` using is file path and through their position.
593
+
Back to the `TextureCache` class, the rest of the methods are the classical `cleanup` method to free the images and the `getTexture` method to be able to retrieve one already created `Texture` using is file path and through their position.
594
594
595
595
```java
596
596
publicclassTextureCache {
@@ -833,7 +833,7 @@ public class DescriptorPool {
833
833
}
834
834
```
835
835
836
-
The format of each descriptor set must me defined by a descriptor set layout. The layout will be something very dependent on the specific data structures that we will use in our shaders. However, we will create an abstractclassto avoid repeating the cleanup method and to store its handle:
836
+
The format of each descriptor set must be defined by a descriptor set layout. The layout will be something very dependent on the specific data structures that we will use in our shaders. However, we will create an abstractclassto avoid repeating the cleanup method and to store its handle:
837
837
838
838
```java
839
839
package org.vulkanb.eng.graph.vk;
@@ -993,7 +993,7 @@ public class TextureSampler {
993
993
In order to create a sampler, we need to invoke the `vkCreateSampler` function which requires a `VkSamplerCreateInfo` structure, defined by the following fields:
994
994
995
995
- `sType`:The type of the structure: `VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO`.
996
-
- `magFilter` and `minFilter`: control how magnification and magnification filter work while performing a texture lookup. In this case, we are using a `VK_FILTER_LINEAR` filter, which is the value for a linerfilter (fora2Dtexture, itcombinesforvaluesoffourpixelsweighted). You can use `VK_FILTER_NEAREST` to pickup just the closest value in the lookup or `VK_FILTER_CUBIC_EXT` to apply cubic filtering (ituses16valuesfor2Dtextures).
996
+
- `magFilter` and `minFilter`: control how magnification and magnification filter work while performing a texture lookup. In this case, we are using a `VK_FILTER_LINEAR` filter, which is the value for a linearfilter (fora2Dtexture, itcombinesforvaluesoffourpixelsweighted). You can use `VK_FILTER_NEAREST` to pickup just the closest value in the lookup or `VK_FILTER_CUBIC_EXT` to apply cubic filtering (ituses16valuesfor2Dtextures).
997
997
- `addressModeU`, `addressModeV` and `addressModeW`: This will control what will be returned for a texture lookup when the coordinates lay out of the texture size. The `U`, `V` and `W` refer to the `x`, `y` and `z` axis (for3Dimages). In this case, we specify the `VK_SAMPLER_ADDRESS_MODE_REPEAT` which means that the texture is repeated endlessly over all the axis. There are some other values such as `VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT` or `VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE` which are similar as the ones used in OpenGL.
998
998
- `borderColor`: This sets the color for the border that will be used for texture lookups beyond bounds when `VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER` is used in the `addressModeX` attributes.
999
999
- `unnormalizedCoordinates`: Texture coordinates cover the [0, 1] range. When this parameter is set to `true` the coordinates will cover the ranges [0, width], [0, height].
@@ -1175,7 +1175,7 @@ public abstract class DescriptorSet {
1175
1175
...
1176
1176
}
1177
1177
```
1178
-
The code is similar as the descriptor set used for textures, with the following exception, ee use a `VkDescriptorBufferInfo` to link the descriptor with the buffer that will hold the descriptor set values. Now we can create another class, specifically for uniforms, which extends the `SimpleDescriptorSet` class, named `UniformDescriptorSet`:
1178
+
The code is similar as the descriptor set used for textures, with the following exception, we use a `VkDescriptorBufferInfo` to link the descriptor with the buffer that will hold the descriptor set values. Now we can create another class, specifically for uniforms, which extends the `SimpleDescriptorSet` class, named `UniformDescriptorSet`:
0 commit comments