[−][src]Struct rin::gl::PbrMaterial
A physically based rendering material
Based on several PBR references and papers including the GLTF reference implementation + Filament
With support for:
Standard material
- metallic / roughness pipeline
- normal map
- occlusion map
- emissive map
- base color texture
- base color
- reflectance
- reflectance tint
- double sided
Anistropic material
supports all the features from the standard material and:
- anisotropy
- anisotropy rotation
Clearcoat
supports all the features from the standard material and:
- clearcoat amount
- clearcoat roughness
Subsurface
supports all the features from the standard material and:
- thickness
- subsurface power
- subsurface color
Cloth
- normal map
- occlusion map
- emissive map
- base color texture
- base color
- reflectance
- reflectance tint
- double sided
- sheen
- subsurface color
The filament material guide is a really good reference to understand most of the parameters of this material
Methods
impl PbrMaterial
[src]
impl PbrMaterial
pub fn new() -> PbrMaterial<Program>
[src]
pub fn new() -> PbrMaterial<Program>
New default PBR material with no maps and gray 0.8 color, 0.2 roughness and 0. metallic
pub fn new_with_texture(tex: Texture) -> PbrMaterial<Program>
[src]
pub fn new_with_texture(tex: Texture) -> PbrMaterial<Program>
New default PBR material with a base color texture and gray 0.8 color, 0.2 roughness and 0. metallic
impl<P: Borrow<Program>, T: Borrow<Texture>> PbrMaterial<P, T>
[src]
impl<P: Borrow<Program>, T: Borrow<Texture>> PbrMaterial<P, T>
pub fn ty(&self) -> Type
[src]
pub fn ty(&self) -> Type
Type of the material (standard, anisotropic, clearcoat or cloth)
pub fn set_type(&mut self, ty: Type)
[src]
pub fn set_type(&mut self, ty: Type)
pub fn texture(&self) -> Option<&T>
[src]
pub fn texture(&self) -> Option<&T>
Base color texture
pub fn normal_map(&self) -> Option<&T>
[src]
pub fn normal_map(&self) -> Option<&T>
Normal map
pub fn set_texture<TT: Into<Option<T>>>(&mut self, texture: TT) -> Option<T>
[src]
pub fn set_texture<TT: Into<Option<T>>>(&mut self, texture: TT) -> Option<T>
pub fn set_normal_map<TT: Into<Option<T>>>(&mut self, texture: TT) -> Option<T>
[src]
pub fn set_normal_map<TT: Into<Option<T>>>(&mut self, texture: TT) -> Option<T>
pub fn set_emissive_map<TT: Into<Option<T>>>(
&mut self,
texture: TT
) -> Option<T>
[src]
pub fn set_emissive_map<TT: Into<Option<T>>>(
&mut self,
texture: TT
) -> Option<T>
pub fn set_anisotropy_map<TT: Into<Option<T>>>(
&mut self,
texture: TT
) -> Option<T>
[src]
pub fn set_anisotropy_map<TT: Into<Option<T>>>(
&mut self,
texture: TT
) -> Option<T>
pub fn set_program(&mut self, program: P)
[src]
pub fn set_program(&mut self, program: P)
pub fn set_color<C: ToRgba>(&mut self, color: &C)
[src]
pub fn set_color<C: ToRgba>(&mut self, color: &C)
pub fn color(&self) -> &Rgba<f32>
[src]
pub fn color(&self) -> &Rgba<f32>
Base color
pub fn emissive_color(&self) -> &Rgba<f32>
[src]
pub fn emissive_color(&self) -> &Rgba<f32>
Emissive color
Plain color that the material emits, not affected by light or shadows
pub fn set_emissive_color<C: ToRgba>(&mut self, emissive: &C)
[src]
pub fn set_emissive_color<C: ToRgba>(&mut self, emissive: &C)
pub fn set_subsurface_color<C: ToRgba>(&mut self, color: &C)
[src]
pub fn set_subsurface_color<C: ToRgba>(&mut self, color: &C)
pub fn subsurface_color(&self) -> &Rgba<f32>
[src]
pub fn subsurface_color(&self) -> &Rgba<f32>
Subsurface color, only for subsurface and cloth materials
Non physically based color of the subsurface scattering in cloths and subsurface materials
pub fn set_sheen_color<C: ToRgba>(&mut self, color: &C)
[src]
pub fn set_sheen_color<C: ToRgba>(&mut self, color: &C)
pub fn sheen_color(&self) -> &Rgba<f32>
[src]
pub fn sheen_color(&self) -> &Rgba<f32>
Modify specular reflectance in cloth materials
pub fn metallic(&self) -> f32
[src]
pub fn metallic(&self) -> f32
Level of metallic of this material
Pure metallic materials don't have diffuse reflection, only specular non metallic have white specular and a diffuse reflection of the base color
This values should usually be 0 or 1, intermediate values are usually used when using a metallic map to transition from metallic to non metallic areas
pub fn roughness(&self) -> f32
[src]
pub fn roughness(&self) -> f32
Controls the roughness of the material or how blurry their specular reflection is.
A non metallic material with roughness 1 will appear almost completely diffuse while rouchness 0 will produce a sharp specular reflection
pub fn anisotropy(&self) -> f32
[src]
pub fn anisotropy(&self) -> f32
Defines the amount of anistropic in anisotropic materials
pub fn set_anisotropy(&mut self, anisotropy: f32)
[src]
pub fn set_anisotropy(&mut self, anisotropy: f32)
pub fn anisotropic_rotation(&self) -> Rad<f32>
[src]
pub fn anisotropic_rotation(&self) -> Rad<f32>
Defines the direction of the anisotropy
pub fn set_anisotropic_rotation(&mut self, anisotropic_rotation: Rad<f32>)
[src]
pub fn set_anisotropic_rotation(&mut self, anisotropic_rotation: Rad<f32>)
pub fn clearcoat(&self) -> f32
[src]
pub fn clearcoat(&self) -> f32
Clearcoat materials (like car paint) have a second translucent layer on top of the main material
This value controls if a material has clearcoat or not and should usually be set as 0 or 1
pub fn set_clearcoat(&mut self, clearcoat: f32)
[src]
pub fn set_clearcoat(&mut self, clearcoat: f32)
pub fn clearcoat_roughness(&self) -> f32
[src]
pub fn clearcoat_roughness(&self) -> f32
The roughness of the clearcoat translucent layer
pub fn set_clearcoat_roughness(&mut self, r: f32)
[src]
pub fn set_clearcoat_roughness(&mut self, r: f32)
pub fn double_sided(&self) -> bool
[src]
pub fn double_sided(&self) -> bool
When a material is set as double sided it's back face will be seen as well even when culling is enabled
pub fn set_metallic(&mut self, metallic: f32)
[src]
pub fn set_metallic(&mut self, metallic: f32)
pub fn reflectance(&self) -> f32
[src]
pub fn reflectance(&self) -> f32
Controls the specular reflectance for non metallics which usually is 0.04
This value should be between 0..1
pub fn set_reflectance(&mut self, reflectance: f32)
[src]
pub fn set_reflectance(&mut self, reflectance: f32)
pub fn set_shininess(&mut self, shininess: f32)
[src]
pub fn set_shininess(&mut self, shininess: f32)
Actually sets the roughness based on legacy shininess model
Useful when porting from phong materials
pub fn set_roughness(&mut self, roughness: f32)
[src]
pub fn set_roughness(&mut self, roughness: f32)
pub fn subsurface_power(&self) -> f32
[src]
pub fn subsurface_power(&self) -> f32
pub fn set_subsurface_power(&mut self, power: f32)
[src]
pub fn set_subsurface_power(&mut self, power: f32)
pub fn thickness(&self) -> f32
[src]
pub fn thickness(&self) -> f32
Only for subsurface materials
Defines how thick is the material
pub fn set_thickness(&mut self, thickness: f32)
[src]
pub fn set_thickness(&mut self, thickness: f32)
pub fn reflectance_tint(&self) -> f32
[src]
pub fn reflectance_tint(&self) -> f32
Tint of the diffuse, base color to the specular reflectance
pub fn set_reflectance_tint(&mut self, t: f32)
[src]
pub fn set_reflectance_tint(&mut self, t: f32)
pub fn texture_matrix(&self) -> Option<&Mat4>
[src]
pub fn texture_matrix(&self) -> Option<&Mat4>
pub fn set_texture_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
[src]
pub fn set_texture_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
pub fn set_normal_map_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
[src]
pub fn set_normal_map_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
pub fn set_emissive_map_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
[src]
pub fn set_emissive_map_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
pub fn set_anisotropy_map_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
[src]
pub fn set_anisotropy_map_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
pub fn set_double_sided(&mut self, double_sided: bool)
[src]
pub fn set_double_sided(&mut self, double_sided: bool)
pub fn has_clip_plane(&self) -> bool
[src]
pub fn has_clip_plane(&self) -> bool
To use when we are going to set a clip plane to cut the render at a certain plane
Useful for mirrors, water...
pub fn set_has_clip_plane(&mut self, c: bool)
[src]
pub fn set_has_clip_plane(&mut self, c: bool)
pub fn with_double_sided(
&self,
double_sided: bool
) -> PbrMaterial<&Program, &Texture>
[src]
pub fn with_double_sided(
&self,
double_sided: bool
) -> PbrMaterial<&Program, &Texture>
A reference to this material but double sided
pub fn set_occlusion_map<TT: Into<Option<T>>>(
&mut self,
texture: TT
) -> Option<T>
[src]
pub fn set_occlusion_map<TT: Into<Option<T>>>(
&mut self,
texture: TT
) -> Option<T>
pub fn set_occlusion_map_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
[src]
pub fn set_occlusion_map_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
pub fn set_metallic_roughness_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
[src]
pub fn set_metallic_roughness_matrix<M: Into<Option<Mat4>>>(&mut self, mat: M)
pub fn set_metallic_roughness_map<TT: Into<Option<T>>>(
&mut self,
texture: TT
) -> Option<T>
[src]
pub fn set_metallic_roughness_map<TT: Into<Option<T>>>(
&mut self,
texture: TT
) -> Option<T>
pub fn occlusion_map(&self) -> Option<&T>
[src]
pub fn occlusion_map(&self) -> Option<&T>
Occlusion map
pub fn metallic_roughness_map(&self) -> Option<&T>
[src]
pub fn metallic_roughness_map(&self) -> Option<&T>
pub fn normal_scale(&self) -> f32
[src]
pub fn normal_scale(&self) -> f32
Scales normals
usually used to make the normal map effect more or less pronounced
pub fn set_normal_scale(&mut self, scale: f32)
[src]
pub fn set_normal_scale(&mut self, scale: f32)
pub fn set_alpha_type(&mut self, alpha_type: AlphaType)
[src]
pub fn set_alpha_type(&mut self, alpha_type: AlphaType)
pub fn alpha_type(&self) -> AlphaType
[src]
pub fn alpha_type(&self) -> AlphaType
Alpha type used for this material
See AlphaType
pub fn has_tangents(&self) -> bool
[src]
pub fn has_tangents(&self) -> bool
If the model has precalculated tangents otherwise calculated in shader which could be slower
pub fn set_has_tangents(&mut self, has_tangents: bool)
[src]
pub fn set_has_tangents(&mut self, has_tangents: bool)
pub fn has_separate_alpha(&self) -> bool
[src]
pub fn has_separate_alpha(&self) -> bool
If the alpha will be set on a separate uniform
Useful for materials that change translucency to not reset the whole ubo
pub fn set_has_separate_alpha(&mut self, has_separate_alpha: bool)
[src]
pub fn set_has_separate_alpha(&mut self, has_separate_alpha: bool)
pub fn with_lights<'a, 'l, L, I>(
&'a self,
lights: I
) -> PbrMaterialRef<'a, P, T> where
L: Borrow<&'l dyn Light>,
I: IntoIterator<Item = L>,
[src]
pub fn with_lights<'a, 'l, L, I>(
&'a self,
lights: I
) -> PbrMaterialRef<'a, P, T> where
L: Borrow<&'l dyn Light>,
I: IntoIterator<Item = L>,
Reference to this material with lights and potentially shadows
The resulting material will apply the lights and shadows to any model drawn with it
A pbr material will look completely black unless drawn with lights so calling this method with at least one light is always necesary
pub fn with_lighting_ubo<'l, B, L, I>(
&self,
lights: I,
ubo: B
) -> PbrMaterialRef<P, T> where
B: BufferRange<u8> + Clone,
L: Borrow<&'l dyn Light>,
I: IntoIterator<Item = L>,
[src]
pub fn with_lighting_ubo<'l, B, L, I>(
&self,
lights: I,
ubo: B
) -> PbrMaterialRef<P, T> where
B: BufferRange<u8> + Clone,
L: Borrow<&'l dyn Light>,
I: IntoIterator<Item = L>,
Pass a ubo with the properties of the lights to set the lighting faster
The ubo can be created from the light data but the material also needs the original lights the ubo was created from in order to completely setup the shader
pub fn material_ubo<R: RenderSurface>(
&self,
gl: &Renderer<R>
) -> PbrMaterialRef<P, T>
[src]
pub fn material_ubo<R: RenderSurface>(
&self,
gl: &Renderer<R>
) -> PbrMaterialRef<P, T>
Reference to this material using a ubo to setup properties
pub fn with_camera_ubo<'a>(&'a self) -> PbrMaterialRef<'a, P, T>
[src]
pub fn with_camera_ubo<'a>(&'a self) -> PbrMaterialRef<'a, P, T>
Reference to this material but using the camera uniforms from an ubo
Trait Implementations
impl<P: Borrow<Program>, T: Borrow<Texture>> Material for PbrMaterial<P, T>
[src]
impl<P: Borrow<Program>, T: Borrow<Texture>> Material for PbrMaterial<P, T>
fn program<R: RenderSurface>(&self, renderer: &Renderer<R>) -> &Program
[src]
fn program<R: RenderSurface>(&self, renderer: &Renderer<R>) -> &Program
fn uniforms<R: RenderSurface>(&self, gl: &Renderer<R>) -> &[Uniform]
[src]
fn uniforms<R: RenderSurface>(&self, gl: &Renderer<R>) -> &[Uniform]
fn properties(&self) -> &[Property]
[src]
fn properties(&self) -> &[Property]
impl<Program: Debug, Texture: Debug> Debug for PbrMaterial<Program, Texture>
[src]
impl<Program: Debug, Texture: Debug> Debug for PbrMaterial<Program, Texture>
Auto Trait Implementations
impl<Program, Texture> Send for PbrMaterial<Program, Texture> where
Program: Send,
Texture: Send,
impl<Program, Texture> Send for PbrMaterial<Program, Texture> where
Program: Send,
Texture: Send,
impl<Program = Program, Texture = Texture> !Sync for PbrMaterial<Program, Texture>
impl<Program = Program, Texture = Texture> !Sync for PbrMaterial<Program, Texture>
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T> Any for T where
T: Any,
[src]
impl<T> Any for T where
T: Any,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T> SetParameter for T
[src]
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
[src]
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
Sets value
as a parameter of self
.
impl<V> IntoVec for V
[src]
impl<V> IntoVec for V
impl<V> IntoPnt for V
[src]
impl<V> IntoPnt for V
impl<T> Same for T
[src]
impl<T> Same for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>,
[src]
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
[src]
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
[src]
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
[src]
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
[src]
fn from_subset(element: &SS) -> SP