diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-21 22:59:01 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-21 22:59:01 +0100 |
commit | a3621790a6f4466daab0f38f5eaf57fe064b2e92 (patch) | |
tree | cb4d6ef53a65abdd87969cbbf6ad4c9a54b54225 /client/src/scene_render.rs | |
parent | 12bf2f3302efc9042f12ca17104928c35700c229 (diff) | |
download | weareserver-a3621790a6f4466daab0f38f5eaf57fe064b2e92.tar weareserver-a3621790a6f4466daab0f38f5eaf57fe064b2e92.tar.bz2 weareserver-a3621790a6f4466daab0f38f5eaf57fe064b2e92.tar.zst |
more work on armature
Diffstat (limited to 'client/src/scene_render.rs')
-rw-r--r-- | client/src/scene_render.rs | 87 |
1 files changed, 54 insertions, 33 deletions
diff --git a/client/src/scene_render.rs b/client/src/scene_render.rs index 3698ff7..77217d6 100644 --- a/client/src/scene_render.rs +++ b/client/src/scene_render.rs @@ -36,50 +36,72 @@ pub struct ScenePipeline { pipeline_no_cull: RenderPipeline, } +pub struct SceneBgLayouts { + pub texture: BindGroupLayout, + pub material: BindGroupLayout, + pub joints: BindGroupLayout, +} + impl ScenePipeline { - pub fn new(device: &Device, format: TextureFormat) -> (Self, BindGroupLayout, BindGroupLayout) { + pub fn new(device: &Device, format: TextureFormat) -> (Self, SceneBgLayouts) { let fragment_pbr = device.create_shader_module(include_wgsl!("shaders/fragment_pbr.wgsl")); let vertex_world = device.create_shader_module(include_wgsl!("shaders/vertex_world.wgsl")); let _vertex_world_skin = device.create_shader_module(include_wgsl!("shaders/vertex_world_skin.wgsl")); - let texture_bgl = device.create_bind_group_layout(&BindGroupLayoutDescriptor { - entries: &[ - BindGroupLayoutEntry { + let layouts = SceneBgLayouts { + texture: device.create_bind_group_layout(&BindGroupLayoutDescriptor { + entries: &[ + BindGroupLayoutEntry { + binding: 0, + count: None, + visibility: ShaderStages::FRAGMENT, + ty: BindingType::Texture { + sample_type: TextureSampleType::Float { filterable: true }, + view_dimension: TextureViewDimension::D2, + multisampled: false, + }, + }, + BindGroupLayoutEntry { + binding: 1, + count: None, + visibility: ShaderStages::FRAGMENT, + ty: BindingType::Sampler(SamplerBindingType::Filtering), + }, + ], + label: None, + }), + material: device.create_bind_group_layout(&BindGroupLayoutDescriptor { + entries: &[BindGroupLayoutEntry { binding: 0, count: None, visibility: ShaderStages::FRAGMENT, - ty: BindingType::Texture { - sample_type: TextureSampleType::Float { filterable: true }, - view_dimension: TextureViewDimension::D2, - multisampled: false, + ty: BindingType::Buffer { + ty: BufferBindingType::Uniform, + has_dynamic_offset: false, + min_binding_size: None, }, - }, - BindGroupLayoutEntry { - binding: 1, + }], + label: None, + }), + joints: device.create_bind_group_layout(&BindGroupLayoutDescriptor { + entries: &[BindGroupLayoutEntry { + binding: 0, count: None, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Sampler(SamplerBindingType::Filtering), - }, - ], - label: None, - }); - let material_bgl = device.create_bind_group_layout(&BindGroupLayoutDescriptor { - entries: &[BindGroupLayoutEntry { - binding: 0, - count: None, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Buffer { - ty: BufferBindingType::Uniform, - has_dynamic_offset: false, - min_binding_size: None, - }, - }], - label: None, - }); + visibility: ShaderStages::VERTEX, + ty: BindingType::Buffer { + ty: BufferBindingType::Uniform, + has_dynamic_offset: false, + min_binding_size: None, + }, + }], + label: None, + }), + }; + let pipeline_layout = device.create_pipeline_layout(&PipelineLayoutDescriptor { label: None, - bind_group_layouts: &[&texture_bgl, &texture_bgl, &material_bgl], + bind_group_layouts: &[&layouts.texture, &layouts.texture, &layouts.material], push_constant_ranges: &[PushConstantRange { range: 0..((4 * 4 + 3 * 4) * size_of::<f32>() as u32), stages: ShaderStages::VERTEX, @@ -170,8 +192,7 @@ impl ScenePipeline { pipeline, pipeline_no_cull, }, - texture_bgl, - material_bgl, + layouts, ) } |