reference

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

ofMaterialBaseTypes.h
Go to the documentation of this file.
1#pragma once
2
3class ofShader;
5
6// enum ofMaterialTextureType: short{
7// OF_MATERIAL_TEXTURE_NONE=0,
8// OF_MATERIAL_TEXTURE_DIFFUSE,
9// OF_MATERIAL_TEXTURE_SPECULAR,
10// OF_MATERIAL_TEXTURE_AMBIENT,
11// OF_MATERIAL_TEXTURE_EMISSIVE,
12// OF_MATERIAL_TEXTURE_NORMAL,
13// OF_MATERIAL_TEXTURE_OCCLUSION,
14// OF_MATERIAL_TEXTURE_AO_ROUGHNESS_METALLIC,
15// OF_MATERIAL_TEXTURE_ROUGHNESS_METALLIC,
16// OF_MATERIAL_TEXTURE_ROUGHNESS,
17// OF_MATERIAL_TEXTURE_METALLIC,
18// OF_MATERIAL_TEXTURE_DISPLACEMENT,
19// OF_MATERIAL_TEXTURE_CLEARCOAT, // INTENSITY
20// OF_MATERIAL_TEXTURE_CLEARCOAT_ROUGHNESS,
21// OF_MATERIAL_TEXTURE_CLEARCOAT_INTENSITY_ROUGHNESS,
22// OF_MATERIAL_TEXTURE_CLEARCOAT_NORMAL
23// };
24
25// Material concept: "Anything graphical applied to the polygons"
26//
27// Diederick Huijbers <diederick[at]apollomedia[dot]nl>
28//
29// references:
30// * Wavefront material file spec: http://people.sc.fsu.edu/~jburkardt/data/mtl/mtl.html
31// * Ogre3D: http://www.ogre3d.org/docs/manual/manual_11.html#SEC14
32// * assimp material: http://assimp.sourceforge.net/lib_html/ai_material_8h.html#7dd415ff703a2cc53d1c22ddbbd7dde0
33
34// PBR Material based on GLTF spec from KhronosGroup: https://github.com/KhronosGroup/glTF
35
36
42public:
43
44 virtual ~ofBaseMaterial(){};
45
47 virtual ofFloatColor getDiffuseColor() const=0;
48
50 virtual ofFloatColor getAmbientColor() const=0;
51
53 virtual ofFloatColor getSpecularColor() const=0;
54
56 virtual ofFloatColor getEmissiveColor() const=0;
57
59 virtual float getShininess() const=0;
60
62 virtual void begin() const=0;
63
65 virtual void end() const=0;
66
70 virtual const ofShader & getShader(int textureTarget, bool geometryHasColor, ofGLProgrammableRenderer & renderer) const=0;
71
74 virtual void setCustomShader( std::shared_ptr<ofShader> aCustomShader) = 0;
75
79 virtual void uploadMatrices(const ofShader & shader,ofGLProgrammableRenderer & renderer) const;
80
84 virtual void updateMaterial(const ofShader & shader,ofGLProgrammableRenderer & renderer) const=0;
85
89 virtual void updateLights(const ofShader & shader,ofGLProgrammableRenderer & renderer) const=0;
90
94 virtual void updateShadows(const ofShader & shader,ofGLProgrammableRenderer & renderer) const=0;
95
99 virtual void updateEnvironmentMaps(const ofShader & shader,ofGLProgrammableRenderer & renderer) const=0;
100
103 virtual bool isBound() const;
104
105protected:
108 virtual void bind(ofGLProgrammableRenderer & renderer) const {
109 mBound = true;
110 }
111
113 virtual void unbind(ofGLProgrammableRenderer & renderer) const {
114 mBound = false;
115 }
116
117 mutable bool mBound = false;
118};
119
material parameter properties that can be applied to vertices in the OpenGL lighting model used in de...
Definition ofMaterialBaseTypes.h:41
virtual void bind(ofGLProgrammableRenderer &renderer) const
set to bound. Later used if certain properties are set so the shader can be updated without calling e...
Definition ofMaterialBaseTypes.h:108
virtual bool isBound() const
when begin() is called, the material is set to bound by the renderer.\nSet to unbound via renderer wh...
Definition ofBaseTypes.cpp:332
virtual void updateMaterial(const ofShader &shader, ofGLProgrammableRenderer &renderer) const =0
update the material properties to the material shader
virtual void uploadMatrices(const ofShader &shader, ofGLProgrammableRenderer &renderer) const
upload the given renderer's normal matrix to the material shader
Definition ofBaseTypes.cpp:328
virtual void end() const =0
end using this material's properties
virtual ofFloatColor getAmbientColor() const =0
virtual void unbind(ofGLProgrammableRenderer &renderer) const
unbind the shader.
Definition ofMaterialBaseTypes.h:113
bool mBound
Definition ofMaterialBaseTypes.h:117
virtual void begin() const =0
begin using this material's properties
virtual ~ofBaseMaterial()
Definition ofMaterialBaseTypes.h:44
virtual ofFloatColor getEmissiveColor() const =0
virtual const ofShader & getShader(int textureTarget, bool geometryHasColor, ofGLProgrammableRenderer &renderer) const =0
create and return a shader used to implement the materials effect for a given renderer
virtual void updateLights(const ofShader &shader, ofGLProgrammableRenderer &renderer) const =0
update the given renderer's lights to the material shader
virtual void setCustomShader(std::shared_ptr< ofShader > aCustomShader)=0
set a custom shader controlled by the user.
virtual ofFloatColor getDiffuseColor() const =0
virtual ofFloatColor getSpecularColor() const =0
virtual void updateEnvironmentMaps(const ofShader &shader, ofGLProgrammableRenderer &renderer) const =0
update the given renderer's environment maps / cube maps to the material shader
virtual void updateShadows(const ofShader &shader, ofGLProgrammableRenderer &renderer) const =0
update the given renderer's shadows to the material shader
virtual float getShininess() const =0
Definition ofGLProgrammableRenderer.h:17
Definition ofShader.h:35