aboutsummaryrefslogtreecommitdiff
path: root/vrayPlug/plugin/shaveVrayShadeable.h
blob: f84ee73a8fb0a741a54f84ff0605716aa15517cd (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
#ifndef _HAIR_VR_SHADEABLE_H_
#define _HAIR_VR_SHADEABLE_H_

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

/**********************************************************************
 *<
	FILE:			shaveVrayShadeable.h ( was HairVrShadeable.h )

	DESCRIPTION:	Used by VRay to shade a surface

	CREATED BY:		Vladimir Dubovoy <[email protected]>

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

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

//#include <vraybase.h>
//#include <vectorbase.h> 
//#include <vrayinterface.h> 
//#include <vrayplugins.h> 
//#include <vraygeom.h>
//#include <brdfs.h> 
//#include <brdfpool.h>

#include "hairAPIvrayutil.h"
#include "hairAPIvray.h"

#include "utils.h"
#include "box.h"
#include "rayserver.h"
#include "vrayplugins.h"
#include "geometryclasses.h"
#include "brdfs.h"
#include "brdfpool.h"

#include "shaveVrayVoxelPrim.h"
#include "shaveVrayBaseBSDF.h"

//#define USE_WHITE_BRDF

class shaveVrayShadeable : public /*VR::Shadeable*/ VR::BSDFShadeable {
public:
	shaveVrayShadeable(shaveVrayVoxelPrim* hair);
	~shaveVrayShadeable();
	/*
	|	from Shadeable
	*/
	//  This is called to shade the intersection in the rayresult member of the given context. 
	void  shade(VR::VRayContext &rc) VRAY_OVERRIDE;
	
	//Returns the name of the shadeable; used to print warnings if any shading errors occur. 
	tchar*  getName(VR::VRayContext &rc) VRAY_OVERRIDE;

	/*
	|
	*/
	VR::BSDFSampler* newBSDF (const VR::VRayContext &rc, VR::BSDFFlags flags) VRAY_OVERRIDE;
 
	void deleteBSDF(const VR::VRayContext &rc, VR::BSDFSampler *bsdf) VRAY_OVERRIDE;

#if defined VRAY40
	int getBSDFFlags() VRAY_OVERRIDE;
#endif

	/*
	|	own
	*/
	void initBSDFpool(VR::VRayCore *vray);

	void freeBSDFpool();

protected:
	//const member access
#ifdef USE_WHITE_BRDF
	inline const VR::BRDFPool<VR::WhiteBRDF>& bsdfPool() const {return m_bsdfPool;}
#else
	//inline const VR::BRDFPool<shaveVrayBaseBSDF>& bsdfPool() const {return m_bsdfPool;}
	inline IShaveBSDFPool*     bsdfPool() {return m_bsdfPool;}
#endif
	inline shaveVrayVoxelPrim* prim() const {return m_prim;}
	//inline IHairVoxel* prim() const {return m_prim;}

	//const member access
#ifdef USE_WHITE_BRDF
	inline VR::BRDFPool<VR::WhiteBRDF>& _bsdfPool() {return m_bsdfPool;}
#else
	//inline VR::BRDFPool<shaveVrayBaseBSDF>& _bsdfPool() {return m_bsdfPool;}
	inline IShaveBSDFPool*&     _bsdfPool() {return m_bsdfPool;}
#endif
	inline shaveVrayVoxelPrim*& _prim() {return m_prim;}
	//inline IHairVoxel*& _prim() {return m_prim;}

protected:
#ifdef USE_WHITE_BRDF
	VR::BRDFPool<VR::WhiteBRDF> m_bsdfPool;
#else
	//VR::BRDFPool<shaveVrayBaseBSDF> m_bsdfPool;
	IShaveBSDFPool* m_bsdfPool;
#endif
	shaveVrayVoxelPrim* m_prim;
	//IHairVoxel* m_prim;
};

#endif //end of_HAIR_VR_SHADEABLE_H_