diff --git a/release-content/0.15/release-notes/14663_shader_storage_buffer.md b/release-content/0.15/release-notes/14663_shader_storage_buffer.md index 4bfa32dfbe..b4c7cb5b7f 100644 --- a/release-content/0.15/release-notes/14663_shader_storage_buffer.md +++ b/release-content/0.15/release-notes/14663_shader_storage_buffer.md @@ -1,36 +1,36 @@ -A new asset `ShaderStorageBuffer` has been added to simplify working with storage buffers in custom materials and compute shaders. Storage buffers are large, GPU-accessible memory buffers designed for storing data that can be read from or written to by shaders. Unlike smaller, more restricted uniform buffers, storage buffers allow you to store large amounts of data, making them perfect for general purpose tasks where large datasets need to be processed. Examples include managing complex data in physics simulations (like particle systems), holding the transformation data for thousands of objects in a scene, or storing procedural geometry information for dynamic terrain generation. Storage buffers are particularly useful when different stages of the rendering pipeline (such as compute shaders and rendering passes) need to share and update large amounts of data efficiently. - -```rust -#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)] -struct CustomMaterial { - #[storage(0, read_only)] - colors: Handle, -} - -fn setup( - mut buffers: ResMut>, - mut materials: ResMut>, -) { - // Example data for the storage buffer - let color_data: Vec<[f32; 4]> = vec![ - [1.0, 0.0, 0.0, 1.0], - [0.0, 1.0, 0.0, 1.0], - [0.0, 0.0, 1.0, 1.0], - [1.0, 1.0, 0.0, 1.0], - [0.0, 1.0, 1.0, 1.0], - ]; - - let colors = buffers.add(ShaderStorageBuffer::from(color_data)); - - // Create the custom material with the storage buffer - let custom_material = CustomMaterial { colors }; - - materials.add(custom_material); -} -``` - -By declaring `Handle` on the material using `AsBindGroup`, this buffer can now be accessed in the shader: - -```wgsl -@group(2) @binding(0) var colors: array, 5>; -``` +A new asset `ShaderStorageBuffer` has been added to simplify working with storage buffers in custom materials and compute shaders. Storage buffers are large, GPU-accessible memory buffers designed for storing data that can be read from or written to by shaders. Unlike smaller, more restricted uniform buffers, storage buffers allow you to store large amounts of data, making them perfect for general purpose tasks where large datasets need to be processed. Examples include managing complex data in physics simulations (like particle systems), holding the transformation data for thousands of objects in a scene, or storing procedural geometry information for dynamic terrain generation. Storage buffers are particularly useful when different stages of the rendering pipeline (such as compute shaders and rendering passes) need to share and update large amounts of data efficiently. + +```rust +#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)] +struct CustomMaterial { + #[storage(0, read_only)] + colors: Handle, +} + +fn setup( + mut buffers: ResMut>, + mut materials: ResMut>, +) { + // Example data for the storage buffer + let color_data: Vec<[f32; 4]> = vec![ + [1.0, 0.0, 0.0, 1.0], + [0.0, 1.0, 0.0, 1.0], + [0.0, 0.0, 1.0, 1.0], + [1.0, 1.0, 0.0, 1.0], + [0.0, 1.0, 1.0, 1.0], + ]; + + let colors = buffers.add(ShaderStorageBuffer::from(color_data)); + + // Create the custom material with the storage buffer + let custom_material = CustomMaterial { colors }; + + materials.add(custom_material); +} +``` + +By declaring `Handle` on the material using `AsBindGroup`, this buffer can now be accessed in the shader: + +```wgsl +@group(2) @binding(0) var colors: array, 5>; +``` diff --git a/release-content/0.15/release-notes/15085_Add_state_scoped_events.md b/release-content/0.15/release-notes/15085_Add_state_scoped_events.md index 07179dc043..944ecf40f8 100644 --- a/release-content/0.15/release-notes/15085_Add_state_scoped_events.md +++ b/release-content/0.15/release-notes/15085_Add_state_scoped_events.md @@ -1,4 +1,18 @@ - +State scoped events will be automatically cleared when exiting a state (similar to [StateScoped entities](https://bevyengine.org/news/bevy-0-14/#state-scoped-entities)). This is useful when you want to guarantee clean state transitions. + +Normally, you would configure your event via: +```rust +fn setup(app: &mut App) { + app.add_event::(); +} +``` + +If you want the events to be cleared when you exit a specific state, change this to: +```rust +fn setup(app: &mut App) { + app.add_state_scoped_event::(GameState::Play); +} +```