Struct GpuMaterial
pub struct GpuMaterial {Show 16 fields
pub uniform_buffer: BufferId,
pub base_color_view: Option<TextureViewId>,
pub metallic_roughness_view: Option<TextureViewId>,
pub normal_view: Option<TextureViewId>,
pub emissive_view: Option<TextureViewId>,
pub occlusion_view: Option<TextureViewId>,
pub base_color_texture: Option<TextureId>,
pub metallic_roughness_texture: Option<TextureId>,
pub normal_texture: Option<TextureId>,
pub emissive_texture: Option<TextureId>,
pub occlusion_texture: Option<TextureId>,
pub sampler: SamplerId,
pub bind_group: BindGroupId,
pub variant: ShaderVariantKey,
pub double_sided: bool,
pub blend: bool,
}Expand description
A GPU-ready representation of a material: its uniform buffer, the PBR texture views it declares, the shared sampler, and a ready-to-bind group-2 bind group.
Built once per material UUID by the data-layer projection (mirroring
GpuMesh), cached, and consumed by every lit lane —
which selects the pipeline for variant and binds bind_group at
group 2. Each texture view is Some only for a map the material
declares (no fallback textures); the variant records
exactly that set of HAS_* flags, so the bind group, the group-2 layout
it was built against, and the lit pipeline’s group-2 layout all resolve
from the same (LayoutKey::Material, variant).
Each declared map is uploaded as a texture private to this material (the
projection does not share GPU textures across materials), so the material
exclusively owns its uniform_buffer, its four *_texture /
*_view handles, and its bind_group. The sampler is the opposite:
it is the engine-shared filtering sampler. This ownership split is what
asset eviction relies on to free the resources — it destroys everything
but the shared sampler when the material is reclaimed. The *_texture
and matching *_view fields are always Some/None together.
Fields§
§uniform_buffer: BufferIdMaterialUniforms uniform buffer (base color, factors, …).
base_color_view: Option<TextureViewId>Base-color (albedo) texture view, if declared.
metallic_roughness_view: Option<TextureViewId>Metallic-roughness texture view (B=metallic, G=roughness), if declared.
normal_view: Option<TextureViewId>Tangent-space normal texture view, if declared.
emissive_view: Option<TextureViewId>Emissive texture view, if declared.
occlusion_view: Option<TextureViewId>Ambient-occlusion texture view, if declared.
base_color_texture: Option<TextureId>Base-color texture backing base_color_view,
owned by this material and freed on eviction.
metallic_roughness_texture: Option<TextureId>Metallic-roughness texture backing
metallic_roughness_view.
normal_texture: Option<TextureId>Normal texture backing normal_view.
emissive_texture: Option<TextureId>Emissive texture backing emissive_view.
occlusion_texture: Option<TextureId>Ambient-occlusion texture backing occlusion_view.
sampler: SamplerIdFiltering sampler shared by all maps (engine-owned; NOT freed on eviction).
bind_group: BindGroupIdPrebuilt group-2 bind group bound by lit lanes.
variant: ShaderVariantKeyShader variant (HAS_* texture flags) this material was built for.
The lit lane requests the matching pipeline and groups draws by it.
double_sided: boolWhether the material renders double-sided (back faces not culled). The
lit lane selects a no-cull pipeline for it; single-sided materials cull
back faces. Part of the pipeline cache key via [PipelineKey].
blend: boolWhether the material is alpha-blended (AlphaMode::Blend).
Blended materials need a different pipeline state (alpha blending on,
depth writes off) and a different draw order: the lit lane defers
them to a second, back-to-front sorted batch after the opaque draws,
because blending is order-dependent. AlphaMode::Mask is not blended
— it discards in the shader and stays in the opaque batch.
Implementations§
§impl GpuMaterial
impl GpuMaterial
pub fn bindings(&self) -> MaterialGpuBindings
pub fn bindings(&self) -> MaterialGpuBindings
Returns the [MaterialGpuBindings] view of this material’s
resources, suitable for
fill_material_bind_group_entries.
Trait Implementations§
§impl Clone for GpuMaterial
impl Clone for GpuMaterial
§fn clone(&self) -> GpuMaterial
fn clone(&self) -> GpuMaterial
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for GpuMaterial
impl Debug for GpuMaterial
impl Asset for GpuMaterial
Auto Trait Implementations§
impl Freeze for GpuMaterial
impl RefUnwindSafe for GpuMaterial
impl Send for GpuMaterial
impl Sync for GpuMaterial
impl Unpin for GpuMaterial
impl UnsafeUnpin for GpuMaterial
impl UnwindSafe for GpuMaterial
Blanket Implementations§
§impl<T> AppLifecycle for Twhere
T: ?Sized,
impl<T> AppLifecycle for Twhere
T: ?Sized,
§fn on_start(&mut self, ctx: &mut dyn AppContext)
fn on_start(&mut self, ctx: &mut dyn AppContext)
update. Apps install their theme / fonts here.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§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>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§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.§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.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.