mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-21 14:28:43 -06:00
init texture prefab
This commit is contained in:
parent
90784e21dd
commit
58e4eed14e
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -27,3 +27,7 @@ _visualizer.json
|
|||
*.so
|
||||
*.dylib
|
||||
*.rlib
|
||||
|
||||
#but keep the dxcompiler.dll/dxil.dll
|
||||
!dxcompiler.dll
|
||||
!dxil.dll
|
||||
|
|
|
@ -36,8 +36,10 @@ impl AssetPaths for BlockTexture {
|
|||
}
|
||||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
pub struct BlockDiffuseTexture(pub wgpu::Texture);
|
||||
pub struct Textures {
|
||||
pub block_diffuse_texture: wgpu::Texture,
|
||||
pub block_diffuse_bind_group: wgpu::BindGroup,
|
||||
}
|
||||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
|
@ -50,13 +52,63 @@ pub fn load_prefabs(
|
|||
assman: UniqueView<AssetManager>
|
||||
) {
|
||||
log::info!("Loading textures...");
|
||||
storages.add_unique_non_send_sync(BlockDiffuseTexture(
|
||||
load_texture2darray_prefab::<BlockTexture>(
|
||||
&renderer,
|
||||
&assman,
|
||||
"blocks".into(),
|
||||
)
|
||||
));
|
||||
let block_diffuse_texture = load_texture2darray_prefab::<BlockTexture>(
|
||||
&renderer,
|
||||
&assman,
|
||||
"blocks".into(),
|
||||
);
|
||||
|
||||
log::info!("Creating bing groups");
|
||||
let block_diffuse_view = block_diffuse_texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
let block_diffuse_sampler = renderer.device().create_sampler(&wgpu::SamplerDescriptor {
|
||||
address_mode_u: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_v: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
min_filter: wgpu::FilterMode::Nearest, //TODO min_filter Linear, requires filtering sampler
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
..Default::default()
|
||||
});
|
||||
let block_diffuse_bind_group_layout = renderer.device()
|
||||
.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
label: Some("block_diffuse_bind_group_layout"),
|
||||
entries: &[
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 0,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Texture {
|
||||
sample_type: wgpu::TextureSampleType::Float { filterable: false },
|
||||
view_dimension: wgpu::TextureViewDimension::D2Array,
|
||||
multisampled: false,
|
||||
},
|
||||
count: None,
|
||||
},
|
||||
wgpu::BindGroupLayoutEntry {
|
||||
binding: 1,
|
||||
visibility: wgpu::ShaderStages::FRAGMENT,
|
||||
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::NonFiltering),
|
||||
count: None,
|
||||
}
|
||||
]
|
||||
});
|
||||
let block_diffuse_bind_group = renderer.device().create_bind_group(&wgpu::BindGroupDescriptor {
|
||||
label: Some("block_diffuse_bind_group"),
|
||||
layout: &block_diffuse_bind_group_layout,
|
||||
entries: &[
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 0,
|
||||
resource: wgpu::BindingResource::TextureView(&block_diffuse_view),
|
||||
},
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 1,
|
||||
resource: wgpu::BindingResource::Sampler(&block_diffuse_sampler),
|
||||
}
|
||||
]
|
||||
});
|
||||
storages.add_unique_non_send_sync(Textures {
|
||||
block_diffuse_texture,
|
||||
block_diffuse_bind_group,
|
||||
});
|
||||
|
||||
log::info!("Loading the UI stuff...");
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use pollster::FutureExt;
|
||||
use shipyard::Unique;
|
||||
use winapi::shared::cfg;
|
||||
use winit::{
|
||||
event_loop::ActiveEventLoop,
|
||||
window::{Fullscreen, Window},
|
||||
|
@ -77,6 +78,14 @@ impl Renderer {
|
|||
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: wgpu::Backends::BROWSER_WEBGPU | wgpu::Backends::VULKAN | wgpu::Backends::GL,
|
||||
//Disable validation layer
|
||||
flags: wgpu::InstanceFlags::default() & !wgpu::InstanceFlags::VALIDATION,
|
||||
//we're using vulkan on windows
|
||||
// #[cfg(all(target_os = "windows", target_arch = "x86_64"))]
|
||||
// dx12_shader_compiler: wgpu::Dx12Compiler::Dxc {
|
||||
// dxil_path: Some("./dxil.dll".into()),
|
||||
// dxc_path: Some("./dxcompiler.dll".into()),
|
||||
// },
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue