AlphaMode

Enum AlphaMode 

Source
pub enum AlphaMode {
    Opaque,
    Mask(f32),
    Blend,
}
Expand description

Specifies how a material handles transparency and alpha blending.

This enum is critical for the rendering system to make intelligent decisions about render pass ordering and pipeline selection. Different alpha modes have significant performance implications:

  • Opaque: Fastest, no transparency calculations
  • Mask: Fast, no sorting required, uses alpha testing
  • Blend: Slowest, requires depth sorting for correct rendering

§Examples

use khora_core::asset::AlphaMode;

// Opaque material (default for most objects)
let opaque = AlphaMode::Opaque;

// Alpha masking (e.g., foliage, chain-link fences)
let masked = AlphaMode::Mask(0.5); // Discard pixels with alpha < 0.5

// Full blending (e.g., glass, water)
let blended = AlphaMode::Blend;

Variants§

§

Opaque

The material is fully opaque with no transparency.

This is the default and most performant mode. Fragments are always written to the framebuffer without alpha testing or blending.

§

Mask(f32)

The material uses alpha testing to create binary transparency.

Fragments with an alpha value below the specified threshold are discarded. This mode is useful for rendering vegetation, chain-link fences, or other objects with hard transparency edges. It’s significantly faster than Blend because it doesn’t require depth sorting.

The f32 value is the alpha cutoff threshold (typically 0.5).

§

Blend

The material uses full alpha blending.

This mode produces smooth transparency but requires objects to be rendered in back-to-front order for correct results. The RenderAgent may choose different rendering strategies based on the number of blend-mode objects in the scene to balance quality and performance.

Trait Implementations§

Source§

impl Clone for AlphaMode

Source§

fn clone(&self) -> AlphaMode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AlphaMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AlphaMode

Source§

fn default() -> AlphaMode

Returns the “default value” for a type. Read more
Source§

impl PartialEq for AlphaMode

Source§

fn eq(&self, other: &AlphaMode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for AlphaMode

Source§

impl StructuralPartialEq for AlphaMode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.