@@ -3,8 +3,8 @@ use std::borrow::Cow;
33use std:: sync:: Arc ;
44
55use bevy:: platform:: collections:: hash_map:: Entry ;
6- use wesl:: syntax:: { ModulePath , PathOrigin } ;
76use wesl:: PkgResolver ;
7+ use wesl:: syntax:: { ModulePath , PathOrigin } ;
88
99wesl:: wesl_pkg!( processing) ;
1010wesl:: wesl_pkg!( lygia) ;
@@ -13,19 +13,20 @@ use bevy::{
1313 asset:: { AsAssetId , AssetEventSystems } ,
1414 core_pipeline:: core_3d:: Opaque3d ,
1515 ecs:: system:: {
16- lifetimeless:: { SRes , SResMut } ,
1716 SystemParamItem ,
17+ lifetimeless:: { SRes , SResMut } ,
1818 } ,
19- material:: { key:: ErasedMeshPipelineKey , MaterialProperties } ,
19+ material:: { MaterialProperties , key:: ErasedMeshPipelineKey } ,
2020 pbr:: {
21- base_specialize , DrawMaterial , EntitiesNeedingSpecialization , MainPassOpaqueDrawFunction ,
21+ DrawMaterial , EntitiesNeedingSpecialization , MainPassOpaqueDrawFunction ,
2222 MaterialBindGroupAllocator , MaterialBindGroupAllocators , MaterialFragmentShader ,
23- MaterialVertexShader , MeshPipelineKey , PreparedMaterial , RenderMaterialBindings , RenderMaterialInstance ,
24- RenderMaterialInstances ,
23+ MaterialVertexShader , MeshPipelineKey , PreparedMaterial , RenderMaterialBindings ,
24+ RenderMaterialInstance , RenderMaterialInstances , base_specialize ,
2525 } ,
2626 prelude:: * ,
27- reflect:: { structs :: Struct , PartialReflect , ReflectMut , ReflectRef } ,
27+ reflect:: { PartialReflect , ReflectMut , ReflectRef , structs :: Struct } ,
2828 render:: {
29+ Extract , RenderApp , RenderStartup ,
2930 camera:: { DirtySpecializationSystems , DirtySpecializations } ,
3031 erased_render_asset:: { ErasedRenderAsset , ErasedRenderAssetPlugin , PrepareAssetError } ,
3132 render_asset:: RenderAssets ,
@@ -34,7 +35,6 @@ use bevy::{
3435 renderer:: RenderDevice ,
3536 sync_world:: MainEntity ,
3637 texture:: GpuImage ,
37- Extract , RenderApp , RenderStartup ,
3838 } ,
3939} ;
4040
@@ -191,7 +191,11 @@ pub fn create_custom(
191191 Ok ( commands. spawn ( UntypedMaterial ( handle. untyped ( ) ) ) . id ( ) )
192192}
193193
194- pub fn set_property ( material : & mut CustomMaterial , name : & str , value : & MaterialValue ) -> Result < ( ) > {
194+ pub fn set_property (
195+ material : & mut CustomMaterial ,
196+ name : & str ,
197+ value : & MaterialValue ,
198+ ) -> Result < ( ) > {
195199 let reflect_value: Box < dyn PartialReflect > = material_value_to_reflect ( value) ?;
196200
197201 if let Some ( field) = material. shader . field_mut ( name) {
@@ -229,7 +233,7 @@ fn material_value_to_reflect(value: &MaterialValue) -> Result<Box<dyn PartialRef
229233 MaterialValue :: Texture ( _) => {
230234 return Err ( ProcessingError :: UnknownMaterialProperty (
231235 "Texture properties not yet supported for custom materials" . to_string ( ) ,
232- ) )
236+ ) ) ;
233237 }
234238 } )
235239}
@@ -326,7 +330,8 @@ impl ErasedRenderAsset for CustomMaterial {
326330 let bind_group_layout =
327331 BindGroupLayoutDescriptor :: new ( "custom_material_bind_group" , & layout_entries) ;
328332
329- let bindings = reflection. create_bindings ( 3 , & source_asset. shader , render_device, gpu_images) ;
333+ let bindings =
334+ reflection. create_bindings ( 3 , & source_asset. shader , render_device, gpu_images) ;
330335
331336 let unprepared = UnpreparedBindGroup {
332337 bindings : BindingResources ( bindings) ,
@@ -348,9 +353,7 @@ impl ErasedRenderAsset for CustomMaterial {
348353 . insert ( bind_group_allocator. allocate_unprepared ( unprepared, & bind_group_layout) ) ,
349354 } ;
350355
351- let draw_function = opaque_draw_functions
352- . read ( )
353- . id :: < DrawMaterial > ( ) ;
356+ let draw_function = opaque_draw_functions. read ( ) . id :: < DrawMaterial > ( ) ;
354357
355358 let mut properties = MaterialProperties {
356359 mesh_pipeline_key_bits : ErasedMeshPipelineKey :: new ( MeshPipelineKey :: empty ( ) ) ,
@@ -406,9 +409,7 @@ fn extract_custom_materials_needing_specialization(
406409 mut dirty : ResMut < DirtySpecializations > ,
407410) {
408411 for entity in entities. changed . iter ( ) {
409- dirty
410- . changed_renderables
411- . insert ( MainEntity :: from ( * entity) ) ;
412+ dirty. changed_renderables . insert ( MainEntity :: from ( * entity) ) ;
412413 }
413414}
414415
@@ -417,9 +418,7 @@ fn extract_custom_materials_that_need_specializations_removed(
417418 mut dirty : ResMut < DirtySpecializations > ,
418419) {
419420 for entity in entities. removed . iter ( ) {
420- dirty
421- . removed_renderables
422- . insert ( MainEntity :: from ( * entity) ) ;
421+ dirty. removed_renderables . insert ( MainEntity :: from ( * entity) ) ;
423422 }
424423}
425424
0 commit comments