remove autoload
This commit is contained in:
parent
ca040e96ec
commit
999e86224a
3 changed files with 10 additions and 32 deletions
|
|
@ -5,9 +5,14 @@
|
|||
|
||||
@fragment
|
||||
fn fragment(mesh: VertexOutput) -> @location(0) vec4<f32> {
|
||||
let bottom = vec3<f32>(1.0, 0.8, 0.2); // warm
|
||||
let top = vec3<f32>(0.2, 0.6, 1.0); // cool
|
||||
var uv = mesh.uv * 2 - 1;
|
||||
uv.x = uv.x * (u_resolution.x / u_resolution.y);
|
||||
|
||||
let color = mix(bottom, top, mesh.uv.y);
|
||||
return vec4<f32>(color, 1.0);
|
||||
let red = vec3<f32>(1, 0, 0);
|
||||
let blue = vec3<f32>(0, 0, 1.0);
|
||||
|
||||
let t = step(0.5, length(uv));
|
||||
|
||||
let color = mix(red, blue, t);
|
||||
return vec4<f32>(color, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ fn main() {
|
|||
Update,
|
||||
(
|
||||
material::update_material_time,
|
||||
material::shader_hot_reload,
|
||||
systems::resize_fullscreen_quad,
|
||||
systems::exit_app.run_if(input_just_pressed(KeyCode::Escape)),
|
||||
systems::toggle_fullscreen.run_if(input_just_pressed(KeyCode::F11)),
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use bevy::{
|
||||
asset::AssetEvent,
|
||||
prelude::*,
|
||||
reflect::TypePath,
|
||||
render::render_resource::{AsBindGroup, Shader, ShaderRef},
|
||||
render::render_resource::{AsBindGroup, ShaderRef},
|
||||
sprite::{AlphaMode2d, Material2d},
|
||||
};
|
||||
|
||||
|
|
@ -24,31 +23,6 @@ pub fn update_material_time(mut materials: ResMut<Assets<CustomMaterial>>, time:
|
|||
}
|
||||
}
|
||||
|
||||
/// Listen for shader asset changes and force materials to update so the new shader is used.
|
||||
pub fn shader_hot_reload(
|
||||
mut shader_events: EventReader<AssetEvent<Shader>>,
|
||||
mut materials: ResMut<Assets<CustomMaterial>>,
|
||||
) {
|
||||
let mut reload_needed = false;
|
||||
for event in shader_events.read() {
|
||||
match event {
|
||||
AssetEvent::Modified { .. } => {
|
||||
reload_needed = true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
if reload_needed {
|
||||
// iterate all materials and 'touch' them so Bevy updates bindings using the recompiled shader
|
||||
for (_handle, material) in materials.iter_mut() {
|
||||
// assign to itself to mark changed
|
||||
let cloned = material.clone();
|
||||
*material = cloned;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Material2d for CustomMaterial {
|
||||
fn fragment_shader() -> ShaderRef {
|
||||
DEFAULT_SHADER_PATH.into()
|
||||
|
|
|
|||
Loading…
Reference in a new issue