From 68b779c31f19a79ea9d009cd7b69c02cc894c030 Mon Sep 17 00:00:00 2001 From: MevLyshkin Date: Tue, 28 Jan 2025 06:09:30 +0100 Subject: [PATCH] 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 --- examples/shader/shader_material_2d.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/shader/shader_material_2d.rs b/examples/shader/shader_material_2d.rs index 22bc1732ae..ce092edd11 100644 --- a/examples/shader/shader_material_2d.rs +++ b/examples/shader/shader_material_2d.rs @@ -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) + } }