YafaRay Core  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
material_t Class Referenceabstract

#include <material.h>

Inheritance diagram for material_t:
Inheritance graph
[legend]
Collaboration diagram for material_t:
Collaboration graph
[legend]

Public Member Functions

 material_t ()
 
virtual ~material_t ()
 
virtual void initBSDF (const renderState_t &state, surfacePoint_t &sp, BSDF_t &bsdfTypes) const =0
 
virtual color_t eval (const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wl, BSDF_t types, bool force_eval=false) const =0
 
virtual color_t sample (const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, vector3d_t &wi, sample_t &s, float &W) const =0
 
virtual color_t sample (const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, vector3d_t *const dir, color_t &tcol, sample_t &s, float *const W) const
 
virtual color_t sampleClay (const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, vector3d_t &wi, sample_t &s, float &W) const
 
virtual float pdf (const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wi, BSDF_t bsdfs) const
 
virtual bool isTransparent () const
 
virtual color_t getTransparency (const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const
 
virtual void getSpecular (const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, bool &reflect, bool &refract, vector3d_t *const dir, color_t *const col) const
 
virtual color_t getReflectivity (const renderState_t &state, const surfacePoint_t &sp, BSDF_t flags) const
 
virtual color_t emit (const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const
 
virtual const volumeHandler_tgetVolumeHandler (bool inside) const
 
virtual float getAlpha (const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const
 
virtual bool scatterPhoton (const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wi, vector3d_t &wo, pSample_t &s) const
 
BSDF_t getFlags () const
 
size_t getReqMem () const
 
virtual float getMatIOR () const
 
virtual color_t getDiffuseColor (const renderState_t &state) const
 
virtual color_t getGlossyColor (const renderState_t &state) const
 
virtual color_t getTransColor (const renderState_t &state) const
 
virtual color_t getMirrorColor (const renderState_t &state) const
 
virtual color_t getSubSurfaceColor (const renderState_t &state) const
 
void setMaterialIndex (const float &newMatIndex)
 
void resetMaterialIndex ()
 
void setMaterialIndex (const int &newMatIndex)
 
float getAbsMaterialIndex () const
 
float getNormMaterialIndex () const
 
color_t getAbsMaterialIndexColor () const
 
color_t getNormMaterialIndexColor () const
 
color_t getAutoMaterialIndexColor () const
 
color_t getAutoMaterialIndexNumber () const
 
visibility_t getVisibility () const
 
bool getReceiveShadows () const
 
int getAdditionalDepth () const
 
void applyWireFrame (float &value, float wireFrameAmount, const surfacePoint_t &sp) const
 
void applyWireFrame (color_t &col, float wireFrameAmount, const surfacePoint_t &sp) const
 
void applyWireFrame (color_t *const col, float wireFrameAmount, const surfacePoint_t &sp) const
 
void applyWireFrame (colorA_t &col, float wireFrameAmount, const surfacePoint_t &sp) const
 
void applyWireFrame (colorA_t *const col, float wireFrameAmount, const surfacePoint_t &sp) const
 
void setSamplingFactor (const float &newSamplingFactor)
 
float getSamplingFactor () const
 

Protected Member Functions

void applyBump (surfacePoint_t &sp, float dfdNU, float dfdNV) const
 

Protected Attributes

BSDF_t bsdfFlags
 
visibility_t mVisibility
 sets material visibility (Normal:visible, visible without shadows, invisible (shadows only) or totally invisible. More...
 
bool mReceiveShadows
 enables/disables material reception of shadows. More...
 
size_t reqMem
 the amount of "temporary" memory required to compute/store surface point specific data More...
 
volumeHandler_tvolI
 volumetric handler for space inside material (opposed to surface normal) More...
 
volumeHandler_tvolO
 volumetric handler for space outside ofmaterial (where surface normal points to) More...
 
float materialIndex
 Material Index for the material-index render pass. More...
 
color_t materialIndexAutoColor
 Material Index color automatically generated for the material-index-auto (color) render pass. More...
 
float materialIndexAutoNumber = 0.f
 Material Index number automatically generated for the material-index-auto-abs (numeric) render pass. More...
 
int additionalDepth
 Per-material additional ray-depth. More...
 
float mWireFrameAmount = 0.f
 Wireframe shading amount. More...
 
float mWireFrameThickness = 0.01f
 Wireframe thickness. More...
 
float mWireFrameExponent = 0.f
 Wireframe exponent (0.f = solid, 1.f=linearly gradual, etc) More...
 
color_t mWireFrameColor = color_t(1.f)
 Wireframe shading color. More...
 
float mSamplingFactor = 1.f
 Material sampling factor, to allow some materials to receive more samples than others. More...
 

Static Protected Attributes

static unsigned int materialIndexAuto = 0
 Material Index automatically generated for the material-index-auto render pass. More...
 
static float highestMaterialIndex = 1.f
 Class shared variable containing the highest material index used for the Normalized Material Index pass. More...
 
static float mHighestSamplingFactor = 1.f
 Class shared variable containing the highest material sampling factor. This is used to calculate the max. possible samples for the Sampling pass. More...
 

Detailed Description

Definition at line 82 of file material.h.

Constructor & Destructor Documentation

material_t::material_t ( )
inline

Definition at line 85 of file material.h.

virtual material_t::~material_t ( )
inlinevirtual

Definition at line 100 of file material.h.

Member Function Documentation

void material_t::applyBump ( surfacePoint_t sp,
float  dfdNU,
float  dfdNV 
) const
protected

Definition at line 75 of file material.cc.

void material_t::applyWireFrame ( float &  value,
float  wireFrameAmount,
const surfacePoint_t sp 
) const
inline

Definition at line 258 of file material.h.

void material_t::applyWireFrame ( color_t col,
float  wireFrameAmount,
const surfacePoint_t sp 
) const
inline

Definition at line 274 of file material.h.

void material_t::applyWireFrame ( color_t *const  col,
float  wireFrameAmount,
const surfacePoint_t sp 
) const
inline

Definition at line 291 of file material.h.

void material_t::applyWireFrame ( colorA_t col,
float  wireFrameAmount,
const surfacePoint_t sp 
) const
inline

Definition at line 309 of file material.h.

void material_t::applyWireFrame ( colorA_t *const  col,
float  wireFrameAmount,
const surfacePoint_t sp 
) const
inline

Definition at line 327 of file material.h.

virtual color_t material_t::emit ( const renderState_t state,
const surfacePoint_t sp,
const vector3d_t wo 
) const
inlinevirtual

allow light emitting materials, for realizing correctly visible area lights. default implementation returns black obviously.

Reimplemented in lightMat_t, shinyDiffuseMat_t, blendMat_t, and maskMat_t.

Definition at line 157 of file material.h.

virtual color_t material_t::eval ( const renderState_t state,
const surfacePoint_t sp,
const vector3d_t wo,
const vector3d_t wl,
BSDF_t  types,
bool  force_eval = false 
) const
pure virtual

evaluate the BSDF for the given components.

Parameters
typesthe types of BSDFs to be evaluated (e.g. diffuse only, or diffuse and glossy)

Implemented in nullMat_t, mirrorMat_t, coatedGlossyMat_t, lightMat_t, glossyMat_t, glassMat_t, shinyDiffuseMat_t, blendMat_t, maskMat_t, and roughGlassMat_t.

float material_t::getAbsMaterialIndex ( ) const
inline

Definition at line 190 of file material.h.

color_t material_t::getAbsMaterialIndexColor ( ) const
inline

Definition at line 192 of file material.h.

int material_t::getAdditionalDepth ( ) const
inline

Definition at line 212 of file material.h.

virtual float material_t::getAlpha ( const renderState_t state,
const surfacePoint_t sp,
const vector3d_t wo 
) const
inlinevirtual

special function, get the alpha-value of a material, used to calculate the alpha-channel

Reimplemented in shinyDiffuseMat_t, glassMat_t, blendMat_t, maskMat_t, and roughGlassMat_t.

Definition at line 164 of file material.h.

color_t material_t::getAutoMaterialIndexColor ( ) const
inline

Definition at line 201 of file material.h.

color_t material_t::getAutoMaterialIndexNumber ( ) const
inline

Definition at line 205 of file material.h.

virtual color_t material_t::getDiffuseColor ( const renderState_t state) const
inlinevirtual

Reimplemented in coatedGlossyMat_t, glossyMat_t, and shinyDiffuseMat_t.

Definition at line 178 of file material.h.

BSDF_t material_t::getFlags ( ) const
inline

Definition at line 170 of file material.h.

virtual color_t material_t::getGlossyColor ( const renderState_t state) const
inlinevirtual

Reimplemented in coatedGlossyMat_t, glossyMat_t, shinyDiffuseMat_t, glassMat_t, and roughGlassMat_t.

Definition at line 179 of file material.h.

virtual float material_t::getMatIOR ( ) const
inlinevirtual

Get materials IOR (for refracted photons)

Reimplemented in glassMat_t, blendMat_t, and roughGlassMat_t.

Definition at line 177 of file material.h.

virtual color_t material_t::getMirrorColor ( const renderState_t state) const
inlinevirtual

Reimplemented in coatedGlossyMat_t, shinyDiffuseMat_t, glassMat_t, and roughGlassMat_t.

Definition at line 181 of file material.h.

float material_t::getNormMaterialIndex ( ) const
inline

Definition at line 191 of file material.h.

color_t material_t::getNormMaterialIndexColor ( ) const
inline

Definition at line 196 of file material.h.

bool material_t::getReceiveShadows ( ) const
inline

Definition at line 211 of file material.h.

color_t material_t::getReflectivity ( const renderState_t state,
const surfacePoint_t sp,
BSDF_t  flags 
) const
virtual

get the overall reflectivity of the material (used to compute radiance map for example)

Definition at line 54 of file material.cc.

size_t material_t::getReqMem ( ) const
inline

Materials may have to do surface point specific (pre-)calculation that need extra storage. returns the required amount of "userdata" memory for all the functions that require a render state

Definition at line 173 of file material.h.

float material_t::getSamplingFactor ( ) const
inline

Definition at line 225 of file material.h.

virtual void material_t::getSpecular ( const renderState_t state,
const surfacePoint_t sp,
const vector3d_t wo,
bool &  reflect,
bool &  refract,
vector3d_t *const  dir,
color_t *const  col 
) const
inlinevirtual

evaluate the specular components for given direction. Somewhat a specialization of sample(), because neither sample values nor pdf values are necessary for this. Typical use: recursive raytracing of integrators.

Parameters
dirdir[0] returns reflected direction, dir[1] refracted direction
colcol[0] returns reflected spectrum, dir[1] refracted spectrum

Reimplemented in mirrorMat_t, coatedGlossyMat_t, glassMat_t, shinyDiffuseMat_t, blendMat_t, and maskMat_t.

Definition at line 148 of file material.h.

virtual color_t material_t::getSubSurfaceColor ( const renderState_t state) const
inlinevirtual

Reimplemented in shinyDiffuseMat_t.

Definition at line 182 of file material.h.

virtual color_t material_t::getTransColor ( const renderState_t state) const
inlinevirtual

Reimplemented in shinyDiffuseMat_t, glassMat_t, and roughGlassMat_t.

Definition at line 180 of file material.h.

virtual color_t material_t::getTransparency ( const renderState_t state,
const surfacePoint_t sp,
const vector3d_t wo 
) const
inlinevirtual

used for computing transparent shadows. Default implementation returns black (i.e. solid shadow). This is only used for shadow calculations and may only be called when isTransparent returned true.

Reimplemented in glassMat_t, shinyDiffuseMat_t, blendMat_t, maskMat_t, and roughGlassMat_t.

Definition at line 142 of file material.h.

visibility_t material_t::getVisibility ( ) const
inline

Definition at line 210 of file material.h.

virtual const volumeHandler_t* material_t::getVolumeHandler ( bool  inside) const
inlinevirtual

get the volumetric handler for space at specified side of the surface

Parameters
insidetrue means space opposite of surface normal, which is considered "inside"

Reimplemented in blendMat_t.

Definition at line 161 of file material.h.

virtual void material_t::initBSDF ( const renderState_t state,
surfacePoint_t sp,
BSDF_t bsdfTypes 
) const
pure virtual

Initialize the BSDF of a material. You must call this with the current surface point first before any other methods (except isTransparent/getTransparency)! The renderstate holds a pointer to preallocated userdata to save data that only depends on the current sp, like texture lookups etc.

Parameters
bsdfTypesreturns flags for all bsdf components the material has

Implemented in nullMat_t, mirrorMat_t, coatedGlossyMat_t, lightMat_t, glossyMat_t, glassMat_t, shinyDiffuseMat_t, blendMat_t, maskMat_t, and roughGlassMat_t.

virtual bool material_t::isTransparent ( ) const
inlinevirtual

indicate whether light can (partially) pass the material without getting refracted, e.g. a curtain or even very thin foils approximated as single non-refractive layer. used to trace transparent shadows. Note that in this case, initBSDF was NOT called before!

Reimplemented in glassMat_t, shinyDiffuseMat_t, blendMat_t, maskMat_t, and roughGlassMat_t.

Definition at line 138 of file material.h.

virtual float material_t::pdf ( const renderState_t state,
const surfacePoint_t sp,
const vector3d_t wo,
const vector3d_t wi,
BSDF_t  bsdfs 
) const
inlinevirtual

return the pdf for sampling the BSDF with wi and wo

Reimplemented in coatedGlossyMat_t, lightMat_t, glossyMat_t, glassMat_t, shinyDiffuseMat_t, blendMat_t, maskMat_t, and roughGlassMat_t.

Definition at line 131 of file material.h.

void material_t::resetMaterialIndex ( )
inline

Definition at line 188 of file material.h.

virtual color_t material_t::sample ( const renderState_t state,
const surfacePoint_t sp,
const vector3d_t wo,
vector3d_t wi,
sample_t s,
float &  W 
) const
pure virtual

take a sample from the BSDF, given a 2-dimensional sample value and the BSDF types to be sampled from

Parameters
ss1, s2 and flags members give necessary information for creating the sample, pdf and sampledFlags need to be returned
Wreturns the weight for importance sampling

Implemented in nullMat_t, mirrorMat_t, coatedGlossyMat_t, lightMat_t, glossyMat_t, glassMat_t, shinyDiffuseMat_t, blendMat_t, maskMat_t, and roughGlassMat_t.

virtual color_t material_t::sample ( const renderState_t state,
const surfacePoint_t sp,
const vector3d_t wo,
vector3d_t *const  dir,
color_t tcol,
sample_t s,
float *const  W 
) const
inlinevirtual

Reimplemented in blendMat_t, and roughGlassMat_t.

Definition at line 119 of file material.h.

virtual color_t material_t::sampleClay ( const renderState_t state,
const surfacePoint_t sp,
const vector3d_t wo,
vector3d_t wi,
sample_t s,
float &  W 
) const
inlinevirtual

Definition at line 121 of file material.h.

bool material_t::scatterPhoton ( const renderState_t state,
const surfacePoint_t sp,
const vector3d_t wi,
vector3d_t wo,
pSample_t s 
) const
virtual

specialized function for photon mapping. Default function uses the sample function, which will do fine for most materials unless there's a less expensive way or smarter scattering approach

Reimplemented in blendMat_t.

Definition at line 35 of file material.cc.

void material_t::setMaterialIndex ( const float &  newMatIndex)
inline

Definition at line 183 of file material.h.

void material_t::setMaterialIndex ( const int &  newMatIndex)
inline

Definition at line 189 of file material.h.

void material_t::setSamplingFactor ( const float &  newSamplingFactor)
inline

Definition at line 220 of file material.h.

Member Data Documentation

int material_t::additionalDepth
protected

Per-material additional ray-depth.

Definition at line 246 of file material.h.

BSDF_t material_t::bsdfFlags
protected

Definition at line 232 of file material.h.

__BEGIN_YAFRAY float material_t::highestMaterialIndex = 1.f
staticprotected

Class shared variable containing the highest material index used for the Normalized Material Index pass.

Definition at line 245 of file material.h.

float material_t::materialIndex
protected

Material Index for the material-index render pass.

Definition at line 241 of file material.h.

unsigned int material_t::materialIndexAuto = 0
staticprotected

Material Index automatically generated for the material-index-auto render pass.

Definition at line 242 of file material.h.

color_t material_t::materialIndexAutoColor
protected

Material Index color automatically generated for the material-index-auto (color) render pass.

Definition at line 243 of file material.h.

float material_t::materialIndexAutoNumber = 0.f
protected

Material Index number automatically generated for the material-index-auto-abs (numeric) render pass.

Definition at line 244 of file material.h.

float material_t::mHighestSamplingFactor = 1.f
staticprotected

Class shared variable containing the highest material sampling factor. This is used to calculate the max. possible samples for the Sampling pass.

Definition at line 254 of file material.h.

bool material_t::mReceiveShadows
protected

enables/disables material reception of shadows.

Definition at line 236 of file material.h.

float material_t::mSamplingFactor = 1.f
protected

Material sampling factor, to allow some materials to receive more samples than others.

Definition at line 253 of file material.h.

visibility_t material_t::mVisibility
protected

sets material visibility (Normal:visible, visible without shadows, invisible (shadows only) or totally invisible.

Definition at line 234 of file material.h.

float material_t::mWireFrameAmount = 0.f
protected

Wireframe shading amount.

Definition at line 248 of file material.h.

color_t material_t::mWireFrameColor = color_t(1.f)
protected

Wireframe shading color.

Definition at line 251 of file material.h.

float material_t::mWireFrameExponent = 0.f
protected

Wireframe exponent (0.f = solid, 1.f=linearly gradual, etc)

Definition at line 250 of file material.h.

float material_t::mWireFrameThickness = 0.01f
protected

Wireframe thickness.

Definition at line 249 of file material.h.

size_t material_t::reqMem
protected

the amount of "temporary" memory required to compute/store surface point specific data

Definition at line 238 of file material.h.

volumeHandler_t* material_t::volI
protected

volumetric handler for space inside material (opposed to surface normal)

Definition at line 239 of file material.h.

volumeHandler_t* material_t::volO
protected

volumetric handler for space outside ofmaterial (where surface normal points to)

Definition at line 240 of file material.h.


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