//https://github.com/bevyengine/bevy/blob/latest/examples/asset/processing/asset_processing.rs //https://www.youtube.com/watch?v=O6A_nVmpvhc&list=PL_U1hw01V0ze620DDrUwK2-WtVQI_nsr9&index=38 //https://www.youtube.com/watch?v=i4zImwo_flw&t=5s //https://www.youtube.com/watch?v=mGRC567ooAM&list=PL_U1hw01V0ze620DDrUwK2-WtVQI_nsr9&index=38 /* Applying Bevy 0.8 Custom Materials to GLTF scenes imports*/ use bevy::{ pbr::{MaterialPipeline, MaterialPipelineKey}, prelude::*, reflect::TypeUuid, render::{ mesh::{ MeshVertexBufferLayout, VertexAttributeValues, }, render_resource::{ AsBindGroup, Face, RenderPipelineDescriptor, ShaderRef, SpecializedMeshPipelineError, }, }, scene::SceneInstance, }; use bevy_shader_utils::ShaderUtilsPlugin; mod map_loader; use map_loader::*; //bevy::prelude::*; use roxmltree::*; #derive(AsBindGroup, Debug, Clone, TypeUuid)] #[uuid = "717f64fe-6844-4822-8926-e0ed374294c8"] pub struct GlowMaterial { #[texture(0)] #[sampler(1)] pub env_texture: Option>, } impl Material for GlowMaterial { fn fragment_shader() -> ShaderRef { "shaders/glow.wgsl".into() } } fn setup( mut commands: Commands, mut meshes: ResMut>, glowmaterials: ResMut>, mut materials: ResMut>, asset_server: Res>, ) { //Load Texture let env_texture = asset_server.load("textures_stone_alley_02_1k.hdr"); let material = glowmaterials.add(GlowMaterial { env_texture: Some(env_texture), }); //Sphere commands.spawn().insert_bundle(MaterialMeshBundle { mesh: meshes.add(Mesh::from(shape::UVSphere { radius: 1.0, ..default() })), material: material.clone(), ..default() }); } fn main() { App::new() .insert_resource({ }) .add_plugins((DefaultPlugins.set(plugin: AssetPlugin { mode: Asset::default(), ) .add_startup_system(setup) .add_system(change_color) .add_system(mod_scene) .add_systems(schedule: Startup, systems: setup) &mut App .add_systems(shedule: Update, systems: hello_assets) &mut App .run(); } #[derive(Component)] struct GLTFScene; #[derive(Component)] struct Inserted; //set up a simple 3d scene fn CustomMaterialGLTFSceneSetup(mut commands: Commands, asset_server: Res) { commands .spawn_bundle(SceneBundle { scene: asset_server.load( "hex-sphere-5-subdivisions.glb#Scene0" ), ..default() }) .insert(GLTFScene); commands.spawn_bundle(Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0) .looking_at(Vec3::ZERO, Vec3::Y), ..default() }); } fn change_color( mut materials: ResMut>, time: Res