pub struct MaterialBuffer<T> { /* private fields */ }
Expand description
This is a chunk of memory that will get bound to all shaders at a particular register slot. StereoKit uses this to provide engine values to the shader, and you can also use this to drive graphical shader systems of your own!
For example, if your application has a custom lighting system, fog, wind, or some other system that multiple shaders might need to refer to, this is the perfect tool to use.
The type ‘T’ for this buffer must be a struct that uses the #[repr(C)] attribute for proper copying. It should also match the layout of your equivalent cbuffer in the shader file. Note that shaders often have specific byte alignment requirements! https://stereokit.net/Pages/StereoKit/MaterialBuffer.html
Implementations§
Source§impl<T> MaterialBuffer<T>
impl<T> MaterialBuffer<T>
Sourcepub fn new(register_slot: i32) -> MaterialBuffer<T>
pub fn new(register_slot: i32) -> MaterialBuffer<T>
Create a new global MaterialBuffer bound to the register slot id. All shaders will have access to the data provided via this instance’s Set. https://stereokit.net/Pages/StereoKit/MaterialBuffer/MaterialBuffer.html
register_slot
- Valid values are 3-16. This is the register id that this data will be bound to. In HLSL, you’ll see the slot id for ‘3’ indicated like this : register(b3)
see also material_buffer_create
Sourcepub fn set(&self, in_data: *mut T)
pub fn set(&self, in_data: *mut T)
This will upload your data to the GPU for shaders to use. https://stereokit.net/Pages/StereoKit/MaterialBuffer/Set.html
see also material_buffer_set_data
Trait Implementations§
Source§impl<T> AsRef<MaterialBuffer<T>> for MaterialBuffer<T>
impl<T> AsRef<MaterialBuffer<T>> for MaterialBuffer<T>
Source§fn as_ref(&self) -> &MaterialBuffer<T>
fn as_ref(&self) -> &MaterialBuffer<T>
Auto Trait Implementations§
impl<T> Freeze for MaterialBuffer<T>
impl<T> RefUnwindSafe for MaterialBuffer<T>where
T: RefUnwindSafe,
impl<T> !Send for MaterialBuffer<T>
impl<T> !Sync for MaterialBuffer<T>
impl<T> Unpin for MaterialBuffer<T>where
T: Unpin,
impl<T> UnwindSafe for MaterialBuffer<T>where
T: UnwindSafe,
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
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.