reference

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

ofMaterialSettings Class Reference

#include <ofMaterial.h>

Public Attributes

ofFloatColor diffuse { 0.8f, 0.8f, 0.8f, 1.0f }
 diffuse reflectance
 
ofFloatColor ambient { 0.2f, 0.2f, 0.2f, 1.0f }
 ambient reflectance
 
ofFloatColor specular { 0.0f, 0.0f, 0.0f, 1.0f }
 specular reflectance
 
ofFloatColor emissive { 0.0f, 0.0f, 0.0f, 1.0f }
 emitted light intensity
 
float shininess { 0.2f }
 specular exponent
 
bool isPbr = false
 
float metallic {0.0}
 metallic properties, can be fraction between 0 -> 1
 
float roughness {0.5}
 roughness
 
float reflectance {0.5}
 reflectance only applies to dielectric materials (non-metallic)
 
bool clearCoatEnabled = false
 this must be enabled for clear coat to have effect, will be enabled if clear coat texture set
 
float clearCoatStrength = 1.0
 
float clearCoatRoughness = 0.1
 
float displacementStrength = 0.2
 strength of vertex displacement from displacement map in world space
 
float displacementNormalsStrength = 50.0
 strength of normal calculation based on displacement map
 
float normalGeomToNormalMapMix = 0.95
 if a normal map is set, the mix between the geometry normal and normal from the normal / displacement map
 
glm::vec2 texCoordScale = { 1.0,1.0 }
 
std::string postFragment =""
 
std::string customUniforms =""
 
std::string uniqueIdString =""
 set by ofMaterial::setCustomUniform* not to be set manually
 
std::string mainFragment =""
 set by ofMaterial to cache shader
 
std::string mainFragmentKey =""
 override the default main function in the frag shader
 
std::string mainVertex =""
 access fragment main function with this key make unique for new instances
 
std::string mainVertexKey =""
 override the default main function in the vertex shader
 

Detailed Description

wrapper for material color properties and other settings

customUniforms: adds some uniforms to the shader so they can be accessed from the postFragment function

postFragment: Adds a function to the material shader that will get executed after all lighting and material calculations

The source passed has to include a function with the signature:

vec4 postFragment(vec4 localColor){ return localColor; }

which will receive the final color after calculating all the lights and material and can modify it and return a new color

The function has access to the following variables:

vec2 v_texcoord;          // texture coordinate
vec3 v_normal;            // normal at this fragment
vec3 v_transformedNormal; // normal multiplied by the normal matrix
vec3 v_eyePosition;       // position of this fragment in eye coordinates
vec3 v_worldPosition;     // position of this fragment in world coordinates
vec4 v_color;             // color interpolated from the vertex colors
SAMPLER tex0;             // the bound texture if there's any

vec4 mat_ambient;         // material ambient color
vec4 mat_diffuse;         // material diffuse color
vec4 mat_specular;        // material specular
vec4 mat_emissive;        // material emissive
float mat_shininess;      // material shininess

vec4 global_ambient;      // global ambient light
mat4 modelViewMatrix;     // model view matrix
mat4 projectionMatrix;    // projection matrix
mat4 textureMatrix;       // texture matrix
mat4 modelViewProjectionMatrix; // model view projection matrix

MAX_LIGHTS                // the total number of lights in the scen

And an array of lights each light has the following properties:

float lights[i].enabled;
vec4 lights[i].ambient;
float lights[i].type;     // 0 = pointlight
                          // 1 = directionlight
                          // 2 = spotlight
                          // 3 = area
vec4 lights[i].position;  // where are we
vec4 lights[i].diffuse;   // how diffuse
vec4 lights[i].specular;  // what kinda specular stuff we got going on?

// attenuation, how the light attenuates with the distance
float lights[i].constantAttenuation;
float lights[i].linearAttenuation;
float lights[i].quadraticAttenuation;

// only for spot
float lights[i].spotCutoff;
float lights[i].spotCosCutoff;
float lights[i].spotExponent;

// spot and area
vec3 lights[i].spotDirection;

// only for directional
vec3 lights[i].halfVector;

// only for area
float lights[i].width;
float lights[i].height;
vec3 lights[i].right;
vec3 lights[i].up;

Member Data Documentation

◆ ambient

ofFloatColor ofMaterialSettings::ambient { 0.2f, 0.2f, 0.2f, 1.0f }

ambient reflectance

◆ clearCoatEnabled

bool ofMaterialSettings::clearCoatEnabled = false

this must be enabled for clear coat to have effect, will be enabled if clear coat texture set

◆ clearCoatRoughness

float ofMaterialSettings::clearCoatRoughness = 0.1

◆ clearCoatStrength

float ofMaterialSettings::clearCoatStrength = 1.0

◆ customUniforms

std::string ofMaterialSettings::customUniforms =""

◆ diffuse

ofFloatColor ofMaterialSettings::diffuse { 0.8f, 0.8f, 0.8f, 1.0f }

diffuse reflectance

◆ displacementNormalsStrength

float ofMaterialSettings::displacementNormalsStrength = 50.0

strength of normal calculation based on displacement map

◆ displacementStrength

float ofMaterialSettings::displacementStrength = 0.2

strength of vertex displacement from displacement map in world space

◆ emissive

ofFloatColor ofMaterialSettings::emissive { 0.0f, 0.0f, 0.0f, 1.0f }

emitted light intensity

◆ isPbr

bool ofMaterialSettings::isPbr = false

◆ mainFragment

std::string ofMaterialSettings::mainFragment =""

set by ofMaterial to cache shader

◆ mainFragmentKey

std::string ofMaterialSettings::mainFragmentKey =""

override the default main function in the frag shader

◆ mainVertex

std::string ofMaterialSettings::mainVertex =""

access fragment main function with this key make unique for new instances

◆ mainVertexKey

std::string ofMaterialSettings::mainVertexKey =""

override the default main function in the vertex shader

◆ metallic

float ofMaterialSettings::metallic {0.0}

metallic properties, can be fraction between 0 -> 1

◆ normalGeomToNormalMapMix

float ofMaterialSettings::normalGeomToNormalMapMix = 0.95

if a normal map is set, the mix between the geometry normal and normal from the normal / displacement map

◆ postFragment

std::string ofMaterialSettings::postFragment =""

◆ reflectance

float ofMaterialSettings::reflectance {0.5}

reflectance only applies to dielectric materials (non-metallic)

◆ roughness

float ofMaterialSettings::roughness {0.5}

roughness

◆ shininess

float ofMaterialSettings::shininess { 0.2f }

specular exponent

◆ specular

ofFloatColor ofMaterialSettings::specular { 0.0f, 0.0f, 0.0f, 1.0f }

specular reflectance

◆ texCoordScale

glm::vec2 ofMaterialSettings::texCoordScale = { 1.0,1.0 }

◆ uniqueIdString

std::string ofMaterialSettings::uniqueIdString =""

set by ofMaterial::setCustomUniform* not to be set manually


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