aboutsummaryrefslogtreecommitdiff
path: root/vrayPlug/plugin/shaveVrayTriShadeable.cpp
blob: 417a61136d8b1dd7440a51a912390e872e575971 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962

/**********************************************************************
 *<
	FILE:			shaveVrayTriShadeable.cpp -- implementation file 

	DESCRIPTION:	Used to shade the instanced surface

	CREATED BY:		Vladimir Dubovoy <[email protected]>

	HISTORY:		created  13-05-2010 

 *>
 **********************************************************************/

#include "shaveVrayTriShadeable.h"

shaveVrayTriShadeable::shaveVrayTriShadeable(shaveVrayTriVoxelPrim *hair)
{
	_prim() = hair;
}

shaveVrayTriShadeable::~shaveVrayTriShadeable()
{
	freeBSDFpool();
}
/*
|	from Shadeable
*/
void  shaveVrayTriShadeable::shade(VR::VRayContext &rc)
{
	BSDFShadeable::shade(rc);

	if (VUtils::hasNonFiniteLanes(rc.mtlresult.color)) {
		rc.mtlresult.color.makeZero();
	}
//#ifdef USE_WHITE_TRI_BRDF
//	VR::Color c = VR::Color(1.0f, 1.0f, 1.0f); 
//	rc.mtlresult.color *= c;
//#else
//	BSDFShadeable::shade(rc);
//#endif

	//rc.mtlresult.color.r = 1.0f;
	//rc.mtlresult.color.g = 0.0f;
	//rc.mtlresult.color.b = 0.0f;

	//rc.mtlresult.alpha.r = 0.0f;
	//rc.mtlresult.alpha.g = 0.0f;
	//rc.mtlresult.alpha.b = 0.0f;

	//rc.mtlresult.transp.r = 0.f;
	//rc.mtlresult.transp.g = 0.f;
	//rc.mtlresult.transp.b = 0.f;

	//rc.mtlresult.alphaTransp.r = 0.0f;
	//rc.mtlresult.alphaTransp.g = 0.0f;
	//rc.mtlresult.alphaTransp.b = 0.0f;
}
/*
|	from Shadeable
*/
tchar*  shaveVrayTriShadeable::getName(VR::VRayContext &rc)
{
	return const_cast<tchar*>("shaveVrayTriShadeable");
}

VR::BSDFSampler* shaveVrayTriShadeable::newBSDF (const VR::VRayContext &rc, VR::BSDFFlags flags)
{
#ifdef USE_WHITE_TRI_BRDF
	VR::WhiteBRDF *bsdf = _bsdfPool().newBRDF(rc);
	return bsdf;
#else
	#error not implemented
	//shaveVrayBaseBSDF *bsdf = _bsdfPool().newBRDF(rc);
	//if (!bsdf) 
	//	return NULL;

	//int strandIdx = rc.rayresult.faceIndex;
	//VR::Color diffCol = VR::Color(0.0f, 1.0f, 0.0f); //just green to see if somthing goes wrong

	//int segmentIdx=(int) rc.rayresult.extraf;

	//if(prim()->IsColorConst(strandIdx))
	//	prim()->GetRootColor(strandIdx,diffCol);
	//else
	//	prim()->GetInterpColor(segmentIdx, strandIdx,diffCol);

	//VR::Color specCol = VR::Color(1.0f, 1.0f, 1.0f);

	//float opacity = 1.0f;
	//if(prim()->GetTipFade())
	//	opacity = prim()->GetInterpOpacity(segmentIdx,strandIdx);
	//else
	//	opacity = prim()->GetOpacity(strandIdx);
	//
	////transparency
	//float t=1.0f-opacity;
	//VR::Color trsp = VR::Color(t, t, t);

	////ambient color [not used yet]
	//VR::Color ambientCol = prim()->GetAmbient();

	////abient/diffuse factor
	//float ambDiff = prim()->GetAmbDiff(strandIdx);

	////glossines
	//float gloss = prim()->GetGlossiness(strandIdx);

	//float splvl = prim()->GetSpecLevel(strandIdx);

	//VR::Vector hairDir=prim()->GetHairDir(rc.rayresult.origPoint, segmentIdx, strandIdx);

	//bsdf->init(rc,specCol,diffCol,ambientCol,ambDiff,splvl,gloss,0,trsp, hairDir, t);

	//return bsdf;
#endif
}

void shaveVrayTriShadeable::deleteBSDF(const VR::VRayContext &rc, VR::BSDFSampler *bsdf)
{
	if(!bsdf)
		return;
#ifdef USE_WHITE_TRI_BRDF	
	VR::WhiteBRDF *dbsdf = static_cast<VR::WhiteBRDF*>(bsdf);
#else
	#error not implemented
	//shaveVrayBaseBSDF* dbsdf = static_cast<shaveVrayBaseBSDF*>(bsdf);
#endif
	_bsdfPool().deleteBRDF(rc, dbsdf);
}

#if defined(VRAY40)
int shaveVrayTriShadeable::getBSDFFlags()
{
	return VR::bsdfFlag_none;
}
#endif

void shaveVrayTriShadeable::initBSDFpool(VR::VRayCore *vray)
{
	const VR::VRaySequenceData &sdata=vray->getSequenceData();
	_bsdfPool().init(sdata.maxRenderThreads);
}

void shaveVrayTriShadeable::freeBSDFpool()
{
	_bsdfPool().freeMem();
}