reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

material parameter properties that can be applied to vertices in the OpenGL lighting model used in determining both the intensity and color of reflected light based on the lighting model in use and if the vertices are on a front or back sided face More...

#include <ofMaterial.h>

Inheritance diagram for ofMaterial:
ofBaseMaterial

Public Types

typedef ofMaterialSettings Data
 

Public Member Functions

 ofMaterial ()
 
virtual ~ofMaterial ()
 
const bool isPBR () const
 is this material pbr. Setting PBR functions or textures will automatically set the material to pbr.\nCan also be set calling setPBR(bool);
 
void setPBR (bool ab)
 enable or disable PBR for this material. Default is disabled.
 
void setup (const ofMaterialSettings &settings)
 setup using settings struct
 
void setShaderMain (std::string aShaderSrc, GLenum atype, std::string skey)
 override the default main shader functions for vert or frag shader. (PBR)
 
void setColors (ofFloatColor oDiffuse, ofFloatColor oAmbient, ofFloatColor oSpecular, ofFloatColor emissive)
 set all material colors: reflectance type & light intensity. (Phong)
 
void setDiffuseColor (ofFloatColor oDiffuse)
 set the diffuse reflectance. (Phong, PBR)
 
void setAmbientColor (ofFloatColor oAmbient)
 set the ambient reflectance. (Phong)
 
void setSpecularColor (ofFloatColor oSpecular)
 set the specular reflectance. (Phong)
 
void setEmissiveColor (ofFloatColor oEmmisive)
 set the emitted light intensity. (Phong, PBR)
 
void setShininess (float nShininess)
 set the specular exponent. (Phong)
 
void setTexCoordScale (float xscale, float yscale)
 set the tex coord scale used in the shader. (Phong, PBR)
 
bool loadTexture (const ofMaterialTextureType &aMaterialTextureType, std::string apath)
 load a texture that is stored in the material. Check which textures are PBR using isPBRTexture(ofMaterialTextureType)
 
bool loadTexture (const ofMaterialTextureType &aMaterialTextureType, std::string apath, bool bTex2d, bool mirrorY)
 
bool isPBRTexture (const ofMaterialTextureType &aMaterialTextureType)
 check if texture is PBR only.
 
void setTexture (const ofMaterialTextureType &aMaterialTextureType, const ofTexture &aTex)
 set additonal textures to use in the shader. If texture is PBR only, will set material to PBR.
 
void setDiffuseTexture (const ofTexture &aTex)
 set a diffuse texture. (Phong, PBR).
 
void setSpecularTexture (const ofTexture &aTex)
 set a specular map texture. (Phong)
 
void setAmbientTexture (const ofTexture &aTex)
 set an ambient light texture. (Phong)
 
void setEmissiveTexture (const ofTexture &aTex)
 set an emissive texture. (Phong, PBR)
 
void setNormalTexture (const ofTexture &aTex)
 set a normal texture. (Phong, PBR)
 
void setOcclusionTexture (const ofTexture &aTex)
 set an occlusion texture. (Phong, PBR)
 
void setAoRoughnessMetallicTexture (const ofTexture &aTex)
 set an occlusion, roughness, metallic texture. (PBR)
 
void setRoughnessMetallicTexture (const ofTexture &aTex)
 set a roughness, metallic texture. (PBR)
 
void setRoughnessTexture (const ofTexture &aTex)
 set a roughness texture. (PBR)
 
void setMetallicTexture (const ofTexture &aTex)
 set a metallic texture. (PBR)
 
void setDisplacementTexture (const ofTexture &aTex)
 set a vertex displacement texture. (PBR)
 
void setClearCoatTexture (const ofTexture &aTex)
 set a clear coat texture. (PBR)
 
void setMetallic (const float &ametallic)
 set metalness. (PBR)
 
void setRoughness (const float &aroughness)
 set roughness. (PBR)
 
void setReflectance (const float &areflectance)
 set reflectance - only applies to dielectrics, ie, non metals. (PBR)
 
void setClearCoatEnabled (bool ab)
 set clear coat. Disabled by default. (PBR)
 
void setClearCoatStrength (const float &astrength)
 set clear coat strength. Must call setClearCoatEnabled(true) to take effect. (PBR)
 
void setClearCoatRoughness (const float &aroughness)
 set clear coat roughness. Must call setClearCoatEnabled(true) to take effect. (PBR)
 
void setDisplacementStrength (const float &astrength)
 amount of vertex displacement. Must have set OF_MATERIAL_TEXTURE_DISPLACEMENT to take effect. (PBR)
 
void setDisplacementNormalsStrength (const float &astrength)
 offset strength to calculate normals for vertex displacement. (PBR)
 
void setNormalGeomToNormalMapMix (const float &astrength)
 percent to mix between geometry normal and normal map normal / displacement normal. (PBR)
 
ofFloatColor getDiffuseColor () const
 
ofFloatColor getAmbientColor () const
 
ofFloatColor getSpecularColor () const
 
ofFloatColor getEmissiveColor () const
 
float getShininess () const
 
float getMetallic () const
 
float getRoughness () const
 
float getReflectance () const
 
bool isClearCoatEnabled () const
 
float getClearCoatStrength () const
 
float getClearCoatRoughness () const
 
float getDisplacementStrength () const
 
float getDisplacementNormalsStrength () const
 
float getNormalGeomToNormalMapMix () const
 
 OF_DEPRECATED_MSG ("Use getSettings() instead", Data getData() const)
 
ofMaterialSettings getSettings () const
 
 OF_DEPRECATED_MSG ("Use setup(settings) instead", void setData(const ofMaterial::Data &data))
 set the material color properties data struct
 
void begin () const
 begin using this material's properties
 
void end () const
 end using this material's properties
 
virtual void uploadMatrices (const ofShader &shader, ofGLProgrammableRenderer &renderer) const
 upload the given renderer's normal matrix to the material shader
 
void setCustomUniform1f (const std::string &name, float value)
 set custom uniforms to be used by the shader. as of 0.12.0 onwards these are added to the fragment shader header
 
void setCustomUniform2f (const std::string &name, glm::vec2 value)
 
void setCustomUniform3f (const std::string &name, glm::vec3 value)
 
void setCustomUniform4f (const std::string &name, glm::vec4 value)
 
void setCustomUniformMatrix4f (const std::string &name, glm::mat4 value)
 
void setCustomUniformMatrix3f (const std::string &name, glm::mat3 value)
 
void setCustomUniform1i (const std::string &name, int value)
 
void setCustomUniform2i (const std::string &name, glm::vec< 2, int, glm::precision::defaultp > value)
 
void setCustomUniform3i (const std::string &name, glm::vec< 3, int, glm::precision::defaultp > value)
 
void setCustomUniform4i (const std::string &name, glm::vec< 4, int, glm::precision::defaultp > value)
 
void setCustomUniformTexture (const std::string &name, const ofTexture &value)
 
void setCustomUniformTexture (const std::string &name, int textureTarget, GLint textureID)
 
void setCustomUniformTexture (const std::string &name, const ofTexture &value, int textureLocation)
 
void setCustomUniformTexture (const std::string &name, int textureTarget, GLint textureID, int textureLocation)
 
bool removeCustomUniformTexture (const ofMaterialTextureType &aMaterialTextureType)
 
bool removeCustomUniformTexture (const std::string &name)
 
int getHighestUniformTextureLocation () const
 
bool hasTexture (const ofMaterialTextureType &aMaterialTextureType) const
 
void addShaderDefine (const std::string &aDefineName)
 
void addShaderDefine (const std::string &aDefineName, const std::string &aDefineValue)
 
bool removeShaderDefine (const std::string &aDefineName)
 
const std::string getDefinesString () const
 string holding all of the defines added to the shader. (Phong, PBR)
 
void setCustomShader (std::shared_ptr< ofShader > aCustomShader)
 set a custom shader controlled by the user.
 
- Public Member Functions inherited from ofBaseMaterial
virtual ~ofBaseMaterial ()
 
virtual bool isBound () const
 when begin() is called, the material is set to bound by the renderer.\nSet to unbound via renderer when end() is called.
 

Static Public Member Functions

static std::string getUniformName (const ofMaterialTextureType &aMaterialTextureType)
 get the shader uniform name for the material texture type.
 
static bool isPBRSupported ()
 \is PBR supported on this platform.
 

Protected Member Functions

void unbind (ofGLProgrammableRenderer &renderer) const
 unbind the material, override the default so we can set current shader to nullptr
 
- Protected Member Functions inherited from ofBaseMaterial
virtual void bind (ofGLProgrammableRenderer &renderer) const
 set to bound. Later used if certain properties are set so the shader can be updated without calling end(), set var and then begin() again.
 

Additional Inherited Members

- Protected Attributes inherited from ofBaseMaterial
bool mBound = false
 

Detailed Description

material parameter properties that can be applied to vertices in the OpenGL lighting model used in determining both the intensity and color of reflected light based on the lighting model in use and if the vertices are on a front or back sided face

Member Typedef Documentation

◆ Data

Returns
material color properties data struct

Constructor & Destructor Documentation

◆ ofMaterial()

ofMaterial::ofMaterial ( )

◆ ~ofMaterial()

virtual ofMaterial::~ofMaterial ( )
inlinevirtual

Member Function Documentation

◆ addShaderDefine() [1/2]

void ofMaterial::addShaderDefine ( const std::string &  aDefineName)

◆ addShaderDefine() [2/2]

void ofMaterial::addShaderDefine ( const std::string &  aDefineName,
const std::string &  aDefineValue 
)

◆ begin()

void ofMaterial::begin ( ) const
virtual

begin using this material's properties

Implements ofBaseMaterial.

◆ end()

void ofMaterial::end ( ) const
virtual

end using this material's properties

Implements ofBaseMaterial.

◆ getAmbientColor()

ofFloatColor ofMaterial::getAmbientColor ( ) const
virtual
Returns
the ambient reflectance

Implements ofBaseMaterial.

◆ getClearCoatRoughness()

float ofMaterial::getClearCoatRoughness ( ) const

◆ getClearCoatStrength()

float ofMaterial::getClearCoatStrength ( ) const

◆ getDefinesString()

const std::string ofMaterial::getDefinesString ( ) const

string holding all of the defines added to the shader. (Phong, PBR)

Returns
string containing all defines.

◆ getDiffuseColor()

ofFloatColor ofMaterial::getDiffuseColor ( ) const
virtual
Returns
the diffuse reflectance

Implements ofBaseMaterial.

◆ getDisplacementNormalsStrength()

float ofMaterial::getDisplacementNormalsStrength ( ) const

◆ getDisplacementStrength()

float ofMaterial::getDisplacementStrength ( ) const

◆ getEmissiveColor()

ofFloatColor ofMaterial::getEmissiveColor ( ) const
virtual
Returns
the emitted light intensity

Implements ofBaseMaterial.

◆ getHighestUniformTextureLocation()

int ofMaterial::getHighestUniformTextureLocation ( ) const

◆ getMetallic()

float ofMaterial::getMetallic ( ) const

◆ getNormalGeomToNormalMapMix()

float ofMaterial::getNormalGeomToNormalMapMix ( ) const

◆ getReflectance()

float ofMaterial::getReflectance ( ) const

◆ getRoughness()

float ofMaterial::getRoughness ( ) const

◆ getSettings()

ofMaterialSettings ofMaterial::getSettings ( ) const

◆ getShininess()

float ofMaterial::getShininess ( ) const
virtual
Returns
the specular exponent

Implements ofBaseMaterial.

◆ getSpecularColor()

ofFloatColor ofMaterial::getSpecularColor ( ) const
virtual
Returns
the specular reflectance

Implements ofBaseMaterial.

◆ getUniformName()

std::string ofMaterial::getUniformName ( const ofMaterialTextureType aMaterialTextureType)
static

get the shader uniform name for the material texture type.

Parameters
aMaterialTextureTypethe material texture type to query
Returns
the shader uniform name

◆ hasTexture()

bool ofMaterial::hasTexture ( const ofMaterialTextureType aMaterialTextureType) const

◆ isClearCoatEnabled()

bool ofMaterial::isClearCoatEnabled ( ) const

◆ isPBR()

const bool ofMaterial::isPBR ( ) const
inline

is this material pbr. Setting PBR functions or textures will automatically set the material to pbr.\nCan also be set calling setPBR(bool);

Returns
is the material pbr.

◆ isPBRSupported()

bool ofMaterial::isPBRSupported ( )
static

\is PBR supported on this platform.

◆ isPBRTexture()

bool ofMaterial::isPBRTexture ( const ofMaterialTextureType aMaterialTextureType)

check if texture is PBR only.

Returns
is texture only PBR.

◆ loadTexture() [1/2]

bool ofMaterial::loadTexture ( const ofMaterialTextureType aMaterialTextureType,
std::string  apath 
)

load a texture that is stored in the material. Check which textures are PBR using isPBRTexture(ofMaterialTextureType)

Parameters
aMaterialTextureTypetype of texture.
apathfile path to texture.
Returns
if the load was successful.

◆ loadTexture() [2/2]

bool ofMaterial::loadTexture ( const ofMaterialTextureType aMaterialTextureType,
std::string  apath,
bool  bTex2d,
bool  mirrorY 
)

◆ OF_DEPRECATED_MSG() [1/2]

ofMaterial::OF_DEPRECATED_MSG ( "Use getSettings() instead"  ,
Data getData() const   
)

◆ OF_DEPRECATED_MSG() [2/2]

ofMaterial::OF_DEPRECATED_MSG ( "Use setup(settings) instead"  ,
void   setDataconst ofMaterial::Data &data 
)

set the material color properties data struct

◆ removeCustomUniformTexture() [1/2]

bool ofMaterial::removeCustomUniformTexture ( const ofMaterialTextureType aMaterialTextureType)

◆ removeCustomUniformTexture() [2/2]

bool ofMaterial::removeCustomUniformTexture ( const std::string &  name)

◆ removeShaderDefine()

bool ofMaterial::removeShaderDefine ( const std::string &  aDefineName)

◆ setAmbientColor()

void ofMaterial::setAmbientColor ( ofFloatColor  oAmbient)

set the ambient reflectance. (Phong)

Parameters
oAmbientthe ambient reflectance

◆ setAmbientTexture()

void ofMaterial::setAmbientTexture ( const ofTexture aTex)

set an ambient light texture. (Phong)

Parameters
aTextexture with ambient lighting data.

◆ setAoRoughnessMetallicTexture()

void ofMaterial::setAoRoughnessMetallicTexture ( const ofTexture aTex)

set an occlusion, roughness, metallic texture. (PBR)

Parameters
aTextexture with r = occlusion, g = roughness and b = metallic.

◆ setClearCoatEnabled()

void ofMaterial::setClearCoatEnabled ( bool  ab)

set clear coat. Disabled by default. (PBR)

Parameters
abis clear coat enabled.

◆ setClearCoatRoughness()

void ofMaterial::setClearCoatRoughness ( const float &  aroughness)

set clear coat roughness. Must call setClearCoatEnabled(true) to take effect. (PBR)

Parameters
aroughnessroughness of clear coat.

◆ setClearCoatStrength()

void ofMaterial::setClearCoatStrength ( const float &  astrength)

set clear coat strength. Must call setClearCoatEnabled(true) to take effect. (PBR)

Parameters
astrengthstrength of clear coat.

◆ setClearCoatTexture()

void ofMaterial::setClearCoatTexture ( const ofTexture aTex)

set a clear coat texture. (PBR)

Parameters
aTexwith r = intensity, g = n/a and b = n/a.

◆ setColors()

void ofMaterial::setColors ( ofFloatColor  oDiffuse,
ofFloatColor  oAmbient,
ofFloatColor  oSpecular,
ofFloatColor  emissive 
)

set all material colors: reflectance type & light intensity. (Phong)

Parameters
oDiffusethe diffuse reflectance
oAmbientthe ambient reflectance
oSpecularthe specular reflectance
oEmmissivethe emitted light intensity

◆ setCustomShader()

void ofMaterial::setCustomShader ( std::shared_ptr< ofShader aCustomShader)
virtual

set a custom shader controlled by the user.

Parameters
aCustomShaderthe material shader, created and maintained by the user

Implements ofBaseMaterial.

◆ setCustomUniform1f()

void ofMaterial::setCustomUniform1f ( const std::string &  name,
float  value 
)

set custom uniforms to be used by the shader. as of 0.12.0 onwards these are added to the fragment shader header

◆ setCustomUniform1i()

void ofMaterial::setCustomUniform1i ( const std::string &  name,
int  value 
)

◆ setCustomUniform2f()

void ofMaterial::setCustomUniform2f ( const std::string &  name,
glm::vec2  value 
)

◆ setCustomUniform2i()

void ofMaterial::setCustomUniform2i ( const std::string &  name,
glm::vec< 2, int, glm::precision::defaultp >  value 
)

◆ setCustomUniform3f()

void ofMaterial::setCustomUniform3f ( const std::string &  name,
glm::vec3  value 
)

◆ setCustomUniform3i()

void ofMaterial::setCustomUniform3i ( const std::string &  name,
glm::vec< 3, int, glm::precision::defaultp >  value 
)

◆ setCustomUniform4f()

void ofMaterial::setCustomUniform4f ( const std::string &  name,
glm::vec4  value 
)

◆ setCustomUniform4i()

void ofMaterial::setCustomUniform4i ( const std::string &  name,
glm::vec< 4, int, glm::precision::defaultp >  value 
)

◆ setCustomUniformMatrix3f()

void ofMaterial::setCustomUniformMatrix3f ( const std::string &  name,
glm::mat3  value 
)

◆ setCustomUniformMatrix4f()

void ofMaterial::setCustomUniformMatrix4f ( const std::string &  name,
glm::mat4  value 
)

◆ setCustomUniformTexture() [1/4]

void ofMaterial::setCustomUniformTexture ( const std::string &  name,
const ofTexture value 
)

◆ setCustomUniformTexture() [2/4]

void ofMaterial::setCustomUniformTexture ( const std::string &  name,
const ofTexture value,
int  textureLocation 
)

◆ setCustomUniformTexture() [3/4]

void ofMaterial::setCustomUniformTexture ( const std::string &  name,
int  textureTarget,
GLint  textureID 
)

◆ setCustomUniformTexture() [4/4]

void ofMaterial::setCustomUniformTexture ( const std::string &  name,
int  textureTarget,
GLint  textureID,
int  textureLocation 
)

◆ setDiffuseColor()

void ofMaterial::setDiffuseColor ( ofFloatColor  oDiffuse)

set the diffuse reflectance. (Phong, PBR)

Parameters
oDiffusethe diffuse reflectance

◆ setDiffuseTexture()

void ofMaterial::setDiffuseTexture ( const ofTexture aTex)

set a diffuse texture. (Phong, PBR).

Parameters
aTextexture with diffuse color information.

◆ setDisplacementNormalsStrength()

void ofMaterial::setDisplacementNormalsStrength ( const float &  astrength)

offset strength to calculate normals for vertex displacement. (PBR)

Parameters
astrengthstrength to calculate normals, higher values = more distinct normals.

◆ setDisplacementStrength()

void ofMaterial::setDisplacementStrength ( const float &  astrength)

amount of vertex displacement. Must have set OF_MATERIAL_TEXTURE_DISPLACEMENT to take effect. (PBR)

Parameters
astrengthamount to displace vertices along normal accoring to displacement texture.

◆ setDisplacementTexture()

void ofMaterial::setDisplacementTexture ( const ofTexture aTex)

set a vertex displacement texture. (PBR)

Parameters
aTexrgb texture displacement map.

◆ setEmissiveColor()

void ofMaterial::setEmissiveColor ( ofFloatColor  oEmmisive)

set the emitted light intensity. (Phong, PBR)

Parameters
oEmmissivethe emitted light intensity

◆ setEmissiveTexture()

void ofMaterial::setEmissiveTexture ( const ofTexture aTex)

set an emissive texture. (Phong, PBR)

Parameters
aTextexture with emissive color information.

◆ setMetallic()

void ofMaterial::setMetallic ( const float &  ametallic)

set metalness. (PBR)

Parameters
ametallicmetal property of material.

◆ setMetallicTexture()

void ofMaterial::setMetallicTexture ( const ofTexture aTex)

set a metallic texture. (PBR)

Parameters
aTextexture with r = n/a, g = n/a and b = metallic.

◆ setNormalGeomToNormalMapMix()

void ofMaterial::setNormalGeomToNormalMapMix ( const float &  astrength)

percent to mix between geometry normal and normal map normal / displacement normal. (PBR)

Parameters
astrengthpercent to mix between the two.

◆ setNormalTexture()

void ofMaterial::setNormalTexture ( const ofTexture aTex)

set a normal texture. (Phong, PBR)

Parameters
aTextexture with normal information.

◆ setOcclusionTexture()

void ofMaterial::setOcclusionTexture ( const ofTexture aTex)

set an occlusion texture. (Phong, PBR)

Parameters
aTextexture with r = occlusion, g = n/a and b = n/a.

◆ setPBR()

void ofMaterial::setPBR ( bool  ab)

enable or disable PBR for this material. Default is disabled.

◆ setReflectance()

void ofMaterial::setReflectance ( const float &  areflectance)

set reflectance - only applies to dielectrics, ie, non metals. (PBR)

Parameters
areflectanceamount of light material reflects.

◆ setRoughness()

void ofMaterial::setRoughness ( const float &  aroughness)

set roughness. (PBR)

Parameters
aroughnessroughness of material.

◆ setRoughnessMetallicTexture()

void ofMaterial::setRoughnessMetallicTexture ( const ofTexture aTex)

set a roughness, metallic texture. (PBR)

Parameters
aTextexture with r = n/a, g = roughness and b = metallic.

◆ setRoughnessTexture()

void ofMaterial::setRoughnessTexture ( const ofTexture aTex)

set a roughness texture. (PBR)

Parameters
aTextexture with r = n/a, g = roughness and b = n/a.

◆ setShaderMain()

void ofMaterial::setShaderMain ( std::string  aShaderSrc,
GLenum  atype,
std::string  skey 
)

override the default main shader functions for vert or frag shader. (PBR)

Parameters
aShaderSrcthe shader source as a string
atypeGL_VERTEX_SHADER or GL_FRAGMENT_SHADER
skeyunique key to identify the vertex and fragment sources. If loading dynamically, use same key to overwrite previous instances.

◆ setShininess()

void ofMaterial::setShininess ( float  nShininess)

set the specular exponent. (Phong)

◆ setSpecularColor()

void ofMaterial::setSpecularColor ( ofFloatColor  oSpecular)

set the specular reflectance. (Phong)

Parameters
oSpecularthe specular reflectance

◆ setSpecularTexture()

void ofMaterial::setSpecularTexture ( const ofTexture aTex)

set a specular map texture. (Phong)

Parameters
aTextexture with specular map data.

◆ setTexCoordScale()

void ofMaterial::setTexCoordScale ( float  xscale,
float  yscale 
)

set the tex coord scale used in the shader. (Phong, PBR)

Parameters
xscaletexture scale in x
yscaletexture scale in y

◆ setTexture()

void ofMaterial::setTexture ( const ofMaterialTextureType aMaterialTextureType,
const ofTexture aTex 
)

set additonal textures to use in the shader. If texture is PBR only, will set material to PBR.

◆ setup()

void ofMaterial::setup ( const ofMaterialSettings settings)

setup using settings struct

Parameters
settingscolor & other properties struct

◆ unbind()

void ofMaterial::unbind ( ofGLProgrammableRenderer renderer) const
protectedvirtual

unbind the material, override the default so we can set current shader to nullptr

Reimplemented from ofBaseMaterial.

◆ uploadMatrices()

void ofMaterial::uploadMatrices ( const ofShader shader,
ofGLProgrammableRenderer renderer 
) const
virtual

upload the given renderer's normal matrix to the material shader

Parameters
shaderthe material shader, created by getShader()
rendererprogrammable renderer instance that uses the material shader

Reimplemented from ofBaseMaterial.


The documentation for this class was generated from the following files:
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/gl/ofMaterial.h
  • /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/gl/ofMaterial.cpp