//! Demonstrates how to write a custom fullscreen shader //! //! This example demonstrates working in 3d. To make the example work in 2d, //! replace 3d components with their 2d counterparts, and schedule the work //! to run in the `Core2d` schedule as described in the `FullscreenMaterial` //! comment in this file. use bevy::{ core_pipeline::fullscreen_material::{FullscreenMaterial, FullscreenMaterialPlugin}, prelude::*, render::{extract_component::ExtractComponent, render_resource::ShaderType, RenderApp}, shader::ShaderRef, }; fn main() { App::new() .add_plugins(( DefaultPlugins, FullscreenMaterialPlugin::::default(), )) .add_systems(Startup, setup) .add_systems(Update, (update_intensity, toggle_effect)) .run(); } fn setup( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { commands.spawn(( Camera3d::default(), Transform::from_translation(Vec3::new(0.0, 0.0, 5.0)).looking_at(Vec3::default(), Vec3::Y), FullscreenEffect::new(0.0), )); commands.spawn(( Mesh3d(meshes.add(Cuboid::default())), MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))), Transform::default(), )); commands.spawn(DirectionalLight { illuminance: 1_000., ..default() }); commands.spawn(( Text::new("(T) FullscreenEffect: On"), Node { position_type: PositionType::Absolute, top: px(12), left: px(12), ..default() }, )); } fn update_intensity( mut effects: Query<&mut FullscreenEffect>, time: Res