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: u8Opacity for BlendMode::AlphaBlend / intensity scale for
BlendMode::Additive; ignored for BlendMode::Opaque.
0 = fully transparent, 255 = fully opaque / full intensity.
mode: BlendModeHow the voxel composites with what is behind it.
emissive: u8Self-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 255 — skipping 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
impl Material
Sourcepub const OPAQUE: Material
pub const OPAQUE: Material
The reserved, fully-opaque material at table id 0 — the
back-compat default for every voxel without explicit material data.
Sourcepub fn alpha_blend(alpha: u8) -> Material
pub fn alpha_blend(alpha: u8) -> Material
An BlendMode::AlphaBlend material with opacity alpha.
Sourcepub fn additive(alpha: u8) -> Material
pub fn additive(alpha: u8) -> Material
An BlendMode::Additive glow material scaled by alpha.
Sourcepub fn glow(emissive: u8) -> Material
pub fn glow(emissive: u8) -> Material
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).
Sourcepub fn with_emissive(self, emissive: u8) -> Material
pub fn with_emissive(self, emissive: u8) -> Material
This material with its emissive set — the
builder for translucent glowing materials.
Sourcepub fn volumetric(alpha: u8) -> Material
pub fn volumetric(alpha: u8) -> Material
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).
Sourcepub fn is_opaque(self) -> bool
pub fn is_opaque(self) -> bool
True for BlendMode::Opaque — the first-hit, fully-occluding path.
Trait Implementations§
impl Copy for Material
impl Eq for Material
impl StructuralPartialEq for Material
Auto Trait Implementations§
impl Freeze for Material
impl RefUnwindSafe for Material
impl Send for Material
impl Sync for Material
impl Unpin for Material
impl UnsafeUnpin for Material
impl UnwindSafe for Material
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more