pub struct MaterialLoader;Expand description
Asset loader for material descriptor files (.mat.json).
Parses a JSON descriptor into a MaterialAsset and declares
shader and texture dependencies via LoadContext.
§JSON Format
{
"name": "brick_wall",
"shader_path": "shaders/pbr.glsl",
"uniforms": {
"roughness": { "type": "Float", "value": 0.7 },
"base_color": { "type": "Vec4", "value": [0.8, 0.3, 0.1, 1.0] }
},
"texture_slots": {
"albedo": "textures/brick_albedo.png",
"normal": "textures/brick_normal.png"
}
}§Example
use goud_engine::assets::{AssetServer, loaders::material::{MaterialLoader, MaterialAsset}};
let mut server = AssetServer::new();
server.register_loader(MaterialLoader::default());
let handle = server.load::<MaterialAsset>("materials/brick.mat.json");Implementations§
Trait Implementations§
Source§impl AssetLoader for MaterialLoader
impl AssetLoader for MaterialLoader
Source§type Asset = MaterialAsset
type Asset = MaterialAsset
The type of asset this loader produces.
Source§fn extensions(&self) -> &[&str]
fn extensions(&self) -> &[&str]
Returns the file extensions supported by this loader. Read more
Source§fn load<'a>(
&'a self,
bytes: &'a [u8],
_settings: &'a Self::Settings,
context: &'a mut LoadContext<'_>,
) -> Result<Self::Asset, AssetLoadError>
fn load<'a>( &'a self, bytes: &'a [u8], _settings: &'a Self::Settings, context: &'a mut LoadContext<'_>, ) -> Result<Self::Asset, AssetLoadError>
Loads an asset from raw bytes. Read more
Source§impl Clone for MaterialLoader
impl Clone for MaterialLoader
Source§fn clone(&self) -> MaterialLoader
fn clone(&self) -> MaterialLoader
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 MaterialLoader
impl Debug for MaterialLoader
Source§impl Default for MaterialLoader
impl Default for MaterialLoader
Source§fn default() -> MaterialLoader
fn default() -> MaterialLoader
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MaterialLoader
impl RefUnwindSafe for MaterialLoader
impl Send for MaterialLoader
impl Sync for MaterialLoader
impl Unpin for MaterialLoader
impl UnsafeUnpin for MaterialLoader
impl UnwindSafe for MaterialLoader
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<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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>
Converts
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>
Converts
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 moreSource§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
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().