|
1 | 1 | --- a/27_model_loading.rs |
2 | 2 | +++ b/28_generating_mipmaps.rs |
3 | | -@@ -36,12 +36,20 @@ use vulkano::swapchain::{ |
| 3 | +@@ -37,12 +37,20 @@ use vulkano::swapchain::{ |
4 | 4 | use vulkano::format::{Format, ClearValue}; |
5 | 5 | use vulkano::image::{ |
6 | 6 | ImageUsage, |
|
24 | 24 | use vulkano::pipeline::{ |
25 | 25 | GraphicsPipeline, |
26 | 26 | GraphicsPipelineAbstract, |
27 | | -@@ -58,6 +66,7 @@ use vulkano::command_buffer::{ |
| 27 | +@@ -59,6 +67,7 @@ use vulkano::command_buffer::{ |
28 | 28 | AutoCommandBuffer, |
29 | 29 | AutoCommandBufferBuilder, |
30 | 30 | DynamicState, |
31 | 31 | + CommandBuffer, |
32 | 32 | }; |
33 | 33 | use vulkano::buffer::{ |
34 | 34 | immutable::ImmutableBuffer, |
35 | | -@@ -73,7 +82,12 @@ use vulkano::descriptor::descriptor_set::{ |
| 35 | +@@ -74,9 +83,14 @@ use vulkano::descriptor::descriptor_set::{ |
36 | 36 | PersistentDescriptorSetImg, |
37 | 37 | PersistentDescriptorSetSampler, |
38 | 38 | }; |
39 | | --use vulkano::sampler::Sampler; |
40 | 39 | +use vulkano::sampler::{ |
41 | 40 | + Sampler, |
42 | 41 | + Filter, |
43 | 42 | + MipmapMode, |
44 | 43 | + SamplerAddressMode, |
45 | 44 | +}; |
| 45 | + |
46 | 46 | use image::GenericImageView; |
| 47 | +-use vulkano::sampler::Sampler; |
47 | 48 |
|
48 | | - const WIDTH: u32 = 800; |
49 | | -@@ -539,28 +553,108 @@ impl HelloTriangleApplication { |
| 49 | + use cgmath::{ |
| 50 | + Rad, |
| 51 | +@@ -549,28 +563,114 @@ impl HelloTriangleApplication { |
50 | 52 | ).collect::<Vec<_>>() |
51 | 53 | } |
52 | 54 |
|
|
149 | 151 |
|
150 | 152 | fn create_image_sampler(device: &Arc<Device>) -> Arc<Sampler> { |
151 | 153 | - Sampler::simple_repeat_linear(device.clone()) |
| 154 | ++ // This is the standard sampler but for this section we are using a custom sampler to show the work we have done |
152 | 155 | + // Sampler::simple_repeat_linear(device.clone()) |
153 | | -+ Sampler::new(device.clone(), |
154 | | -+ Filter::Linear, |
155 | | -+ Filter::Linear, |
156 | | -+ MipmapMode::Linear, |
157 | | -+ SamplerAddressMode::Repeat, |
158 | | -+ SamplerAddressMode::Repeat, |
159 | | -+ SamplerAddressMode::Repeat, |
160 | | -+ 0.0, |
161 | | -+ 1.0, |
162 | | -+ 6.0, |
163 | | -+ 1_000.0) |
164 | | -+ .unwrap() |
| 156 | ++ |
| 157 | ++ let min_lod = 6.0; |
| 158 | ++ // This custom sampler used a min_lod of 6 to display the work we have done in this section |
| 159 | ++ // changing the above variable will change which mipmap is used. |
| 160 | ++ Sampler::new( |
| 161 | ++ device.clone(), |
| 162 | ++ Filter::Linear, |
| 163 | ++ Filter::Linear, |
| 164 | ++ MipmapMode::Linear, |
| 165 | ++ SamplerAddressMode::Repeat, |
| 166 | ++ SamplerAddressMode::Repeat, |
| 167 | ++ SamplerAddressMode::Repeat, |
| 168 | ++ 0.0, |
| 169 | ++ 1.0, |
| 170 | ++ min_lod, |
| 171 | ++ 1_000.0 |
| 172 | ++ ).unwrap() |
165 | 173 | } |
166 | 174 |
|
167 | 175 | fn load_model() -> (Vec<Vertex>, Vec<u32>) { |
0 commit comments