Skip to main content

Material

Struct Material 

Source
pub struct Material {
    pub alpha: u8,
    pub mode: BlendMode,
    pub emissive: u8,
}
Expand description

One material: an opacity and a blend mode, indexed out of a MaterialTable by a per-voxel material id.

Fields§

§alpha: u8

Opacity for BlendMode::AlphaBlend / intensity scale for BlendMode::Additive; ignored for BlendMode::Opaque. 0 = fully transparent, 255 = fully opaque / full intensity.

§mode: BlendMode

How the voxel composites with what is behind it.

§emissive: u8

Self-emission (EV stage): 0 = a normal lit voxel; anything greater renders the voxel at albedo × ((128 + (emissive >> 1)) / 128) — from ~1.0× up to ~2.0× over-bright at 255skipping the baked brightness byte, per-face side shades, the dynamic light rig, shadows and cel bands (fog still applies). Orthogonal to mode: an BlendMode::AlphaBlend crystal can glow through its own translucency. Emission onto surrounding voxels is separate — that is the lightmode-2 point-light bake (BakeMode::PointLights in roxlap-scene), not this field.

Implementations§

Source§

impl Material

Source

pub const OPAQUE: Self

The reserved, fully-opaque material at table id 0 — the back-compat default for every voxel without explicit material data.

Source

pub fn alpha_blend(alpha: u8) -> Self

An BlendMode::AlphaBlend material with opacity alpha.

Source

pub fn additive(alpha: u8) -> Self

An BlendMode::Additive glow material scaled by alpha.

Source

pub fn glow(emissive: u8) -> Self

An opaque emissive material (EV stage): renders at albedo × ((128 + (emissive >> 1)) / 128) regardless of baked lighting, side shades, the dynamic rig or shadows. Combine with a translucent mode via with_emissive (e.g. Material::alpha_blend(160).with_emissive(255) for a glowing crystal).

Source

pub fn with_emissive(self, emissive: u8) -> Self

This material with its emissive set — the builder for translucent glowing materials.

Source

pub fn volumetric(alpha: u8) -> Self

A BlendMode::Volumetric (Beer–Lambert) material whose alpha is the per-voxel-unit absorption — opacity accrues with the ray’s path length through filled volumes (smoke/fog/murky water).

Source

pub fn is_opaque(self) -> bool

True for BlendMode::Opaque — the first-hit, fully-occluding path.

Trait Implementations§

Source§

impl Clone for Material

Source§

fn clone(&self) -> Material

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Material

Source§

impl Debug for Material

Source§

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

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

impl Default for Material

Source§

fn default() -> Self

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

impl Eq for Material

Source§

impl PartialEq for Material

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Material

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.