Skip to content

Commit

Permalink
More material WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
JMS55 committed Oct 24, 2023
1 parent 32083f9 commit 099f1c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{
render, AlphaMode, DrawMesh, DrawPrepass, EnvironmentMapLight, MeshPipeline, MeshPipelineKey,
PrepassPipelinePlugin, PrepassPlugin, RenderMeshInstances, ScreenSpaceAmbientOcclusionSettings,
SetMeshBindGroup, SetMeshViewBindGroup, Shadow, ShadowFilteringMethod,
meshlet::MeshletGpuScene, render, AlphaMode, DrawMesh, DrawPrepass, EnvironmentMapLight,
MeshPipeline, MeshPipelineKey, PrepassPipelinePlugin, PrepassPlugin, RenderMeshInstances,
ScreenSpaceAmbientOcclusionSettings, SetMeshBindGroup, SetMeshViewBindGroup, Shadow,
ShadowFilteringMethod,
};
use bevy_app::{App, Plugin};
use bevy_asset::{Asset, AssetApp, AssetEvent, AssetId, AssetServer, Assets, Handle};
Expand Down Expand Up @@ -297,6 +298,7 @@ where
pub struct MaterialPipeline<M: Material> {
pub mesh_pipeline: MeshPipeline,
pub material_layout: BindGroupLayout,
pub meshlet_layout: Option<BindGroupLayout>,
pub vertex_shader: Option<Handle<Shader>>,
pub fragment_shader: Option<Handle<Shader>>,
pub marker: PhantomData<M>,
Expand All @@ -307,6 +309,7 @@ impl<M: Material> Clone for MaterialPipeline<M> {
Self {
mesh_pipeline: self.mesh_pipeline.clone(),
material_layout: self.material_layout.clone(),
meshlet_layout: self.meshlet_layout.clone(),
vertex_shader: self.vertex_shader.clone(),
fragment_shader: self.fragment_shader.clone(),
marker: PhantomData,
Expand Down Expand Up @@ -341,7 +344,7 @@ where

let _mesh_bind_group = descriptor.layout.pop().unwrap();
descriptor.layout.extend_from_slice(&[
todo!("MesletGpuScene::draw_bind_group_layout()"),
self.meshlet_layout.expect("TODO"),
self.material_layout.clone(),
]);

Expand All @@ -365,6 +368,9 @@ impl<M: Material> FromWorld for MaterialPipeline<M> {
MaterialPipeline {
mesh_pipeline: world.resource::<MeshPipeline>().clone(),
material_layout: M::bind_group_layout(render_device),
meshlet_layout: world
.get_resource::<MeshletGpuScene>()
.map(|gpu_scene| gpu_scene.draw_bind_group_layout().clone()),
vertex_shader: match M::vertex_shader() {
ShaderRef::Default => None,
ShaderRef::Handle(handle) => Some(handle),
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/meshlet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod persistent_buffer;
mod psb_impls;
mod test_material;

pub(crate) use self::gpu_scene::MeshletGpuScene;
pub use self::{
asset::{Meshlet, MeshletBoundingSphere, MeshletMesh},
from_mesh::MeshToMeshletMeshConversionError,
Expand All @@ -19,7 +20,6 @@ use self::{
gpu_scene::{
extract_meshlet_meshes, perform_pending_meshlet_mesh_writes,
prepare_meshlet_per_frame_bind_groups, prepare_meshlet_per_frame_resources,
MeshletGpuScene,
},
test_material::{MeshletTestMaterial, MESHLET_TEST_MATERIAL_SHADER_HANDLE},
};
Expand Down

0 comments on commit 099f1c0

Please sign in to comment.