Add alpha mode implementation to shader_material_2d (#16603)

## Objective 

Bevy 0.15 introduced new method in `Material2d` trait- `alpha_mode`.
Before that when new material was created it had alpha blending, now it
does not.

## Solution 

While I am okay with it, it could be useful to add the new trait method
implementation to one of the samples so users are more aware of it.

---------

Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
This commit is contained in:
MevLyshkin 2025-01-28 06:09:30 +01:00 committed by GitHub
parent 15f00278e7
commit 68b779c31f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,7 +4,7 @@ use bevy::{
prelude::*,
reflect::TypePath,
render::render_resource::{AsBindGroup, ShaderRef},
sprite::{Material2d, Material2dPlugin},
sprite::{AlphaMode2d, Material2d, Material2dPlugin},
};
/// This example uses a shader source file from the assets subdirectory
@ -57,4 +57,8 @@ impl Material2d for CustomMaterial {
fn fragment_shader() -> ShaderRef {
SHADER_ASSET_PATH.into()
}
fn alpha_mode(&self) -> AlphaMode2d {
AlphaMode2d::Mask(0.5)
}
}