YafaRay Core  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
shinydiff.h
Go to the documentation of this file.
1 #ifndef Y_SHINYDIFFMAT_H
2 #define Y_SHINYDIFFMAT_H
3 
4 #include <yafray_config.h>
6 #include <core_api/shader.h>
7 #include <core_api/environment.h>
8 #include <core_api/color_ramp.h>
9 
11 
26 {
27  public:
28  shinyDiffuseMat_t(const color_t &diffuseColor, const color_t &mirrorColor, float diffuseStrength, float transparencyStrength=0.0, float translucencyStrength=0.0, float mirrorStrength=0.0, float emitStrength=0.0, float transmitFilterStrength=1.0, visibility_t eVisibility=NORMAL_VISIBLE);
29  virtual ~shinyDiffuseMat_t();
30  virtual void initBSDF(const renderState_t &state, surfacePoint_t &sp, BSDF_t &bsdfTypes)const;
31  virtual color_t eval(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wl, BSDF_t bsdfs, bool force_eval = false)const;
32  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;
33  virtual float pdf(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wi, BSDF_t bsdfs)const;
34  virtual bool isTransparent() const { return mIsTransparent; }
35  virtual color_t getTransparency(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const;
36  virtual color_t emit(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const; // { return emitCol; }
37  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;
38  virtual float getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo)const;
39  virtual color_t getDiffuseColor(const renderState_t &state) const
40  {
41  SDDat_t *dat = (SDDat_t *)state.userdata;
42  nodeStack_t stack(dat->nodeStack);
43 
45  else return color_t(0.f);
46  }
47  virtual color_t getGlossyColor(const renderState_t &state) const
48  {
49  SDDat_t *dat = (SDDat_t *)state.userdata;
50  nodeStack_t stack(dat->nodeStack);
51 
53  else return color_t(0.f);
54  }
55  virtual color_t getTransColor(const renderState_t &state) const
56  {
57  SDDat_t *dat = (SDDat_t *)state.userdata;
58  nodeStack_t stack(dat->nodeStack);
59 
61  else return color_t(0.f);
62  }
63  virtual color_t getMirrorColor(const renderState_t &state) const
64  {
65  SDDat_t *dat = (SDDat_t *)state.userdata;
66  nodeStack_t stack(dat->nodeStack);
67 
69  else return color_t(0.f);
70  }
71  virtual color_t getSubSurfaceColor(const renderState_t &state) const
72  {
73  SDDat_t *dat = (SDDat_t *)state.userdata;
74  nodeStack_t stack(dat->nodeStack);
75 
77  else return color_t(0.f);
78  }
79 
80  static material_t* factory(paraMap_t &params, std::list<paraMap_t> &eparams, renderEnvironment_t &render);
81 
82  struct SDDat_t
83  {
84  float component[4];
85  void *nodeStack;
86  };
87 
88  protected:
89  void config();
90  int getComponents(const bool *useNode, nodeStack_t &stack, float *component) const;
91  void getFresnel(const vector3d_t &wo, const vector3d_t &N, float &Kr, float &currentIORSquared) const;
92 
93  void initOrenNayar(double sigma);
94  float OrenNayar(const vector3d_t &wi, const vector3d_t &wo, const vector3d_t &N, bool useTextureSigma, double textureSigma) const;
95 
96  bool mIsTransparent = false;
97  bool mIsTranslucent = false;
98  bool mIsMirror = false;
99  bool mIsDiffuse = false;
100 
101  bool mHasFresnelEffect = false;
102  float IOR = 1.f;
103  float mIOR_Squared = 1.f;
104 
105  bool viNodes[4], vdNodes[4];
114  shaderNode_t *iorS = nullptr;
116 
126 
127  bool mUseOrenNayar = false;
128  float mOrenNayar_A = 0.f;
129  float mOrenNayar_B = 0.f;
130 
131  int nBSDF = 0;
132 
134  int cIndex[4];
135 };
136 
137 
139 
140 #endif // Y_SHINYDIFFMAT_H
virtual color_t getTransparency(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const
shaderNode_t * mSigmaOrenShader
Shader node for sigma in Oren Nayar material.
Definition: shinydiff.h:112
float mTransmitFilterStrength
determines how strong light passing through material gets tinted
Definition: shinydiff.h:125
float mEmitStrength
Emit strength.
Definition: shinydiff.h:124
color_t mMirrorColor
BSDF Mirror component color.
Definition: shinydiff.h:119
virtual color_t emit(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const
bool mIsMirror
Boolean value which is true if you have specular reflection component.
Definition: shinydiff.h:98
float OrenNayar(const vector3d_t &wi, const vector3d_t &wo, const vector3d_t &N, bool useTextureSigma, double textureSigma) const
void initOrenNayar(double sigma)
float mIOR_Squared
Squared IOR.
Definition: shinydiff.h:103
shaderNode_t * mWireFrameShader
Shader node for wireframe shading (float)
Definition: shinydiff.h:115
float getScalar(const nodeStack_t &stack) const
Definition: shader.h:84
shaderNode_t * mDiffuseReflShader
Shader node for diffuse reflection strength (float)
Definition: shinydiff.h:113
bool vdNodes[4]
describes if the nodes are viewdependant or not (if available)
Definition: shinydiff.h:105
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
#define sigma
Definition: bglight.cc:35
#define __BEGIN_YAFRAY
bool mIsDiffuse
Boolean value which is true if you have diffuse component.
Definition: shinydiff.h:99
colorA_t getColor(const nodeStack_t &stack) const
Definition: shader.h:82
visibility_t
Definition: material.h:73
float mOrenNayar_B
Oren Nayar B coefficient.
Definition: shinydiff.h:129
static material_t * factory(paraMap_t &params, std::list< paraMap_t > &eparams, renderEnvironment_t &render)
float mDiffuseStrength
BSDF Diffuse component strength when not textured.
Definition: shinydiff.h:123
virtual ~shinyDiffuseMat_t()
Definition: shinydiffuse.cc:20
int cIndex[4]
list the index of the BSDF components (0=specular reflection, 1=specular transparency, 2=translucency, 3=diffuse reflection)
Definition: shinydiff.h:134
Definition: color.h:49
virtual color_t eval(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wl, BSDF_t bsdfs, bool force_eval=false) 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
bool mHasFresnelEffect
Boolean value which is true if you have Fresnel specular effect.
Definition: shinydiff.h:101
virtual color_t getTransColor(const renderState_t &state) const
Definition: shinydiff.h:55
bool mIsTransparent
Boolean value which is true if you have transparent component.
Definition: shinydiff.h:96
int getComponents(const bool *useNode, nodeStack_t &stack, float *component) const
Definition: shinydiffuse.cc:80
virtual color_t getMirrorColor(const renderState_t &state) const
Definition: shinydiff.h:63
float mOrenNayar_A
Oren Nayar A coefficient.
Definition: shinydiff.h:128
virtual color_t getSubSurfaceColor(const renderState_t &state) const
Definition: shinydiff.h:71
YAFRAYCORE_EXPORT bool refract(const vector3d_t &n, const vector3d_t &wi, vector3d_t &wo, float IOR)
Definition: vector3d.cc:86
virtual float getAlpha(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const
virtual void initBSDF(const renderState_t &state, surfacePoint_t &sp, BSDF_t &bsdfTypes) const
shinyDiffuseMat_t(const color_t &diffuseColor, const color_t &mirrorColor, float diffuseStrength, float transparencyStrength=0.0, float translucencyStrength=0.0, float mirrorStrength=0.0, float emitStrength=0.0, float transmitFilterStrength=1.0, visibility_t eVisibility=NORMAL_VISIBLE)
Definition: shinydiffuse.cc:8
virtual color_t getDiffuseColor(const renderState_t &state) const
Definition: shinydiff.h:39
color_t mDiffuseColor
BSDF Diffuse component color.
Definition: shinydiff.h:117
virtual color_t getGlossyColor(const renderState_t &state) const
Definition: shinydiff.h:47
color_t mEmitColor
Emit color.
Definition: shinydiff.h:118
void * userdata
a fixed amount of memory where materials may keep data to avoid recalculations...really need better m...
Definition: scene.h:83
virtual float pdf(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wi, BSDF_t bsdfs) const
float mMirrorStrength
BSDF Specular reflection component strength when not textured.
Definition: shinydiff.h:120
bool mIsTranslucent
Boolean value which is true if you have translucent component.
Definition: shinydiff.h:97
float mTransparencyStrength
BSDF Transparency component strength when not textured.
Definition: shinydiff.h:121
shaderNode_t * mTransparencyShader
Shader node for transparency strength (float)
Definition: shinydiff.h:108
float mTranslucencyStrength
BSDF Translucency component strength when not textured.
Definition: shinydiff.h:122
BSDF_t cFlags[4]
list the BSDF components that are present
Definition: shinydiff.h:133
unsigned int BSDF_t
Definition: material.h:49
shaderNode_t * iorS
Shader node for IOR value (float)
Definition: shinydiff.h:114
void getFresnel(const vector3d_t &wo, const vector3d_t &N, float &Kr, float &currentIORSquared) const
virtual bool isTransparent() const
Definition: shinydiff.h:34
bool mUseOrenNayar
Use Oren Nayar reflectance (default Lambertian)
Definition: shinydiff.h:127
shaderNode_t * mBumpShader
Shader node for bump.
Definition: shinydiff.h:107
shaderNode_t * mTranslucencyShader
Shader node for translucency strength (float)
Definition: shinydiff.h:109
shaderNode_t * mDiffuseShader
Shader node for diffuse color.
Definition: shinydiff.h:106
float IOR
IOR.
Definition: shinydiff.h:102
shaderNode_t * mMirrorShader
Shader node for specular reflection strength (float)
Definition: shinydiff.h:110
shaderNode_t * mMirrorColorShader
Shader node for specular reflection color.
Definition: shinydiff.h:111
#define __END_YAFRAY