API Documentation
Public Member Functions | Static Public Member Functions | List of all members
nkAstraeus::PbsMaterial Class Referencefinal

A Physically Based Shading material. More...

Inheritance diagram for nkAstraeus::PbsMaterial:
nkAstraeus::Material nkExport::Exportable

Public Member Functions

 PbsMaterial (System *system) noexcept
 
virtual ~PbsMaterial ()
 
nkMemory::StringView getPositionAttributeName () const
 
nkMemory::StringView getTexCoordAttributeName () const
 
nkMemory::StringView getNormalAttributeName () const
 
nkMemory::StringView getTangentAttributeName () const
 
nkMemory::StringView getBinormalAttributeName () const
 
nkMaths::Vector getLightDirection () const
 
nkMaths::Vector getLightColor () const
 
nkMaths::Vector getAlbedoColor () const
 
nkMaths::Vector getSpecularColor () const
 
nkMaths::Vector getEmissiveColor () const
 
nkMaths::Vector getEnvironmentColor () const
 
float getMetalness () const
 
float getRoughnessGlossiness () const
 
float getAlpha () const
 
nkGraphics::TexturegetAlbedoTexture () const
 
nkGraphics::TexturegetSpecularTexture () const
 
nkGraphics::TexturegetEmissiveTexture () const
 
nkGraphics::TexturegetMetalnessTexture () const
 
nkGraphics::TexturegetRoughnessGlossinessTexture () const
 
nkGraphics::TexturegetAlphaTexture () const
 
nkGraphics::TexturegetOcclusionTexture () const
 
nkGraphics::TexturegetNormalMapTexture () const
 
nkGraphics::TexturegetEnvironmentTexture () const
 
nkGraphics::TexturegetIrradianceTexture () const
 
THREE_CHANNEL_PACK getAlbedoTextureChannels () const
 
THREE_CHANNEL_PACK getSpecularTextureChannels () const
 
THREE_CHANNEL_PACK getEmissiveTextureChannels () const
 
ONE_CHANNEL_PACK getMetalnessTextureChannels () const
 
ONE_CHANNEL_PACK getRoughnessGlossinessTextureChannels () const
 
ONE_CHANNEL_PACK getAlphaTextureChannels () const
 
ONE_CHANNEL_PACK getOcclusionTextureChannels () const
 
THREE_CHANNEL_PACK getNormalMapTextureChannels () const
 
THREE_CHANNEL_PACK getEnvironmentTextureChannels () const
 
THREE_CHANNEL_PACK getIrradianceTextureChannels () const
 
nkGraphics::TexturegetShadowMapTexture () const
 
nkGraphics::CameragetShadowMapCamera () const
 
const ShadowMapParametersgetShadowMapParameters () const
 
PBS_MODEL getPbsModel () const
 
bool getEnvironmentTextureIsCubeByDefault () const
 
bool getIrradianceTextureIsCubeByDefault () const
 
bool getReconstructBinormals () const
 
bool getMixAlbedoColorAndTexture () const
 
bool getMixSpecularColorAndTexture () const
 
bool getMixEmissiveColorAndTexture () const
 
bool getMixMetalnessFactorAndTexture () const
 
bool getMixRoughnessGlossinessFactorAndTexture () const
 
bool getMixEnvironmentColorAndTexture () const
 
bool getMixAlphaFactorAndTexture () const
 
void setPositionAttributeName (nkMemory::StringView value)
 
void setTexCoordAttributeName (nkMemory::StringView value)
 
void setNormalAttributeName (nkMemory::StringView value)
 
void setTangentAttributeName (nkMemory::StringView value)
 
void setBinormalAttributeName (nkMemory::StringView value)
 
void setLightDirection (const nkMaths::Vector &value)
 
void setLightColor (const nkMaths::Vector &value)
 
void setAlbedoColor (const nkMaths::Vector &value)
 
void setSpecularColor (const nkMaths::Vector &value)
 
void setEmissiveColor (const nkMaths::Vector &value)
 
void setEnvironmentColor (const nkMaths::Vector &value)
 
void setMetalness (float value)
 
void setRoughnessGlossiness (float value)
 
void setAlpha (float value)
 
void setAlbedoTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB)
 
void setSpecularTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB)
 
void setEmissiveTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB)
 
void setMetalnessTexture (nkGraphics::Texture *value, ONE_CHANNEL_PACK channel=ONE_CHANNEL_PACK::A)
 
void setRoughnessGlossinessTexture (nkGraphics::Texture *value, ONE_CHANNEL_PACK channel=ONE_CHANNEL_PACK::A)
 
void setAlphaTexture (nkGraphics::Texture *value, ONE_CHANNEL_PACK channel=ONE_CHANNEL_PACK::A)
 
void setOcclusionTexture (nkGraphics::Texture *value, ONE_CHANNEL_PACK channel=ONE_CHANNEL_PACK::A)
 
void setNormalMapTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB)
 
void setEnvironmentTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB, bool prefilteredEnv=false)
 
void setIrradianceTexture (nkGraphics::Texture *value, THREE_CHANNEL_PACK channels=THREE_CHANNEL_PACK::RGB)
 
void setShadowMapTexture (nkGraphics::Texture *value, nkGraphics::Camera *shadowCamera, const ShadowMapParameters &parameters=ShadowMapParameters())
 
void setPbsModel (PBS_MODEL value)
 
void setEnvironmentTextureIsCubeByDefault (bool value)
 
void setIrradianceTextureIsCubeByDefault (bool value)
 
void setReconstructBinormals (bool value)
 
void setMixAlbedoColorAndTexture (bool value)
 
void setMixSpecularColorAndTexture (bool value)
 
void setMixEmissiveColorAndTexture (bool value)
 
void setMixMetalnessFactorAndTexture (bool value)
 
void setMixRoughnessGlossinessFactorAndTexture (bool value)
 
void setMixEnvironmentColorAndTexture (bool value)
 
void setMixAlphaFactorAndTexture (bool value)
 
virtual bool load () override
 
virtual void unload () override
 
virtual void exportClassToTree (nkExport::Node *rootNode) override
 
virtual void importClassFromTree (nkExport::Node *rootNode) override
 
- Public Member Functions inherited from nkAstraeus::Material
 Material (MATERIAL_TYPE type) noexcept
 
virtual ~Material ()
 
nkMemory::StringView getName () const
 
nkGraphics::ShadergetShader () const
 
MATERIAL_TYPE getType () const
 
void setName (nkMemory::StringView value)
 
- Public Member Functions inherited from nkExport::Exportable
 Exportable () noexcept
 
virtual ~Exportable ()
 

Static Public Member Functions

static nkMemory::UniquePtr< PbsMaterialcreate (System *system=nullptr)
 

Detailed Description

A Physically Based Shading material.

This material aims to represent surfaces using physically plausible equations. It became a standard over the years, thanks to the limited number of parameters it requires, while offering pleasant results.

Constructor & Destructor Documentation

◆ PbsMaterial()

nkAstraeus::PbsMaterial::PbsMaterial ( System system)
noexcept

Constructor.

Parameters
systemThe system the resource should live in.

◆ ~PbsMaterial()

virtual nkAstraeus::PbsMaterial::~PbsMaterial ( )
virtual

Destructor.

Member Function Documentation

◆ getPositionAttributeName()

nkMemory::StringView nkAstraeus::PbsMaterial::getPositionAttributeName ( ) const
Returns
The name of the attribute used as position.

◆ getTexCoordAttributeName()

nkMemory::StringView nkAstraeus::PbsMaterial::getTexCoordAttributeName ( ) const
Returns
The name of the attribute used as texture coordinate, if necessary.

◆ getNormalAttributeName()

nkMemory::StringView nkAstraeus::PbsMaterial::getNormalAttributeName ( ) const
Returns
The name of the attribute used as normal.

◆ getTangentAttributeName()

nkMemory::StringView nkAstraeus::PbsMaterial::getTangentAttributeName ( ) const
Returns
The name of the attribute used as tangent, if necessary.

◆ getBinormalAttributeName()

nkMemory::StringView nkAstraeus::PbsMaterial::getBinormalAttributeName ( ) const
Returns
The name of the attribute used as binormal, if necessary.

◆ getLightDirection()

nkMaths::Vector nkAstraeus::PbsMaterial::getLightDirection ( ) const
Returns
The currently set light direction.

◆ getLightColor()

nkMaths::Vector nkAstraeus::PbsMaterial::getLightColor ( ) const
Returns
The currently set light color.

◆ getAlbedoColor()

nkMaths::Vector nkAstraeus::PbsMaterial::getAlbedoColor ( ) const
Returns
The currently set constant albedo color.

◆ getSpecularColor()

nkMaths::Vector nkAstraeus::PbsMaterial::getSpecularColor ( ) const
Returns
The currently set constant specular color.

◆ getEmissiveColor()

nkMaths::Vector nkAstraeus::PbsMaterial::getEmissiveColor ( ) const
Returns
The currently set constant emissive color.

◆ getEnvironmentColor()

nkMaths::Vector nkAstraeus::PbsMaterial::getEnvironmentColor ( ) const
Returns
The currently set constant environment color.

◆ getMetalness()

float nkAstraeus::PbsMaterial::getMetalness ( ) const
Returns
The currently set constant metalness value.

◆ getRoughnessGlossiness()

float nkAstraeus::PbsMaterial::getRoughnessGlossiness ( ) const
Returns
The currently set constant roughness / glossiness value.

◆ getAlpha()

float nkAstraeus::PbsMaterial::getAlpha ( ) const
Returns
The currently set constant alpha value.

◆ getAlbedoTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getAlbedoTexture ( ) const
Returns
The currently set albedo texture.

◆ getSpecularTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getSpecularTexture ( ) const
Returns
The currently set specular texture.

◆ getEmissiveTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getEmissiveTexture ( ) const
Returns
The currently set emissive texture.

◆ getMetalnessTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getMetalnessTexture ( ) const
Returns
The currently set metalness texture.

◆ getRoughnessGlossinessTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getRoughnessGlossinessTexture ( ) const
Returns
The currently set roughness / glossiness texture.

◆ getAlphaTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getAlphaTexture ( ) const
Returns
The currently set alpha texture.

◆ getOcclusionTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getOcclusionTexture ( ) const
Returns
The currently set occlusion texture.

◆ getNormalMapTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getNormalMapTexture ( ) const
Returns
The currently set normal map texture.

◆ getEnvironmentTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getEnvironmentTexture ( ) const
Returns
The currently set environment texture.

◆ getIrradianceTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getIrradianceTexture ( ) const
Returns
The currently set irradiance texture.

◆ getAlbedoTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getAlbedoTextureChannels ( ) const
Returns
The currently used channels from the albedo texture.

◆ getSpecularTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getSpecularTextureChannels ( ) const
Returns
The currently used channels from the specular texture.

◆ getEmissiveTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getEmissiveTextureChannels ( ) const
Returns
The currently used channels from the emissive texture.

◆ getMetalnessTextureChannels()

ONE_CHANNEL_PACK nkAstraeus::PbsMaterial::getMetalnessTextureChannels ( ) const
Returns
The currently used channel from the metalness texture.

◆ getRoughnessGlossinessTextureChannels()

ONE_CHANNEL_PACK nkAstraeus::PbsMaterial::getRoughnessGlossinessTextureChannels ( ) const
Returns
The currently used channel from the roughness / glossiness texture.

◆ getAlphaTextureChannels()

ONE_CHANNEL_PACK nkAstraeus::PbsMaterial::getAlphaTextureChannels ( ) const
Returns
The currently used channel from the alpha texture.

◆ getOcclusionTextureChannels()

ONE_CHANNEL_PACK nkAstraeus::PbsMaterial::getOcclusionTextureChannels ( ) const
Returns
The currently used channel from the occlusion texture.

◆ getNormalMapTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getNormalMapTextureChannels ( ) const
Returns
The currently used channels from the normal map texture.

◆ getEnvironmentTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getEnvironmentTextureChannels ( ) const
Returns
The currently used channels from the environment texture.

◆ getIrradianceTextureChannels()

THREE_CHANNEL_PACK nkAstraeus::PbsMaterial::getIrradianceTextureChannels ( ) const
Returns
The currently used channels from the irradiance texture.

◆ getShadowMapTexture()

nkGraphics::Texture* nkAstraeus::PbsMaterial::getShadowMapTexture ( ) const
Returns
The currently used shadow map texture.

◆ getShadowMapCamera()

nkGraphics::Camera* nkAstraeus::PbsMaterial::getShadowMapCamera ( ) const
Returns
The currently used shadow map camera.

◆ getShadowMapParameters()

const ShadowMapParameters& nkAstraeus::PbsMaterial::getShadowMapParameters ( ) const
Returns
The currently used shadow map parameters.

◆ getPbsModel()

PBS_MODEL nkAstraeus::PbsMaterial::getPbsModel ( ) const
Returns
The currently used PBS model.

◆ getEnvironmentTextureIsCubeByDefault()

bool nkAstraeus::PbsMaterial::getEnvironmentTextureIsCubeByDefault ( ) const
Returns
Whether unloaded environment textures are expected as cube maps (true) or not (false).

◆ getIrradianceTextureIsCubeByDefault()

bool nkAstraeus::PbsMaterial::getIrradianceTextureIsCubeByDefault ( ) const
Returns
Whether unloaded irradiance textures are expected as cube maps (true) or not (false).

◆ getReconstructBinormals()

bool nkAstraeus::PbsMaterial::getReconstructBinormals ( ) const
Returns
Whether the binormals are recontructed during rendering (true) or if they are coming from the vertex buffers (false).

◆ getMixAlbedoColorAndTexture()

bool nkAstraeus::PbsMaterial::getMixAlbedoColorAndTexture ( ) const
Returns
Whether the albedo color will be mixed with its texture value (true) or not (false).

◆ getMixSpecularColorAndTexture()

bool nkAstraeus::PbsMaterial::getMixSpecularColorAndTexture ( ) const
Returns
Whether the specular color will be mixed with its texture value (true) or not (false).

◆ getMixEmissiveColorAndTexture()

bool nkAstraeus::PbsMaterial::getMixEmissiveColorAndTexture ( ) const
Returns
Whether the emissive color will be mixed with its texture value (true) or not (false).

◆ getMixMetalnessFactorAndTexture()

bool nkAstraeus::PbsMaterial::getMixMetalnessFactorAndTexture ( ) const
Returns
Whether the metalness factor will be mixed with its texture value (true) or not (false).

◆ getMixRoughnessGlossinessFactorAndTexture()

bool nkAstraeus::PbsMaterial::getMixRoughnessGlossinessFactorAndTexture ( ) const
Returns
Whether the roughness / glossiness factor will be mixed with its texture value (true) or not (false).

◆ getMixEnvironmentColorAndTexture()

bool nkAstraeus::PbsMaterial::getMixEnvironmentColorAndTexture ( ) const
Returns
Whether the environment (irradiance) color will be mixed with its texture value (true) or not (false).

◆ getMixAlphaFactorAndTexture()

bool nkAstraeus::PbsMaterial::getMixAlphaFactorAndTexture ( ) const
Returns
Whether the alpha factor will be mixed with its texture value (true) or not (false).

◆ setPositionAttributeName()

void nkAstraeus::PbsMaterial::setPositionAttributeName ( nkMemory::StringView  value)

Sets the name of the attribute that should be used as position.

Parameters
valueThe name of the attribute to use.
Remarks
Defaults to "POSITION". This parameter needs a reload of the material to apply, if the material is already loaded.

◆ setTexCoordAttributeName()

void nkAstraeus::PbsMaterial::setTexCoordAttributeName ( nkMemory::StringView  value)

Sets the name of the attribute that should be used as texture coordinate, if necessary.

Parameters
valueThe name of the attribute to use.
Remarks
Defaults to "TEXCOORD". This parameter needs a reload of the material to apply, if the material is already loaded.

◆ setNormalAttributeName()

void nkAstraeus::PbsMaterial::setNormalAttributeName ( nkMemory::StringView  value)

Sets the name of the attribute that should be used as normal.

Parameters
valueThe name of the attribute to use.
Remarks
Defaults to "NORMAL". This parameter needs a reload of the material to apply, if the material is already loaded.

◆ setTangentAttributeName()

void nkAstraeus::PbsMaterial::setTangentAttributeName ( nkMemory::StringView  value)

Sets the name of the attribute that should be used as tangent, if necessary.

Parameters
valueThe name of the attribute to use.
Remarks
Defaults to "TANGENT". This parameter needs a reload of the material to apply, if the material is already loaded.

◆ setBinormalAttributeName()

void nkAstraeus::PbsMaterial::setBinormalAttributeName ( nkMemory::StringView  value)

Sets the name of the attribute that should be used as binormal, if necessary.

Parameters
valueThe name of the attribute to use.
Remarks
Defaults to "BINORMAL". This parameter needs a reload of the material to apply, if the material is already loaded.

◆ setLightDirection()

void nkAstraeus::PbsMaterial::setLightDirection ( const nkMaths::Vector value)

Sets the light direction to use within the material. Currently, the only type of light supported is directional.

Parameters
valueThe direction of the light.
Remarks
This parameter is not used if an environment texture is set.

◆ setLightColor()

void nkAstraeus::PbsMaterial::setLightColor ( const nkMaths::Vector value)

Sets the color to use for the directional light when it is active.

Parameters
valueThe light color.
Remarks
This parameter is not used if an environment texture is set.

◆ setAlbedoColor()

void nkAstraeus::PbsMaterial::setAlbedoColor ( const nkMaths::Vector value)

Sets the constant albedo (diffuse) color to use on the whole surface.

Parameters
valueThe albedo color to use.

◆ setSpecularColor()

void nkAstraeus::PbsMaterial::setSpecularColor ( const nkMaths::Vector value)

Sets the constant specular (reflections) color to use on the whole surface.

Parameters
valueThe specular color to use.

◆ setEmissiveColor()

void nkAstraeus::PbsMaterial::setEmissiveColor ( const nkMaths::Vector value)

Sets the constant emissive color to use on the whole surface.

Parameters
valueThe emissive color to use.

◆ setEnvironmentColor()

void nkAstraeus::PbsMaterial::setEnvironmentColor ( const nkMaths::Vector value)

Sets a constant environment color. Can be seen as an ambient lighting.

Parameters
valueThe color to use.
Remarks
This parameter is not used if an environment texture is set.

◆ setMetalness()

void nkAstraeus::PbsMaterial::setMetalness ( float  value)

Sets the metalness of the material. Metalness is a factor between [0.0, 1.0], encoding how metallic the material should be. At 0, the material is dialectric, while at 1, it's fully metallic. Globally, at higher metallic level, the material will be more reflective.

Parameters
valueThe constant metalness to use on the whole surface.

◆ setRoughnessGlossiness()

void nkAstraeus::PbsMaterial::setRoughnessGlossiness ( float  value)

Sets the roughness or glossiness of the material, depending on the PBS model chosen. Roughness / glossiness is a factor between [0.0, 1.0], encoding how rough / glossy the material should be. As roughness, at 0, the material is very smooth, while at 1, it is full of small rough patches. Low roughness values mean that the material will have clear reflections. As it goes higher, the reflections get blurrier. For glossiness, the opposite applies (glossier means smoother).

Parameters
valueThe constant roughness to use on the whole surface.

◆ setAlpha()

void nkAstraeus::PbsMaterial::setAlpha ( float  value)

Sets the alpha of the material. Alpha is a factor between [0.0, 1.0], encoding how the rendered material should be blended during painting. At 0, the material is fully transparent, while at 1 it is fully opaque.

Parameters
valueThe constant alpha to use on the whole surface.
Remarks
This parameter requires to use an adapted BlendState within the RenderScenePass, enabling blending.

◆ setAlbedoTexture()

void nkAstraeus::PbsMaterial::setAlbedoTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB 
)

Sets the albedo (diffuse) color to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
Remarks
When changing the data channels, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setSpecularTexture()

void nkAstraeus::PbsMaterial::setSpecularTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB 
)

Sets the specular (reflections) color to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
Remarks
When changing the data channels, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setEmissiveTexture()

void nkAstraeus::PbsMaterial::setEmissiveTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB 
)

Sets the emissive color to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
Remarks
When changing the data channels, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setMetalnessTexture()

void nkAstraeus::PbsMaterial::setMetalnessTexture ( nkGraphics::Texture value,
ONE_CHANNEL_PACK  channel = ONE_CHANNEL_PACK::A 
)

Sets the metalness to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use.
channelThe texture channel the data is encoded in. Defaults to sampling the A channel.
Remarks
When changing the data channel, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setRoughnessGlossinessTexture()

void nkAstraeus::PbsMaterial::setRoughnessGlossinessTexture ( nkGraphics::Texture value,
ONE_CHANNEL_PACK  channel = ONE_CHANNEL_PACK::A 
)

Sets the roughness / glossiness to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use.
channelThe texture channel the data is encoded in. Defaults to sampling the A channel.
Remarks
When changing the data channel, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setAlphaTexture()

void nkAstraeus::PbsMaterial::setAlphaTexture ( nkGraphics::Texture value,
ONE_CHANNEL_PACK  channel = ONE_CHANNEL_PACK::A 
)

Sets the alpha to use by using a texture that will be sampled using meshes texture coordinates.

Parameters
valueThe texture to use.
channelThe texture channel the data is encoded in. Defaults to sampling the A channel.
Remarks
When changing the data channel, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

This parameter requires to use an adapted BlendState within the RenderScenePass, enabling blending.

◆ setOcclusionTexture()

void nkAstraeus::PbsMaterial::setOcclusionTexture ( nkGraphics::Texture value,
ONE_CHANNEL_PACK  channel = ONE_CHANNEL_PACK::A 
)

Sets the occlusion map to use. Occlusion should range from [0.0, 1.0], encoding occluded (dark, 0) to non occluded (light, 1) regions. This occlusion data will be mixed with the albedo and ambient to drive the overall diffuse lighting.

Parameters
valueThe texture to use.
channelThe texture channel the data is encoded in. Defaults to sampling the A channel.
Remarks
When changing the data channel, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setNormalMapTexture()

void nkAstraeus::PbsMaterial::setNormalMapTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB 
)

Sets the normal map texture to use for normal mapping. Normal mapping at least requires tangents to be provided by the meshes to render. Binormals will be reconstructed unless told otherwise through a call to setReconstructBinormals(false).

Parameters
valueThe texture to use as the normal map.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
Remarks
When changing the data channels, a material reload is needed. Updating a texture on the fly can be done with the material loaded, provided it is not shared across multiple parameters.

◆ setEnvironmentTexture()

void nkAstraeus::PbsMaterial::setEnvironmentTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB,
bool  prefilteredEnv = false 
)

Sets the environment map to use. Giving a texture enables the Image Based Lighting functionality of the material for specular reflections. The texture can be either :

  • A 2D spherical map
  • A cube map

If the texture is unloaded when the material's load() method is called, the assumed texture type will be the one given by the setEnvironmentTextureIsCubeByDefault() function.

Parameters
valueThe texture to use as the environment.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
prefilteredEnvWhether the texture given is prefiltered (true) or not (false). If true, the material will use the split-sum optimization to improve performances.
Remarks
When changing the data channels or the prefiltered boolean, a material reload is needed. Updating a texture on the fly can be done with the material loaded. As the environment map is never considered as shared, this is true at all times.
To prefilter maps and benefit from the performances improvements, see PbsEnvMapFilter class.

◆ setIrradianceTexture()

void nkAstraeus::PbsMaterial::setIrradianceTexture ( nkGraphics::Texture value,
THREE_CHANNEL_PACK  channels = THREE_CHANNEL_PACK::RGB 
)

Sets the irradiance map to use. Irradiance corresponds to the diffuse lighting from the environment, the average light incoming on the surface for any given direction. The texture can be either :

  • A 2D spherical map
  • A cube map

If the texture is unloaded when the material's load() method is called, the assumed texture type will be the one given by the setIrradianceTextureIsCubeByDefault() function.

Parameters
valueThe texture to use as the irradiance map.
channelsThe texture channels the data is encoded in. Defaults to sample the RGB channels.
Remarks
When changing the data channels, a material reload is needed. Updating a texture on the fly can be done with the material loaded. As the irradiance map is never considered as shared, this is true at all times.

◆ setShadowMapTexture()

void nkAstraeus::PbsMaterial::setShadowMapTexture ( nkGraphics::Texture value,
nkGraphics::Camera shadowCamera,
const ShadowMapParameters parameters = ShadowMapParameters() 
)

Sets the shadow map to use within the material.

Parameters
valueThe map to use. It should be compatible with comparison sampling.
shadowCameraThe camera used to generate given map.
parametersMethod parameters to tweak the effect's rendering.
Remarks
If the shadow map feature was off, a material reload is needed in all cases. Else, the texture and camera can be updated on the fly, but changing any other parameter requires a material reload.

◆ setPbsModel()

void nkAstraeus::PbsMaterial::setPbsModel ( PBS_MODEL  value)

Sets the PBS model to use to light the material. This will impact the rendering and the parameter used :

Changing this parameter can change how a parameter is interpreted, such as the roughness, which can also be interpreted as the glossiness in dedicated model.

Parameters
valueThe model to use.
Remarks
When changing this parameter, a material reload is needed. By default, this parameter is using the PBS_MODEL::SPECULAR_METALNESS_ROUGHNESS value.

◆ setEnvironmentTextureIsCubeByDefault()

void nkAstraeus::PbsMaterial::setEnvironmentTextureIsCubeByDefault ( bool  value)

Sets whether the environment texture given should be expected as a cube map or not, when it is unloaded while the material is loading.

Parameters
valueWhether an unloaded texture should be expected as a cube map (true) or not (false).
Remarks
When changing this parameter, a material reload is needed. By default, the parameter is on.

◆ setIrradianceTextureIsCubeByDefault()

void nkAstraeus::PbsMaterial::setIrradianceTextureIsCubeByDefault ( bool  value)

Sets whether the irradiance texture given should be expected as a cube map or not, when it is unloaded while the material is loading.

Parameters
valueWhether an unloaded texture should be expected as a cube map (true) or not (false).
Remarks
When changing this parameter, a material reload is needed. By default, the parameter is on.

◆ setReconstructBinormals()

void nkAstraeus::PbsMaterial::setReconstructBinormals ( bool  value)

Sets whether the binormals will be reconstructed during rendering, or searched for within the vertex buffers. Reconstruction happens as a cross product between the normal and the tangent.

Parameters
valueWhether the binormals should be reconstructed (true) or not (false).
Remarks
When changing this parameter, a material reload is needed. By default, this parameter is on.

◆ setMixAlbedoColorAndTexture()

void nkAstraeus::PbsMaterial::setMixAlbedoColorAndTexture ( bool  value)

Sets whether the albedo provided color should be mixed (multiplied) with the provided texture value, if available.

Parameters
valueWhether the mix should happen (true) or not (false).
Remarks
When changing this parameter, a material reload is needed. By default, this parameter is off.

◆ setMixSpecularColorAndTexture()

void nkAstraeus::PbsMaterial::setMixSpecularColorAndTexture ( bool  value)

Sets whether the specular provided color should be mixed (multiplied) with the provided texture value, if available.

Parameters
valueWhether the mix should happen (true) or not (false).
Remarks
When changing this parameter, a material reload is needed. By default, this parameter is off.

◆ setMixEmissiveColorAndTexture()

void nkAstraeus::PbsMaterial::setMixEmissiveColorAndTexture ( bool  value)

Sets whether the emissive provided color should be mixed (multiplied) with the provided texture value, if available.

Parameters
valueWhether the mix should happen (true) or not (false).
Remarks
When changing this parameter, a material reload is needed. By default, this parameter is off.

◆ setMixMetalnessFactorAndTexture()

void nkAstraeus::PbsMaterial::setMixMetalnessFactorAndTexture ( bool  value)

Sets whether the metalness provided factor should be mixed (multiplied) with the provided texture value, if available.

Parameters
valueWhether the mix should happen (true) or not (false).
Remarks
When changing this parameter, a material reload is needed. By default, this parameter is off.

◆ setMixRoughnessGlossinessFactorAndTexture()

void nkAstraeus::PbsMaterial::setMixRoughnessGlossinessFactorAndTexture ( bool  value)

Sets whether the roughness / glossiness provided factor should be mixed (multiplied) with the provided texture value, if available.

Parameters
valueWhether the mix should happen (true) or not (false).
Remarks
When changing this parameter, a material reload is needed. By default, this parameter is off.

◆ setMixEnvironmentColorAndTexture()

void nkAstraeus::PbsMaterial::setMixEnvironmentColorAndTexture ( bool  value)

Sets whether the environment (irradiance) provided color should be mixed (multiplied) with the provided texture value, if available. The color will impact both the irradiance and the environment values.

Parameters
valueWhether the mix should happen (true) or not (false).
Remarks
When changing this parameter, a material reload is needed. By default, this parameter is off.

◆ setMixAlphaFactorAndTexture()

void nkAstraeus::PbsMaterial::setMixAlphaFactorAndTexture ( bool  value)

Sets whether the alpha provided factor should be mixed (multiplied) with the provided texture value, if available.

Parameters
valueWhether the mix should happen (true) or not (false).
Remarks
When changing this parameter, a material reload is needed. By default, this parameter is off.

◆ load()

virtual bool nkAstraeus::PbsMaterial::load ( )
overridevirtual

Loads the material and make it ready for rendering.

Returns
Whether the loading went well (true) or not (false).

Implements nkAstraeus::Material.

◆ unload()

virtual void nkAstraeus::PbsMaterial::unload ( )
overridevirtual

Unloads the material and its internal memory. After that, the material is unusable for rendering.

Implements nkAstraeus::Material.

◆ exportClassToTree()

virtual void nkAstraeus::PbsMaterial::exportClassToTree ( nkExport::Node rootNode)
overridevirtual

Exports an item into a tree describing its structure and its data.

Parameters
rootNodeThe node into which the object has to write its related information.

Reimplemented from nkAstraeus::Material.

◆ importClassFromTree()

virtual void nkAstraeus::PbsMaterial::importClassFromTree ( nkExport::Node rootNode)
overridevirtual

Imports information from a tree which is supposed to describe its structure and data.

Parameters
rootNodeThe root node of the tree holding the information.

Reimplemented from nkAstraeus::Material.

◆ create()

static nkMemory::UniquePtr<PbsMaterial> nkAstraeus::PbsMaterial::create ( System system = nullptr)
static

Creates an instance of the class, and returns ownership over it.

Parameters
systemThe system the resource should live in. If left to nullptr, will seek the singleton instance of the system.
Returns
Ownership over the created instance of the class.
Remarks
The instance is not part of any manager if instantiated this way. If the resource's lifetime should be managed within the manager, then calling ComplexEffectManager::createOrRetrieve() might be a better option. Alternatively, registering it afterwards through ComplexEffectManager::record() is another option.

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