This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.
ofMaterial.h
Go to the documentation of this file.
30};
39// * assimp material: http://assimp.sourceforge.net/lib_html/ai_material_8h.html#7dd415ff703a2cc53d1c22ddbbd7dde0
196 void setColors(ofFloatColor oDiffuse, ofFloatColor oAmbient, ofFloatColor oSpecular, ofFloatColor emissive);
227 bool loadTexture( const ofMaterialTextureType& aMaterialTextureType, std::string apath, bool bTex2d, bool mirrorY );
342 void setCustomUniform2i(const std::string & name, glm::vec<2, int, glm::precision::defaultp> value);
343 void setCustomUniform3i(const std::string & name, glm::vec<3, int, glm::precision::defaultp> value);
344 void setCustomUniform4i(const std::string & name, glm::vec<4, int, glm::precision::defaultp> value);
347 void setCustomUniformTexture(const std::string & name, const ofTexture & value, int textureLocation);
348 void setCustomUniformTexture(const std::string & name, int textureTarget, GLint textureID, int textureLocation);
371 void mergeCustomUniformTextures(ofMaterialTextureType mainType, std::vector<ofMaterialTextureType> mergeTypes);
376 const ofShader & getShader(int textureTarget, bool geometryHasColor, ofGLProgrammableRenderer & renderer) const;
401 const TextureUnifom getCustomUniformTexture(const ofMaterialTextureType& aMaterialTextureType) const;
material parameter properties that can be applied to vertices in the OpenGL lighting model used in de...
Definition ofMaterialBaseTypes.h:41
Definition ofGLProgrammableRenderer.h:17
material parameter properties that can be applied to vertices in the OpenGL lighting model used in de...
Definition ofMaterial.h:162
void addShaderDefine(const std::string &aDefineName)
Definition ofMaterial.cpp:1187
void setup(const ofMaterialSettings &settings)
setup using settings struct
Definition ofMaterial.cpp:110
void setMetallicTexture(const ofTexture &aTex)
set a metallic texture. (PBR)
Definition ofMaterial.cpp:325
void setCustomUniform2f(const std::string &name, glm::vec2 value)
Definition ofMaterial.cpp:1045
void setMetallic(const float &ametallic)
set metalness. (PBR)
Definition ofMaterial.cpp:340
void setDiffuseColor(ofFloatColor oDiffuse)
set the diffuse reflectance. (Phong, PBR)
Definition ofMaterial.cpp:160
void setCustomUniformMatrix3f(const std::string &name, glm::mat3 value)
Definition ofMaterial.cpp:1085
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 sh...
Definition ofMaterial.cpp:1040
void setSpecularColor(ofFloatColor oSpecular)
set the specular reflectance. (Phong)
Definition ofMaterial.cpp:176
void setNormalGeomToNormalMapMix(const float &astrength)
percent to mix between geometry normal and normal map normal / displacement normal....
Definition ofMaterial.cpp:436
float getDisplacementStrength() const
Definition ofMaterial.cpp:486
void setClearCoatTexture(const ofTexture &aTex)
set a clear coat texture. (PBR)
Definition ofMaterial.cpp:335
void setDisplacementTexture(const ofTexture &aTex)
set a vertex displacement texture. (PBR)
Definition ofMaterial.cpp:330
virtual void uploadMatrices(const ofShader &shader, ofGLProgrammableRenderer &renderer) const
upload the given renderer's normal matrix to the material shader
Definition ofMaterial.cpp:540
void setReflectance(const float &areflectance)
set reflectance - only applies to dielectrics, ie, non metals. (PBR)
Definition ofMaterial.cpp:363
void setRoughness(const float &aroughness)
set roughness. (PBR)
Definition ofMaterial.cpp:352
void setDisplacementNormalsStrength(const float &astrength)
offset strength to calculate normals for vertex displacement. (PBR)
Definition ofMaterial.cpp:426
void setCustomUniformMatrix4f(const std::string &name, glm::mat4 value)
Definition ofMaterial.cpp:1080
void setCustomUniform3f(const std::string &name, glm::vec3 value)
Definition ofMaterial.cpp:1050
void setCustomUniformTexture(const std::string &name, const ofTexture &value)
Definition ofMaterial.cpp:1091
void setSpecularTexture(const ofTexture &aTex)
set a specular map texture. (Phong)
Definition ofMaterial.cpp:283
void setCustomUniform4i(const std::string &name, glm::vec< 4, int, glm::precision::defaultp > value)
Definition ofMaterial.cpp:1075
void setNormalTexture(const ofTexture &aTex)
set a normal texture. (Phong, PBR)
Definition ofMaterial.cpp:298
void setClearCoatRoughness(const float &aroughness)
set clear coat roughness. Must call setClearCoatEnabled(true) to take effect. (PBR)
Definition ofMaterial.cpp:402
void setAmbientTexture(const ofTexture &aTex)
set an ambient light texture. (Phong)
Definition ofMaterial.cpp:288
OF_DEPRECATED_MSG("Use getSettings() instead", Data getData() const)
void setEmissiveColor(ofFloatColor oEmmisive)
set the emitted light intensity. (Phong, PBR)
Definition ofMaterial.cpp:184
void setRoughnessTexture(const ofTexture &aTex)
set a roughness texture. (PBR)
Definition ofMaterial.cpp:320
static std::string getUniformName(const ofMaterialTextureType &aMaterialTextureType)
get the shader uniform name for the material texture type.
Definition ofMaterial.cpp:25
void setCustomUniform1i(const std::string &name, int value)
Definition ofMaterial.cpp:1060
void setCustomUniform3i(const std::string &name, glm::vec< 3, int, glm::precision::defaultp > value)
Definition ofMaterial.cpp:1070
static bool isPBRSupported()
\is PBR supported on this platform.
Definition ofMaterial.cpp:64
void begin() const
begin using this material's properties
Definition ofMaterial.cpp:526
void setEmissiveTexture(const ofTexture &aTex)
set an emissive texture. (Phong, PBR)
Definition ofMaterial.cpp:293
void unbind(ofGLProgrammableRenderer &renderer) const
unbind the material, override the default so we can set current shader to nullptr
Definition ofMaterial.cpp:621
void setPBR(bool ab)
enable or disable PBR for this material. Default is disabled.
Definition ofMaterial.cpp:76
bool loadTexture(const ofMaterialTextureType &aMaterialTextureType, std::string apath)
load a texture that is stored in the material. Check which textures are PBR using isPBRTexture(ofMate...
Definition ofMaterial.cpp:209
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.
Definition ofMaterial.cpp:252
void setCustomUniform2i(const std::string &name, glm::vec< 2, int, glm::precision::defaultp > value)
Definition ofMaterial.cpp:1065
bool hasTexture(const ofMaterialTextureType &aMaterialTextureType) const
Definition ofMaterial.cpp:1178
int getHighestUniformTextureLocation() const
Definition ofMaterial.cpp:1167
void setCustomShader(std::shared_ptr< ofShader > aCustomShader)
set a custom shader controlled by the user.
Definition ofMaterial.cpp:1033
void setAoRoughnessMetallicTexture(const ofTexture &aTex)
set an occlusion, roughness, metallic texture. (PBR)
Definition ofMaterial.cpp:308
float getDisplacementNormalsStrength() const
Definition ofMaterial.cpp:491
void setClearCoatStrength(const float &astrength)
set clear coat strength. Must call setClearCoatEnabled(true) to take effect. (PBR)
Definition ofMaterial.cpp:391
void setDiffuseTexture(const ofTexture &aTex)
set a diffuse texture. (Phong, PBR).
Definition ofMaterial.cpp:278
void setColors(ofFloatColor oDiffuse, ofFloatColor oAmbient, ofFloatColor oSpecular, ofFloatColor emissive)
set all material colors: reflectance type & light intensity. (Phong)
Definition ofMaterial.cpp:102
void setRoughnessMetallicTexture(const ofTexture &aTex)
set a roughness, metallic texture. (PBR)
Definition ofMaterial.cpp:314
void setTexCoordScale(float xscale, float yscale)
set the tex coord scale used in the shader. (Phong, PBR)
Definition ofMaterial.cpp:200
void setShininess(float nShininess)
set the specular exponent. (Phong)
Definition ofMaterial.cpp:192
bool removeShaderDefine(const std::string &aDefineName)
Definition ofMaterial.cpp:1211
OF_DEPRECATED_MSG("Use setup(settings) instead", void setData(const ofMaterial::Data &data))
set the material color properties data struct
void setCustomUniform4f(const std::string &name, glm::vec4 value)
Definition ofMaterial.cpp:1055
bool removeCustomUniformTexture(const ofMaterialTextureType &aMaterialTextureType)
Definition ofMaterial.cpp:1152
void setShaderMain(std::string aShaderSrc, GLenum atype, std::string skey)
override the default main shader functions for vert or frag shader. (PBR)
Definition ofMaterial.cpp:132
void setAmbientColor(ofFloatColor oAmbient)
set the ambient reflectance. (Phong)
Definition ofMaterial.cpp:168
void setClearCoatEnabled(bool ab)
set clear coat. Disabled by default. (PBR)
Definition ofMaterial.cpp:374
const std::string getDefinesString() const
string holding all of the defines added to the shader. (Phong, PBR)
Definition ofMaterial.cpp:1229
float getNormalGeomToNormalMapMix() const
Definition ofMaterial.cpp:496
const bool isPBR() const
is this material pbr. Setting PBR functions or textures will automatically set the material to pbr....
Definition ofMaterial.h:177
void setOcclusionTexture(const ofTexture &aTex)
set an occlusion texture. (Phong, PBR)
Definition ofMaterial.cpp:303
void setDisplacementStrength(const float &astrength)
amount of vertex displacement. Must have set OF_MATERIAL_TEXTURE_DISPLACEMENT to take effect....
Definition ofMaterial.cpp:413
bool isPBRTexture(const ofMaterialTextureType &aMaterialTextureType)
check if texture is PBR only.
Definition ofMaterial.cpp:247
Definition ofShader.h:35
@ OF_MATERIAL_TEXTURE_CLEARCOAT_ROUGHNESS
Definition ofMaterial.h:27
@ OF_MATERIAL_TEXTURE_ROUGHNESS_METALLIC
Definition ofMaterial.h:22
@ OF_MATERIAL_TEXTURE_AO_ROUGHNESS_METALLIC
Definition ofMaterial.h:21
@ OF_MATERIAL_TEXTURE_CLEARCOAT_NORMAL
Definition ofMaterial.h:29
@ OF_MATERIAL_TEXTURE_CLEARCOAT_INTENSITY_ROUGHNESS
Definition ofMaterial.h:28
Definition ofMaterial.h:123
float reflectance
reflectance only applies to dielectric materials (non-metallic)
Definition ofMaterial.h:135
float displacementNormalsStrength
strength of normal calculation based on displacement map
Definition ofMaterial.h:140
std::string mainVertex
access fragment main function with this key make unique for new instances
Definition ofMaterial.h:152
bool clearCoatEnabled
this must be enabled for clear coat to have effect, will be enabled if clear coat texture set
Definition ofMaterial.h:136
float displacementStrength
strength of vertex displacement from displacement map in world space
Definition ofMaterial.h:139
std::string uniqueIdString
set by ofMaterial::setCustomUniform* not to be set manually
Definition ofMaterial.h:148
std::string mainFragment
set by ofMaterial to cache shader
Definition ofMaterial.h:149
float normalGeomToNormalMapMix
if a normal map is set, the mix between the geometry normal and normal from the normal / displacement...
Definition ofMaterial.h:141
std::string mainVertexKey
override the default main function in the vertex shader
Definition ofMaterial.h:153
float metallic
metallic properties, can be fraction between 0 -> 1
Definition ofMaterial.h:133
std::string mainFragmentKey
override the default main function in the frag shader
Definition ofMaterial.h:150