View difference between Paste ID: ewwhK1PF and w2FiQdAj
SHOW: | | - or go back to the newest paste.
1
/****************************************************************************
2
  Convenient VRay Enums and Defines For Vray Materials manipulation
3
****************************************************************************/
4
5
#define VRAYMTL_CLASS_ID Class_ID(0x37bf3f2f, 0x7034695c)
6
7
#define VRAYMTL_NSUBTEX 17
8
9
#define SUBTEXNO_DIFFUSE 0
10
#define SUBTEXNO_REFLECT 1
11
#define SUBTEXNO_REFRACT 2
12
#define SUBTEXNO_BUMP 3
13
#define SUBTEXNO_REFLECT_GLOSSINESS 4
14
#define SUBTEXNO_REFRACT_GLOSSINESS 5
15
#define SUBTEXNO_DISPLACEMENT 6
16
#define SUBTEXNO_ENVIRONMENT 7
17
#define SUBTEXNO_TRANSLUCENCY 8
18
#define SUBTEXNO_IOR 9
19
#define SUBTEXNO_HILIGHT_GLOSSINESS 10
20
#define SUBTEXNO_FRESNELIOR 11
21
#define SUBTEXNO_OPACITY 12
22
#define SUBTEXNO_ROUGHNESS 13
23
#define SUBTEXNO_ANISO 14
24
#define SUBTEXNO_ANISO_ROTATION 15
25
#define SUBTEXNO_FOG 16
26
27
namespace VRayMtlParameters {
28
29
	// Parameter block IDs
30
	enum {
31
		vrayMtl_old_id,
32
		vrayMtl_basic_id,
33
		vrayMtl_BRDF_id,
34
		vrayMtl_options_id,
35
		vrayMtl_maps_id,
36
		vrayMtl_reflIMap_id,
37
		vrayMtl_refrIMap_id,
38
	};
39
40
	// Parameters
41
	enum {
42
		pb_spin,
43
44
		pb_diffuse_color,
45
46
		pb_reflect_color, pb_reflect_glossiness, pb_reflect_subdivs,
47
48
		pb_refract_color, pb_refract_glossiness, pb_refract_subdivs,
49
50
		pb_reflect_fresnel,
51
		pb_refract_ior,
52
53
		pb_brdf_type,
54
55
		pb_reflect_trace,
56
		pb_refract_trace,
57
58
		pb_doubleSided,
59
		pb_reflectOnBack,
60
61
		pb_diffuse_trace, pb_diffuse_subdivs,
62
63
		pb_useIrradMap,
64
		pb_diffuseGlossy,
65
		pb_traceCaustics,
66
67
		pb_reflect_maxDepth,
68
		pb_refract_maxDepth,
69
		pb_cutoffThresh,
70
71
		pb_refract_fogColor, pb_refract_fogMult, pb_refract_translucent, pb_refract_thickness, pb_refract_volSubdivs, pb_refract_lightMult_old,
72
		pb_refract_scatterCoeff, pb_refract_scatterDir, pb_refract_lightMult,
73
74
		pb_fog_affectShadows,
75
76
		pb_useInterpolation,
77
		pb_interpSamples,
78
		pb_colorThreshold,
79
80
		pb_preservationMode,
81
		pb_translucent_color, pb_translucent_map,
82
83
		pb_reflect_minRate, pb_reflect_maxRate, pb_reflect_clrThresh, pb_reflect_nrmThresh, pb_reflect_interpSamples, pb_reflect_preset,
84
85
		pb_refract_minRate, pb_refract_maxRate, pb_refract_clrThresh, pb_refract_nrmThresh, pb_refract_interpSamples, pb_refract_preset,
86
87
		pb_reflect_exitColor, pb_refract_exitColor, pb_refract_exitColor_on,
88
89
		pb_brdf_anisotropy, pb_brdf_anisotropy_channel,
90
91
		pb_reflect_useInterpolation,
92
		pb_refract_useInterpolation,
93
94
		pb_brdf_anisotropy_rotation, pb_brdf_anisotropy_derivation, pb_brdf_anisotropy_axis,
95
96
		pb_refract_affectAlpha,
97
		pb_hilight_glossiness,
98
		pb_reflect_ior, pb_reflect_glossiness_lock, pb_reflect_ior_lock,
99
100
		pb_refract_fogBias,
101
102
		pb_environment_priority,
103
		pb_diffuse_roughness,
104
105
		pb_brdf_soften,
106
		pb_clampColors,
107
108
		pb_reflect_dimDistance, pb_reflect_dimDistanceFallOff, pb_reflect_dimDistanceOn,
109
110
		pb_refract_dispersion, pb_refract_dispersionOn,
111
112
		pb_refract_fogUnitScaleOn,
113
		pb_brdf_fixDarkEdges,
114
115
		pb_effect_id,
116
		pb_override_effect_id,
117
118
		pb_reflect_affectAlpha,
119
	};
120
121
#define SUBTEX_PARAM_ID 100
122
#define ON_OFFSET 50
123
#define MULT_OFFSET 100
124
125
#define VRAYMTL_TEXMAP_PARAMID(subtexNo) (SUBTEX_PARAM_ID+subtexNo)
126
#define VRAYMTL_TEXMAP_ON_PARAMID(subtexNo) (SUBTEX_PARAM_ID+subtexNo+ON_OFFSET)
127
#define VRAYMTL_TEXMAP_MULT_PARAMID(subtexNo) (SUBTEX_PARAM_ID+subtexNo+MULT_OFFSET)
128
129
} // namespace VRayMtlParameters
130
131
132
133
134
135
/****************************************************************************
136
  DumpMaterialVRay (Get the VRayMtl material properties)
137
****************************************************************************/
138
void Max2Nmo::DumpMaterialVRayMtl(Mtl* mtl, VirtoolsMaterial &NMat, BOOL &OpacityValid)
139
{
140
/*
141
	// list every parameters in its matching IParamBlock2
142
	
143
	IParamBlock2 *pblockBasic=mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_basic_id);
144
	IParamBlock2 *pblockMaps=mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_maps_id);
145
	IParamBlock2 *pblockOptions=mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_options_id);
146
	IParamBlock2 *pblockBRDF=mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_BRDF_id);
147
148
	OutputDebugString("pblockBasic\n");
149
	for (int i=-1; ++i<pblockBasic->NumParams();)
150
	{
151
		OutputDebugString("\t");
152
		OutputDebugString(pblockBasic->GetLocalName(pblockBasic->IndextoID(i)));
153
		OutputDebugString("\n");
154
	}
155
156
	OutputDebugString(_T("pblockMaps\n"));
157
	for (int i=-1; ++i<pblockMaps->NumParams();)
158
	{
159
		OutputDebugString("\t");
160
		OutputDebugString(pblockMaps->GetLocalName(pblockMaps->IndextoID(i)));
161
		OutputDebugString("\n");
162
	}
163
164
	OutputDebugString(_T("pblockOptions\n"));
165
	for (int i=-1; ++i<pblockOptions->NumParams();)
166
	{
167
		OutputDebugString("\t");
168
		OutputDebugString(pblockOptions->GetLocalName(pblockOptions->IndextoID(i)));
169
		OutputDebugString("\n");
170
	}
171
172
	OutputDebugString(_T("pblockBRDF\n"));
173
	for (int i=-1; ++i<pblockBRDF->NumParams();)
174
	{
175
		OutputDebugString("\t");
176
		OutputDebugString(pblockBRDF->GetLocalName(pblockBRDF->IndextoID(i)));
177
		OutputDebugString("\n");
178
	}
179
*/
180
181
182
183
184
	TimeValue t = GetStaticFrame();
185
	BOOL map_on;
186
	float map_mult;
187
188
189
	Color ambient_color(0.75, 0.75, 0.75);
190
	Color diffuse_color(0.75, 0.75, 0.75);
191
	Color reflection_color(0.0, 0.0, 0.0);	// specular color
192
	Color emissive_color(0.0, 0.0, 0.0);
193
194
	float reflection_glossiness = 10.0f;	// specular power
195
	float transparency = 1.0f;		// diffuse color alpha component
196
197
	BOOL option_doubleSided = true;
198
199
	Texmap *diffuse_texture = NULL;
200
201
202
	//--
203
	// Get VRay Material Properties
204
	
205-
	IParamBlock2 *pblockBasic =		mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_basic_id);
205+
	IParamBlock2 *pblockBasic = mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_basic_id);
206-
	IParamBlock2 *pblockMaps =		mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_maps_id);
206+
	IParamBlock2 *pblockMaps = mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_maps_id);
207-
	IParamBlock2 *pblockOptions =	mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_options_id);
207+
	IParamBlock2 *pblockOptions = mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_options_id);
208
	IParamBlock2 *pblockMaps = mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_maps_id);
209
210
	// get colors
211
	diffuse_color =		pblockBasic->GetColor(VRayMtlParameters::pb_diffuse_color, t);
212
	ambient_color =		diffuse_color;
213
	reflection_color =	pblockBasic->GetColor(VRayMtlParameters::pb_reflect_color, t);
214
	
215
	// get specular level
216
	// from the "Reflection Glossiness" spinner [formula: (100* (1-value))]
217
	reflection_glossiness = 100.0f * (1.0f - (pblockBasic->GetFloat(VRayMtlParameters::pb_reflect_glossiness, t)));
218
219
	// get transparency value from the "Maps" rollout
220
	map_on = pblockMaps->GetInt(VRAYMTL_TEXMAP_ON_PARAMID(SUBTEXNO_OPACITY), t);
221
	if (map_on)
222
	{
223
		map_mult =	pblockMaps->GetFloat(VRAYMTL_TEXMAP_MULT_PARAMID(SUBTEXNO_OPACITY), t);
224
		transparency = (map_mult / 100.0f);
225
	}
226
	else
227
	{
228
		transparency = 1.0f;
229
	}
230
231
	// get both-sided value
232
	option_doubleSided = pblockOptions->GetInt(VRayMtlParameters::pb_doubleSided);
233
234
235
	
236
	// Diffuse map
237-
	//--Set Virtools Material Properties
237+
238-
	NMat.m_Diffuse		= VxColor(diffuse_color.r,diffuse_color.g,diffuse_color.b,transparency);
238+
	int diffuse_map_on;
239-
	NMat.m_Ambient		= VxColor(ambient_color.r,ambient_color.g,ambient_color.b);
239+
	Texmap* diffuse_texture = NULL;
240-
	NMat.m_Specular		= VxColor(reflection_color.r,reflection_color.g,reflection_color.b);
240+
241-
	NMat.m_SpecularPower= reflection_glossiness;
241+
	diffuse_map_on = pblockMaps->GetInt(VRAYMTL_TEXMAP_ON_PARAMID(SUBTEXNO_DIFFUSE), t);
242-
	NMat.m_Emissive		= VxColor(emissive_color.r,emissive_color.g,emissive_color.b);
242+
	if (diffuse_map_on)
243-
	NMat.m_TwoSided		= option_doubleSided;
243+
244-
	NMat.m_FillMode		= VXFILL_SOLID;
244+
		diffuse_texture = pblockMaps->GetTexmap(VRAYMTL_TEXMAP_PARAMID(SUBTEXNO_DIFFUSE));
245-
	NMat.m_ShadeMode	= VXSHADE_GOURAUD;
245+
246-
		
246+