diff --git a/src/prefabs.rs b/src/prefabs.rs index 9d2f3ba..f215f50 100644 --- a/src/prefabs.rs +++ b/src/prefabs.rs @@ -1,5 +1,5 @@ use shipyard::{World, NonSendSync, UniqueView, Unique}; -use glium::{texture::SrgbTexture2dArray, Program}; +use glium::{texture::{SrgbTexture2dArray, MipmapsOption}, Program}; use strum::EnumIter; use crate::rendering::Renderer; @@ -61,7 +61,8 @@ pub fn load_prefabs(world: &World) { world.add_unique_non_send_sync(BlockTexturesPrefab( load_texture2darray_prefab::( "./assets/blocks/".into(), - &renderer.display + &renderer.display, + MipmapsOption::AutoGeneratedMipmaps ) )); world.add_unique_non_send_sync(ChunkShaderPrefab( diff --git a/src/prefabs/texture.rs b/src/prefabs/texture.rs index bb1415d..cf2ae4c 100644 --- a/src/prefabs/texture.rs +++ b/src/prefabs/texture.rs @@ -1,7 +1,7 @@ use strum::IntoEnumIterator; use rayon::prelude::*; use std::{fs::File, path::PathBuf, io::BufReader}; -use glium::{texture::{SrgbTexture2dArray, RawImage2d}, backend::Facade}; +use glium::{texture::{SrgbTexture2dArray, RawImage2d, MipmapsOption}, backend::Facade}; use super::AssetPaths; pub fn load_texture2darray_prefab< @@ -9,7 +9,8 @@ pub fn load_texture2darray_prefab< E: Facade >( directory: PathBuf, - facade: &E + facade: &E, + mipmaps: MipmapsOption, ) -> SrgbTexture2dArray { log::info!("↓↓↓ loading textures {} ↓↓↓", directory.as_os_str().to_str().unwrap()); //Load raw images @@ -38,6 +39,6 @@ pub fn load_texture2darray_prefab< }).collect(); log::info!("done loading texture files, uploading to the gpu"); //Upload images to the GPU - SrgbTexture2dArray::new(facade, raw_images) + SrgbTexture2dArray::with_mipmaps(facade, raw_images, mipmaps) .expect("Failed to upload texture array to GPU") } diff --git a/src/rendering.rs b/src/rendering.rs index 334a33e..d20bde5 100644 --- a/src/rendering.rs +++ b/src/rendering.rs @@ -6,7 +6,8 @@ use glium::{ Sampler, SamplerBehavior, MinifySamplerFilter, - MagnifySamplerFilter + MagnifySamplerFilter, + SamplerWrapFunction }, draw_parameters::{ Depth, @@ -89,6 +90,7 @@ pub fn draw_world( minify_filter: MinifySamplerFilter::Linear, magnify_filter: MagnifySamplerFilter::Nearest, max_anisotropy: 8, + wrap_function: (SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp, SamplerWrapFunction::Clamp), ..Default::default() }); let view = camera.view_matrix.to_cols_array_2d();