Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
Material Class Reference

Represent a surface material, including textures describing the surface parameters. More...

#include <Material.hpp>

Public Types

enum  Type : int {
  None = 0 , Regular , Parallax , Clearcoat ,
  Anisotropic , Sheen , Iridescent , Subsurface ,
  Emissive , Transparent , TransparentIrid
}
 Type of shading/effects. More...
 

Public Member Functions

 Material ()=default
 
 Material (Type type)
 
void addTexture (const Texture *infos)
 
void addParameter (const glm::vec4 &param)
 
const std::vector< const Texture * > & textures () const
 
const std::vector< glm::vec4 > & parameters () const
 
const Typetype () const
 
bool twoSided () const
 
bool masked () const
 
const std::string & name () const
 
bool decode (const KeyValues &params, Storage options)
 
virtual KeyValues encode () const
 
virtual ~Material ()=default
 
 Material (const Material &)=delete
 
Materialoperator= (const Material &)=delete
 
 Material (Material &&)=default
 
Materialoperator= (Material &&)=default
 

Protected Attributes

std::vector< const Texture * > _textures
 Textures used by the material.
 
std::vector< glm::vec4 > _parameters
 Parameters used by the material.
 
std::string _name
 The material name.
 
Type _material = Type::None
 The material type.
 
bool _twoSided = false
 Should faces of objects be visible from the two sides.
 
bool _masked = false
 The material uses alpha cutout.
 

Detailed Description

Represent a surface material, including textures describing the surface parameters.

Different predefined materials can be used, with predefined parameters stored in ordered textures.

Regular: GGX material, dielectric or conductor.

Parallax: GGX material with parallax occlusion mapping.

Clearcoat: GGX material with an additional dielectric transparent layer overlayed top.

Anisotropic: GGX material with anisotropic specular behavior.

Sheen: Cloth-like material, assumed to be a dielectric.

Iridescent: GGX material with thin-film interferences on the surface.

Subsurface: Dieletric GGX material with subsurface scattering/transmission.

Emissive: light emitting material, assume to be optionally covered by a transparent dielectric

Transparent: transparent object with a dieletric surface

TransparentIrid: transparent object with a dieletric surface and thin film interferences

None: any parameters can be specified depending on the shader used in the renderer code.

Member Enumeration Documentation

◆ Type

enum Material::Type : int

Type of shading/effects.

Enumerator
None 

Any type of shading.

Regular 

PBR shading.

Parallax 

PBR with parallax mapping.

Clearcoat 

PBR shading with an additional clear coat specular layer.

Anisotropic 

PBR shading with an anisotropic BRDF.

Sheen 

PBR shading with a sheen BRDF.

Iridescent 

PBR shading with iridescent Fresnel.

Subsurface 

PBR shading with subsurface scattering.

Emissive 

Emissive objects (no diffuse shading).

Transparent 

Transparent object.

TransparentIrid 

Transparent object with iridescent Fresnel.

Constructor & Destructor Documentation

◆ Material() [1/4]

Material::Material ( )
default

Constructor

◆ Material() [2/4]

Material::Material ( Type  type)

Construct a new material.

Parameters
typethe type of shading and effects associated with this material

◆ ~Material()

virtual Material::~Material ( )
virtualdefault

Destructor.

◆ Material() [3/4]

Material::Material ( const Material )
delete

Copy constructor.

◆ Material() [4/4]

Material::Material ( Material &&  )
default

Move constructor.

Member Function Documentation

◆ addParameter()

void Material::addParameter ( const glm::vec4 &  param)

Register a new parameter.

Parameters
paramthe values to add

◆ addTexture()

void Material::addTexture ( const Texture infos)

Register a texture.

Parameters
infosthe texture infos to add

◆ decode()

bool Material::decode ( const KeyValues params,
Storage  options 
)

Setup a material parameters from a list of key-value tuples. The following keywords will be searched for:

type: materialtype
twosided: bool
masked: bool
textures:
    - texturetype: ...
    - ...
parameters:
   - R,G,B,A
   - ...
Parameters
paramsthe parameters tuple
optionsdata loading and storage options
Returns
decoding status

◆ encode()

KeyValues Material::encode ( ) const
virtual

Generate a key-values representation of the material. See decode for the keywords and layout.

Returns
a tuple representing the material.

◆ masked()

bool Material::masked ( ) const
inline

Should an alpha clip mask be applied when rendering the surface (for leaves or chains for instance).

Returns
a boolean denoting if masking should be applied

◆ name()

const std::string & Material::name ( ) const
inline
Returns
the name of the material

◆ operator=() [1/2]

Material & Material::operator= ( const Material )
delete

Copy assignment.

Returns
a reference to the material assigned to

◆ operator=() [2/2]

Material & Material::operator= ( Material &&  )
default

Move assignment.

Returns
a reference to the material assigned to

◆ parameters()

const std::vector< glm::vec4 > & Material::parameters ( ) const
inline

Parameters array getter.

Returns
a vector containing the parameters associated to the material

◆ textures()

const std::vector< const Texture * > & Material::textures ( ) const
inline

Textures array getter.

Returns
a vector containing the textures associated to the material

◆ twoSided()

bool Material::twoSided ( ) const
inline

Is the surface from both sides.

Returns
a boolean denoting if the surface has two sides

◆ type()

const Type & Material::type ( ) const
inline

Type getter.

Returns
the type of material
Note
This can be used in different way by different applications.

The documentation for this class was generated from the following files: