#[repr(C)]pub struct InstanceData {
pub model_matrix: [[f32; 4]; 4],
pub material_params: [[f32; 4]; 4],
}Expand description
Per-instance data packed for GPU instanced rendering. Each instance gets a transform matrix and material parameters.
Fields§
§model_matrix: [[f32; 4]; 4]Model matrix (4x4, column-major, 16 floats).
material_params: [[f32; 4]; 4]Packed material parameters.
[0] = albedo.r, albedo.g, albedo.b, alpha
[1] = metallic, roughness, emission_intensity, material_id (as float)
[2] = emission.r, emission.g, emission.b,
Implementations§
Source§impl InstanceData
impl InstanceData
Sourcepub fn new(transform: &Mat4, material: &PbrMaterial) -> Self
pub fn new(transform: &Mat4, material: &PbrMaterial) -> Self
Create instance data from a transform and material.
Sourcepub fn from_transform(transform: &Mat4) -> Self
pub fn from_transform(transform: &Mat4) -> Self
Create instance data with just a transform (default material params).
Sourcepub fn set_albedo(&mut self, r: f32, g: f32, b: f32)
pub fn set_albedo(&mut self, r: f32, g: f32, b: f32)
Set the albedo color.
Sourcepub fn set_metallic_roughness(&mut self, metallic: f32, roughness: f32)
pub fn set_metallic_roughness(&mut self, metallic: f32, roughness: f32)
Set metallic/roughness.
Sourcepub fn set_material_id(&mut self, id: u8)
pub fn set_material_id(&mut self, id: u8)
Set the material ID.
Sourcepub fn glsl_instance_attributes() -> &'static str
pub fn glsl_instance_attributes() -> &'static str
Generate GLSL vertex attribute declarations for instanced rendering.
Trait Implementations§
Source§impl Clone for InstanceData
impl Clone for InstanceData
Source§fn clone(&self) -> InstanceData
fn clone(&self) -> InstanceData
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InstanceData
impl Debug for InstanceData
Source§impl Default for InstanceData
impl Default for InstanceData
impl Copy for InstanceData
Auto Trait Implementations§
impl Freeze for InstanceData
impl RefUnwindSafe for InstanceData
impl Send for InstanceData
impl Sync for InstanceData
impl Unpin for InstanceData
impl UnsafeUnpin for InstanceData
impl UnwindSafe for InstanceData
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.