mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 08:18:43 -06:00
add mipmaps and spcify wrap function on sampler
This commit is contained in:
parent
5f06c85279
commit
8f1821a8f5
|
@ -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::<BlockTextures, _>(
|
||||
"./assets/blocks/".into(),
|
||||
&renderer.display
|
||||
&renderer.display,
|
||||
MipmapsOption::AutoGeneratedMipmaps
|
||||
)
|
||||
));
|
||||
world.add_unique_non_send_sync(ChunkShaderPrefab(
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue