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 calculationsMask: Fast, no sorting required, uses alpha testingBlend: 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.