Skip to content

Commit ef68a10

Browse files
author
subcomandante
committed
Refactor
- Fixed some variable names
1 parent 76c67f5 commit ef68a10

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

include/materials/shinydiff.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ __BEGIN_YAFRAY
2525
class shinyDiffuseMat_t: public nodeMaterial_t
2626
{
2727
public:
28-
shinyDiffuseMat_t(const color_t &col, const color_t &srcol, float diffuse, float transp=0.0, float transl=0.0, float sp_refl=0.0, float emit=0.0);
28+
shinyDiffuseMat_t(const color_t &diffuseColor, const color_t &mirrorColor, float diffuseStrength, float transparencyStrength, float translucencyStrength, float mirrorStrength, float emitStrength);
2929
virtual ~shinyDiffuseMat_t();
3030
virtual void initBSDF(const renderState_t &state, const surfacePoint_t &sp, BSDF_t &bsdfTypes)const;
3131
virtual color_t eval(const renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, const vector3d_t &wl, BSDF_t bsdfs)const;

src/materials/shinydiff.cc

+29-24
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
__BEGIN_YAFRAY
77

8-
shinyDiffuseMat_t::shinyDiffuseMat_t(const color_t &col, const color_t &srcol, float diffuse, float transp, float transl, float sp_refl, float emit):
8+
shinyDiffuseMat_t::shinyDiffuseMat_t(const color_t &diffuseColor, const color_t &mirrorColor, float diffuseStrength, float transp, float transl, float mirrorStrength, float emitStrength):
99
mIsTransparent(false), mIsTranslucent(false), mIsMirror(false), mIsDiffuse(false), mHasFresnelEffect(false),
10-
mDiffuseShader(0), mBumpShader(0), mTransparencyShader(0), mTranslucencyShader(0), mMirrorShader(0), mMirrorColorShader(0), mDiffuseColor(col), mMirrorColor(srcol),
11-
mMirrorStrength(sp_refl), mTransparencyStrength(transp), mTranslucencyStrength(transl), mDiffuseStrength(diffuse), mUseOrenNayar(false), nBSDF(0)
10+
mDiffuseShader(0), mBumpShader(0), mTransparencyShader(0), mTranslucencyShader(0), mMirrorShader(0), mMirrorColorShader(0), mDiffuseColor(diffuseColor), mMirrorColor(mirrorColor),
11+
mMirrorStrength(mirrorStrength), mTransparencyStrength(transp), mTranslucencyStrength(transl), mDiffuseStrength(diffuseStrength), mUseOrenNayar(false), nBSDF(0)
1212
{
13-
mEmitColor = emit*col;
14-
mEmitStrength = emit;
13+
mEmitColor = emitStrength * diffuseColor;
14+
mEmitStrength = emitStrength;
1515
bsdfFlags = BSDF_NONE;
1616
if(mEmitStrength > 0.f) bsdfFlags |= BSDF_EMIT;
1717
}
@@ -461,34 +461,37 @@ CFLOAT shinyDiffuseMat_t::getAlpha(const renderState_t &state, const surfacePoin
461461

462462
material_t* shinyDiffuseMat_t::factory(paraMap_t &params, std::list<paraMap_t> &paramsList, renderEnvironment_t &render)
463463
{
464-
shinyDiffuseMat_t *mat;
465-
color_t col=1.f, srCol=1.f;
466-
const std::string *name=0;
467-
float transparency=0.f, emit=0.f, translucency=0.f;
468-
float sp_refl=0.f;
469-
bool fresnEff=false;
464+
/// Material Parameters
465+
color_t diffuseColor=1.f;
466+
color_t mirrorColor=1.f;
467+
CFLOAT diffuseStrength=1.f;
468+
float transparencyStrength=0.f;
469+
float translucencyStrength=0.f;
470+
float mirrorStrength=0.f;
471+
float emitStrength = 0.f;
472+
bool fresnelEffect=false;
470473
double IOR = 1.33, filt=1.0;
471-
CFLOAT diffuse=1.f;
472-
//bool error=false;
473-
params.getParam("color", col);
474-
params.getParam("mirror_color", srCol);
475-
params.getParam("transparency", transparency);
476-
params.getParam("translucency", translucency);
477-
params.getParam("diffuse_reflect", diffuse);
478-
params.getParam("specular_reflect", sp_refl);
479-
params.getParam("emit", emit);
474+
params.getParam("color", diffuseColor);
475+
params.getParam("mirror_color", mirrorColor);
476+
params.getParam("transparency", transparencyStrength);
477+
params.getParam("translucency", translucencyStrength);
478+
params.getParam("diffuse_reflect", diffuseStrength);
479+
params.getParam("specular_reflect", mirrorStrength);
480+
params.getParam("emit", emitStrength);
480481
params.getParam("IOR", IOR);
481-
params.getParam("fresnel_effect", fresnEff);
482+
params.getParam("fresnel_effect", fresnelEffect);
482483
params.getParam("transmit_filter", filt);
483484
// !!remember to put diffuse multiplier in material itself!
484-
mat = new shinyDiffuseMat_t(col, srCol, diffuse, transparency, translucency, sp_refl, emit);
485+
shinyDiffuseMat_t *mat = new shinyDiffuseMat_t(diffuseColor, mirrorColor, diffuseStrength, transparencyStrength, translucencyStrength, mirrorStrength, emitStrength);
485486
mat->mTransmitFilterStrength = filt;
486487

487-
if(fresnEff)
488+
if(fresnelEffect)
488489
{
489490
mat->mIOR_Squared = IOR * IOR;
490491
mat->mHasFresnelEffect = true;
491492
}
493+
494+
const std::string *name=0;
492495
if(params.getParam("diffuse_brdf", name))
493496
{
494497
if(*name == "oren_nayar")
@@ -499,6 +502,7 @@ material_t* shinyDiffuseMat_t::factory(paraMap_t &params, std::list<paraMap_t> &
499502
}
500503
}
501504

505+
/// Material Shader Nodes
502506
std::vector<shaderNode_t *> roots;
503507
std::map<std::string, shaderNode_t *> nodeList;
504508

@@ -537,12 +541,13 @@ material_t* shinyDiffuseMat_t::factory(paraMap_t &params, std::list<paraMap_t> &
537541
if(mat->mTransparencyShader) mat->getNodeList(mat->mTransparencyShader, colorNodes);
538542
if(mat->mTranslucencyShader) mat->getNodeList(mat->mTranslucencyShader, colorNodes);
539543

540-
mat->filterNodes(colorNodes, mat->allViewdep, VIEW_DEP);
544+
mat->filterNodes(colorNodes, mat->allViewdep, VIEW_DEP);
541545
mat->filterNodes(colorNodes, mat->allViewindep, VIEW_INDEP);
542546

543547
if(mat->mBumpShader) mat->getNodeList(mat->mBumpShader, mat->bumpNodes);
544548
}
545549

550+
546551
mat->config();
547552

548553
//===!!!=== test <<< This test should go, is useless, DT

0 commit comments

Comments
 (0)