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: Self
pub const OPAQUE: Self
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) -> Self
pub fn alpha_blend(alpha: u8) -> Self
An BlendMode::AlphaBlend material with opacity alpha.
Sourcepub fn additive(alpha: u8) -> Self
pub fn additive(alpha: u8) -> Self
An BlendMode::Additive glow material scaled by alpha.
Sourcepub fn glow(emissive: u8) -> Self
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).
Sourcepub fn with_emissive(self, emissive: u8) -> Self
pub fn with_emissive(self, emissive: u8) -> Self
This material with its emissive set — the
builder for translucent glowing materials.
Sourcepub fn volumetric(alpha: u8) -> Self
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).
Sourcepub fn is_opaque(self) -> bool
pub fn is_opaque(self) -> bool
True for BlendMode::Opaque — the first-hit, fully-occluding path.