aboutsummaryrefslogtreecommitdiff
path: root/vrayPlug/plugin/shaveVrayBaseBSDF.h
blob: 4216b8dda0616b635061d796014d156ca8ce4c15 (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
#ifndef _HAIR_VR_BASE_BSDF_H_
#define _HAIR_VR_BASE_BSDF_H_

// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962

/**********************************************************************
 *<
	FILE:			shaveVrayBaseBSDF.h ( was HairVrBaseBSDF.h )

	DESCRIPTION:	Generic class for BSDFs

	CREATED BY:		Vladimir Dubovoy <[email protected]>

	HISTORY:		created  09-09-2008 ( as part of 3ds Max + VRay hair shaders)
					merged   31-03-2010 

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

//#include <max.h> //ShadeContext
//#include <vraybase.h>
//#include <vectorbase.h> 
//#include <vrayinterface.h> 
//#include <vrayplugins.h> 
//#include <vraygeom.h>

#include "utils.h"
#include "vrayplugins.h"
#include "brdfs.h"

#include "hairAPIvray.h"
#include "vray3_compat.h"

class shaveVrayBaseBSDF : public IShaveVrayBSDF
						 //public VR::BRDFSampler, 
					     //public VR::BSDFSampler 
{
public:
	// Initialization
	void init(const VR::VRayContext &rc, 
			  const VR::Color &reflectionColor, 
			  const VR::Color &diffuseColor,
			  const VR::Color &ambientColor,
			  const VR::Color &specularTint,
			  const VR::Color &specularTint2,
			  float ambDiff,
			  float specularLevel,
			  float reflectionGlossiness, 
			  int subdivs, const VR::Color &transp,
			  const VR::ShadeVec &hairDir,
			  float requiredTransparency,
			  bool  cameraVisibility,
			  bool  reflVisibility,
			  bool  refrVisibility,
			  bool  lightVisibility,
			  bool  giVisibility,
			  float selfshadow,
			  bool  recvshadow) VRAY_OVERRIDE;

	// From BRDFSampler
	VR::ShadeCol getDiffuseColor(VR::ShadeCol &lightColor) VRAY_OVERRIDE;
	VR::ShadeCol getLightMult   (VR::ShadeCol &lightColor) VRAY_OVERRIDE;
	VR::ShadeCol getTransparency(const VR::VRayContext &rc) VRAY_OVERRIDE;

	VR::ShadeCol eval(const VR::VRayContext &rc, const VR::ShadeVec &direction, 
						 VR::ShadeCol &lightColor, VR::ShadeCol &origLightColor, float probLight, int flags) VRAY_OVERRIDE;

	void traceForward(VR::VRayContext &rc, int doDiffuse) VRAY_OVERRIDE;

	VR::RenderChannelsInfo* getRenderChannels() VRAY_OVERRIDE;

	// From BSDFSampler
	VR::BRDFSampler *getBRDF(VR::BSDFSide side) VRAY_OVERRIDE;
protected:

	//const member access
	inline const VR::ShadeCol&  reflect_filter() const {return m_reflect_filter;}
	inline const VR::ShadeCol&  transparency()	  const {return m_transparency;}
	inline const VR::ShadeCol&  diffuse()		  const {return m_diffuse;}
	inline const VR::ShadeCol&  ambient()		  const {return m_ambient;}
	inline const VR::ShadeCol&	 spec_tint()	  const {return m_spec_tint;}
	inline const VR::ShadeCol&	 spec_tint2()	  const {return m_spec_tint2;}
	inline const VR::ShadeVec& normal()		  const {return m_normal; }
	inline const VR::ShadeVec& gnormal()		  const {return m_gnormal;}
	inline VR::real  glossiness()	const {return m_glossiness;}
	inline bool  combineSampling()	const {return m_combineSampling;}
	inline float ambdiff()			const {return m_ambdiff;}
	inline float speclvl()			const {return m_speclvl;}
	inline bool	 cameraVisibility() const {return m_cameraVisibility;}
	inline bool	 lightVisibility()  const {return m_lightVisibility;}
	inline bool	 giVisibility()		const {return m_giVisibility;}
	
	//member access
	inline VR::ShadeCol&  _reflect_filter() {return m_reflect_filter;}
	inline VR::ShadeCol&  _transparency()	 {return m_transparency;}
	inline VR::ShadeCol&  _diffuse()		 {return m_diffuse;}
	inline VR::ShadeCol&  _ambient()		 {return m_ambient;}
	inline VR::ShadeCol&  _spec_tint()		 {return m_spec_tint;}
	inline VR::ShadeCol&  _spec_tint2()	 {return m_spec_tint2;}
	inline VR::ShadeVec& _normal()		 {return m_normal; }
	inline VR::ShadeVec& _gnormal()		 {return m_gnormal;}
	inline VR::real&   _glossiness()	 {return m_glossiness;}
	inline bool&  _combineSampling()	 {return m_combineSampling;}
	inline float& _ambdiff()			 {return m_ambdiff;}
	inline float& _speclvl()			 {return m_speclvl;}
	inline bool&	 _cameraVisibility() {return m_cameraVisibility;}
	inline bool&	 _lightVisibility()  {return m_lightVisibility;}
	inline bool&	 _giVisibility()	 {return m_giVisibility;}

private:
	VR::ShadeCol m_reflect_filter; 
	VR::ShadeCol m_transparency;
	VR::ShadeCol m_diffuse;
	VR::ShadeCol m_ambient;
	VR::ShadeCol m_spec_tint;
	VR::ShadeCol m_spec_tint2;
	VR::real  m_glossiness;
	float     m_ambdiff;
	float	  m_speclvl;
	bool m_combineSampling;
	bool	  m_cameraVisibility;
	bool	  m_lightVisibility;
	bool	  m_giVisibility;

	VR::ShadeVec m_normal; 
	VR::ShadeVec m_gnormal;

	VR::ShadeVec hairDir;
	float currentTransp;
	float requiredTransparency;
	bool  isGatherPoint;
};

#endif	//endof_HAIR_VR_BASE_BSDF_H_