//! Allows configuring a material's transparency behavior.12use bevy_reflect::{std_traits::ReflectDefault, Reflect};34// TODO: add discussion about performance.5/// Sets how a material's base color alpha channel is used for transparency.6#[derive(Debug, Default, Reflect, Copy, Clone, PartialEq)]7#[reflect(Default, Debug, Clone)]8pub enum AlphaMode {9/// Base color alpha values are overridden to be fully opaque (1.0).10#[default]11Opaque,12/// Reduce transparency to fully opaque or fully transparent13/// based on a threshold.14///15/// Compares the base color alpha value to the specified threshold.16/// If the value is below the threshold,17/// considers the color to be fully transparent (alpha is set to 0.0).18/// If it is equal to or above the threshold,19/// considers the color to be fully opaque (alpha is set to 1.0).20Mask(f32),21/// The base color alpha value defines the opacity of the color.22/// Standard alpha-blending is used to blend the fragment's color23/// with the color behind it.24Blend,25/// Similar to [`AlphaMode::Blend`], however assumes RGB channel values are26/// [premultiplied](https://en.wikipedia.org/wiki/Alpha_compositing#Straight_versus_premultiplied).27///28/// For otherwise constant RGB values, behaves more like [`AlphaMode::Blend`] for29/// alpha values closer to 1.0, and more like [`AlphaMode::Add`] for30/// alpha values closer to 0.0.31///32/// Can be used to avoid “border” or “outline” artifacts that can occur33/// when using plain alpha-blended textures.34Premultiplied,35/// Spreads the fragment out over a hardware-dependent number of sample36/// locations proportional to the alpha value. This requires multisample37/// antialiasing; if MSAA isn't on, this is identical to38/// [`AlphaMode::Mask`] with a value of 0.5.39///40/// Alpha to coverage provides improved performance and better visual41/// fidelity over [`AlphaMode::Blend`], as Bevy doesn't have to sort objects42/// when it's in use. It's especially useful for complex transparent objects43/// like foliage.44///45/// [alpha to coverage]: https://en.wikipedia.org/wiki/Alpha_to_coverage46AlphaToCoverage,47/// Combines the color of the fragments with the colors behind them in an48/// additive process, (i.e. like light) producing lighter results.49///50/// Black produces no effect. Alpha values can be used to modulate the result.51///52/// Useful for effects like holograms, ghosts, lasers and other energy beams.53Add,54/// Combines the color of the fragments with the colors behind them in a55/// multiplicative process, (i.e. like pigments) producing darker results.56///57/// White produces no effect. Alpha values can be used to modulate the result.58///59/// Useful for effects like stained glass, window tint film and some colored liquids.60Multiply,61}6263impl Eq for AlphaMode {}646566