1 #ifndef __GAME_MATERIAL__H
2 #define __GAME_MATERIAL__H
3 
4 #include "shaders.h"
5 #include "samplers.h"
6 #include "iparamm2.h"
7 #include "texmaps.h"
8 #include "..\kernel\resources.h"
9 
10 #define XRAYMTL_CLASS_ID	Class_ID(0x35e04198, 0x2293156c)
11 
12 // XRayMtl flags values
13 #define NEWSTDMTL_ADD_TRANSP	(1<<0)
14 #define NEWSTDMTL_FALLOFF_OUT	(1<<1)
15 #define NEWSTDMTL_WIRE		  	(1<<2)
16 #define NEWSTDMTL_2SIDE			(1<<3)
17 #define NEWSTDMTL_SOFTEN		(1<<4)
18 #define NEWSTDMTL_FILT_TRANSP 	(1<<5)
19 #define NEWSTDMTL_WIRE_UNITS	(1<<6)
20 #define NEWSTDMTL_LOCK_AD		(1<<8)
21 #define NEWSTDMTL_LOCK_DS		(1<<9)
22 #define NEWSTDMTL_UNUSED1		(1<<10)
23 #define NEWSTDMTL_LOCK_ADTEX	(1<<11)
24 #define NEWSTDMTL_FACEMAP		(1<<12)
25 #define NEWSTDMTL_OLDSPEC		(1<<13)
26 #define NEWSTDMTL_SSAMP_ON		(1<<14)
27 #define NEWSTDMTL_COLOR_SI		(1<<15)
28 #define NEWSTDMTL_FACETED		(1<<16)
29 
30 #define NEWSTDMTL_ROLLUP0_OPEN  (1<<27)	// shader
31 #define NEWSTDMTL_ROLLUP1_OPEN  (1<<28)	// basic
32 #define NEWSTDMTL_ROLLUP2_OPEN  (1<<29)	// extra
33 #define NEWSTDMTL_ROLLUP3_OPEN  (1<<30)	// maps
34 #define NEWSTDMTL_ROLLUP4_OPEN  (1<<26)	// sampling
35 #define NEWSTDMTL_ROLLUP5_OPEN  (1<<25)	// dynamics
36 #define NEWSTDMTL_ROLLUP6_OPEN  (1<<24)	// effects
37 
38 // only needed if the constant shader is included in shaders
39 #define  CONSTClassID (STDSHADERS_CLASS_ID+1)
40 
41 #define NEWSTDMTL_ROLLUP_FLAGS (NEWSTDMTL_ROLLUP0_OPEN|NEWSTDMTL_ROLLUP1_OPEN|NEWSTDMTL_ROLLUP2_OPEN|NEWSTDMTL_ROLLUP3_OPEN \
42 	|NEWSTDMTL_ROLLUP4_OPEN|NEWSTDMTL_ROLLUP5_OPEN|NEWSTDMTL_ROLLUP6_OPEN)
43 
44 class XRayMtlDlg;
45 
46 
47 // IDs for all the ParamBlocks and their parameters.  One block UI per rollout.
48 enum { std2_shader, std2_extended, std2_sampling, std_maps, std2_dynamics, std2_xray };  // pblock IDs
49 enum{
50 	std2_eshader_type,
51 	std2_cshader_type,
52 	std2_eshader_by_name,	// virtual param for accessing shader type by name
53 	std2_cshader_by_name,	// virtual param for accessing shader type by name
54 	std2_gamemtl_type,
55 	std2_gamemtl_by_name	// virtual param for accessing shader type by name
56 };
57 // std2_shader param IDs
58 enum
59 {
60 	std2_shader_type, std2_wire, std2_two_sided, std2_face_map, std2_faceted,
61 	std2_shader_by_name  // virtual param for accessing shader type by name
62 };
63 // std2_extended param IDs
64 enum
65 {
66 	std2_opacity_type, std2_opacity, std2_filter_color, std2_ep_filter_map,
67 	std2_falloff_type, std2_falloff_amnt,
68 	std2_ior,
69 	std2_wire_size, std2_wire_units,
70 	std2_apply_refl_dimming, std2_dim_lvl, std2_refl_lvl,
71 };
72 
73 // std2_sampling param IDs
74 enum
75 {
76 	std2_ssampler, std2_ssampler_qual, std2_ssampler_enable,
77 	std2_ssampler_adapt_on, std2_ssampler_adapt_threshold, std2_ssampler_advanced,
78 	std2_ssampler_subsample_tex_on, std2_ssampler_by_name,
79 	std2_ssampler_param0, std2_ssampler_param1,
80 };
81 // std_maps param IDs
82 enum
83 {
84 	std2_map_enables, std2_maps, std2_map_amnts, std2_mp_ad_texlock,
85 };
86 // std2_dynamics param IDs
87 enum
88 {
89 	std2_bounce, std2_static_friction, std2_sliding_friction,
90 };
91 
92 
93 // paramblock2 block and parameter IDs for the standard shaders
94 // NB these are duplicated in shaders/stdShaders.cpp...
95 enum { shdr_params, };
96 // shdr_params param IDs
97 enum
98 {
99 	shdr_ambient, shdr_diffuse, shdr_specular,
100 	shdr_ad_texlock, shdr_ad_lock, shdr_ds_lock,
101 	shdr_use_self_illum_color, shdr_self_illum_amnt, shdr_self_illum_color,
102 	shdr_spec_lvl, shdr_glossiness, shdr_soften,
103 };
104 
105 extern TCHAR *GetString(int id);
106 
107 #define NUM_REFS		9
108 
109 // refs
110 #define OLD_PBLOCK_REF	0		// reference number assignments
111 #define TEXMAPS_REF		1
112 #define SHADER_REF		2
113 #define SHADER_PB_REF	3
114 #define EXTENDED_PB_REF	4
115 #define SAMPLING_PB_REF	5
116 #define MAPS_PB_REF		6
117 #define DYNAMICS_PB_REF	7
118 #define SAMPLER_REF		8
119 #define XRAY_PB_REF		9
120 
121 // sub anims
122 #define NUM_SUB_ANIMS	5
123 //#define OLD_PARAMS_SUB		0
124 #define TEXMAPS_SUB			0
125 #define SHADER_SUB			1
126 #define EXTRA_PB_SUB		2
127 #define SAMPLING_PB_SUB		3
128 #define DYNAMICS_PB_SUB		4
129 
130 
131 class RefmsgKillCounter {
132 private:
133 	friend class KillRefmsg;
134 	LONG	counter;
135 
136 public:
RefmsgKillCounter()137 	RefmsgKillCounter() : counter(-1) {}
138 
DistributeRefmsg()139 	bool DistributeRefmsg() { return counter < 0; }
140 };
141 
142 class KillRefmsg {
143 private:
144 	LONG&	counter;
145 
146 public:
KillRefmsg(RefmsgKillCounter & c)147 	KillRefmsg(RefmsgKillCounter& c) : counter(c.counter) { ++counter; }
~KillRefmsg()148 	~KillRefmsg() { --counter; }
149 };
150 
151 class XRayMtl: public StdMat2, public IReshading {
152 	// Animatable parameters
153 public:
154 	// current UI if open
155 	static ShaderParamDlg*	pShaderDlg;
156 	static IAutoMParamDlg*	masterDlg;
157 	static IAutoMParamDlg*	texmapDlg;
158 	static IAutoMParamDlg*	extendedDlg;
159 	static IAutoMParamDlg*	samplingDlg;
160 	static IAutoMParamDlg*	xrayDlg;
161 	static HWND				curHwmEdit;
162 	static IMtlParams*		curImp;
163 	static Tab<ClassDesc*>	shaderList;
164 	static Tab<ClassDesc*>	samplerList;
165 	static LPSTR_vec			EShaders;
166 	static LPSTR_vec			CShaders;
167 	static LPSTR_vec			GameMtls;
168 
169 	IParamBlock *old_pblock;    // ref 0, for old version loading
170 	Texmaps* maps;				// ref 1
171 	Interval ivalid;
172 	ReshadeRequirements mReshadeRQ; // mjm - 06.02.00
173 	ReshadeRequirements mInRQ;		// ca - 12/7/00
174 	ULONG flags;
175 	int shaderId;
176 	Shader *pShader;			// ref 2
177 	// new PB2 paramblocks, one per rollout
178 	IParamBlock2 *pb_xray;		//
179 	IParamBlock2 *pb_shader;	// ref 3, 4, ...
180 	IParamBlock2 *pb_extended;
181 	IParamBlock2 *pb_sampling;
182 	IParamBlock2 *pb_maps;
183 	IParamBlock2 *pb_dynamics;
184 
185 	// xray
186 	int		eshaderId;
187 	int		cshaderId;
188 	int		gamemtlId;
189 
190 	Color filter;
191 	float opacity;
192 	float opfall;
193 	float wireSize;
194 	float ioRefract;
195 	float dimIntens;
196 	float dimMult;
197 	BOOL dimReflect;
198 
199 	// sampling
200 	int samplerId;
201 	Sampler* pixelSampler;	// ref 8
202 
203 	// composite of shader/mtl channel types
204 	int channelTypes[ STD2_NMAX_TEXMAPS ];
205 	int stdIDToChannel[ N_ID_CHANNELS ];
206 
207 	// experiment: override filter
208 	BOOL	filterOverrideOn;
209 	float	filterSz;
210 
211 	// Kill REFMSG_CHANGE messages. This counter is used to
212 	// prevent these messages when things really aren't changing.
213 	// Use the class KillRefmsg
214 	RefmsgKillCounter	killRefmsg;
215 
216 	void SetFlag(ULONG f, ULONG val);
217 	void EnableMap(int i, BOOL onoff);
IsMapEnabled(int i)218 	BOOL IsMapEnabled(int i) { return (*maps)[i].mapOn; }
KeyAtTime(int id,TimeValue t)219 	BOOL KeyAtTime(int id,TimeValue t) { return (id == OPACITY_PARAM) ? pb_extended->KeyFrameAtTime(std2_opacity, t) : FALSE; }
220 	BOOL AmtKeyAtTime(int i, TimeValue t);
221 	int  GetMapState( int indx ); //returns 0 = no map, 1 = disable, 2 = mapon
222 	TSTR  GetMapName( int indx );
223 	void SyncADTexLock( BOOL lockOn );
224 
225 	// from StdMat
226 	// these set Approximate colors into the plug in shader
227 	BOOL IsSelfIllumColorOn();
228 	void SetSelfIllumColorOn( BOOL on );
229 	void SetSelfIllumColor(Color c, TimeValue t);
230 	void SetAmbient(Color c, TimeValue t);
231 	void SetDiffuse(Color c, TimeValue t);
232 	void SetSpecular(Color c, TimeValue t);
233 	void SetShininess(float v, TimeValue t);
234 	void SetShinStr(float v, TimeValue t);
235 	void SetSelfIllum(float v, TimeValue t);
SetSoften(BOOL onoff)236 	void SetSoften(BOOL onoff) { SetFlag(NEWSTDMTL_SOFTEN,onoff); }
237 
238 	void SetTexmapAmt(int imap, float amt, TimeValue t);
LockAmbDiffTex(BOOL onoff)239 	void LockAmbDiffTex(BOOL onoff) { SetFlag(NEWSTDMTL_LOCK_ADTEX,onoff); }
240 
SetWire(BOOL onoff)241 	void SetWire(BOOL onoff){ pb_shader->SetValue(std2_wire,0, (onoff!=0) ); }//SetFlag(NEWSTDMTL_WIRE,onoff); }
242 	void SetWireSize(float s, TimeValue t);
SetWireUnits(BOOL onoff)243 	void SetWireUnits(BOOL onoff) { pb_extended->SetValue(std2_wire_units,0, (onoff!=0) ); } //SetFlag(NEWSTDMTL_WIRE_UNITS,onoff); }
244 
SetFaceMap(BOOL onoff)245 	void SetFaceMap(BOOL onoff) { pb_shader->SetValue(std2_face_map,0, (onoff!=0) ); } //SetFlag(NEWSTDMTL_FACEMAP,onoff); }
SetTwoSided(BOOL onoff)246 	void SetTwoSided(BOOL onoff) { pb_shader->SetValue(std2_two_sided,0, (onoff!=0) ); } //SetFlag(NEWSTDMTL_2SIDE,onoff); }
SetFalloffOut(BOOL outOn)247 	void SetFalloffOut(BOOL outOn) { pb_extended->SetValue(std2_falloff_type,0, (outOn!=0) ); } //SetFlag(NEWSTDMTL_FALLOFF_OUT,onoff); }
248 	void SetTransparencyType(int type);
249 
250 	void SetFilter(Color c, TimeValue t);
251 	void SetOpacity(float v, TimeValue t);
252 	void SetOpacFalloff(float v, TimeValue t);
253 	void SetIOR(float v, TimeValue t);
254 	void SetDimIntens(float v, TimeValue t);
255 	void SetDimMult(float v, TimeValue t);
256 
GetFlag(ULONG f)257 	int GetFlag(ULONG f) { return (flags&f)?1:0; }
258 
259 	// >>>Shaders
260 
261 	// these 3 internal only
262 	void SetShaderIndx( long shaderId, BOOL update=TRUE );
GetShaderIndx()263 	long GetShaderIndx(){ return shaderId; }
264 	void SetShader( Shader* pNewShader );
265 	void ShuffleTexMaps( Shader* newShader, Shader* oldShader );
266 	void ShuffleShaderParams( Shader* newShader, Shader* oldShader );
267 
GetShader()268 	Shader* GetShader(){ return pShader; }
269 	void SwitchShader(Shader* pNewShader, BOOL loadDlg = FALSE);
270 	void SwitchShader(ClassDesc* pNewCD);
271 	BOOL SwitchShader(Class_ID shaderId);
272 	int FindShader( Class_ID& findId, ClassDesc** ppCD=NULL );
IsShaderInUI()273 	BOOL IsShaderInUI() { return pb_shader && pb_shader->GetMap() && pShader && pShader->GetParamDlg(); }
274 
275 	static void XRayMtl::LoadShaderList();
276 	static int XRayMtl::NumShaders();
277 	static ClassDesc* XRayMtl::GetShaderCD(int i);
278 	static void XRayMtl::LoadSamplerList();
279 	static int XRayMtl::NumSamplers();
280 	static ClassDesc* XRayMtl::GetSamplerCD(int i);
281 
282 	void SetEShaderIndx(long shaderId);
283 	void SetCShaderIndx(long shaderId);
284 	void SetGameMtlIndx(long shaderId);
GetEShaderIndx()285 	long GetEShaderIndx(){ return eshaderId; }
GetCShaderIndx()286 	long GetCShaderIndx(){ return cshaderId; }
GetGameMtlIndx()287 	long GetGameMtlIndx(){ return gamemtlId; }
GetEShaderName()288 	LPCSTR GetEShaderName(){ return GetEShader(eshaderId); }
GetCShaderName()289 	LPCSTR GetCShaderName(){ return GetCShader(cshaderId); }
GetGameMtlName()290 	LPCSTR GetGameMtlName(){ return GetGameMtl(gamemtlId); }
291 
292 	static void		XRayMtl::LoadXRayShaderList		();
293 	static void		XRayMtl::UnloadXRayShaderList	();
294 	virtual TCHAR*	GetEShader	(DWORD i);
295 	virtual TCHAR*	GetCShader	(DWORD i);
296 	virtual TCHAR*	GetGameMtl	(DWORD i);
297 	virtual int		FindEShader	(LPCSTR name);
298 	virtual int		FindCShader	(LPCSTR name);
299 	virtual int		FindGameMtl	(LPCSTR name);
300 
IsFaceted()301 	BOOL IsFaceted(){ return GetFlag(NEWSTDMTL_FACETED); }
SetFaceted(BOOL on)302 	void SetFaceted( BOOL on ){	pb_shader->SetValue(std2_faceted,0, (on!=0) ); }
303 
304 	// These utilitys provide R2.5 shaders, ONLY used for Translators
305 	// Does not & will not work for plug-in shaders
306 	void SetShading(int s);
307 	int GetShading();
308 
309 	// from Mtl
310 	Color GetAmbient(int mtlNum=0, BOOL backFace=FALSE);
311 	Color GetDiffuse(int mtlNum=0, BOOL backFace=FALSE);
312 	Color GetSpecular(int mtlNum=0, BOOL backFace=FALSE);
313 	float GetShininess(int mtlNum=0, BOOL backFace=FALSE);
314 	float GetShinStr(int mtlNum=0, BOOL backFace=FALSE) ;
315 	float GetXParency(int mtlNum=0, BOOL backFace=FALSE);
316 	float WireSize(int mtlNum=0, BOOL backFace=FALSE) { return wireSize; }
317 
318 	// >>>> Self Illumination
319 	float GetSelfIllum(int mtlNum, BOOL backFace) ;
320 	BOOL  GetSelfIllumColorOn(int mtlNum, BOOL backFace);
321 	Color GetSelfIllumColor(int mtlNum, BOOL backFace);
322 
323 	// >>>> sampling
SetSamplingOn(BOOL on)324 	void SetSamplingOn( BOOL on )
325 	{
326 		pb_sampling->SetValue(std2_ssampler_enable, 0, on!=0 );
327 	}
GetSamplingOn()328 	BOOL GetSamplingOn()
329 	{	Interval iv;
330 	BOOL on;
331 	pb_sampling->GetValue(std2_ssampler_enable, 0, on, iv );
332 	return on;
333 	}
SetSamplingQuality(float quality)334 	void SetSamplingQuality( float quality )
335 	{
336 		pb_sampling->SetValue(std2_ssampler_qual, 0, quality );
337 	}
GetSamplingQuality()338 	float GetSamplingQuality()
339 	{	Interval iv;
340 	float q;
341 	pb_sampling->GetValue(std2_ssampler_qual, 0, q, iv );
342 	return q;
343 	}
344 
345 	void SwitchSampler(ClassDesc* pNewCD);
346 	void SwitchSampler(Sampler* pNewSampler);
347 	BOOL SwitchSampler(Class_ID samplerId);
348 	int FindSampler( Class_ID findId, ClassDesc** pNewCD=NULL );
349 	Sampler * GetPixelSampler(int mtlNum=0, BOOL backFace=FALSE){  return pixelSampler; }
350 
351 	// these 2 internal only
352 	void SetSamplerIndx( long indx, BOOL update=TRUE );
GetSamplerIndx()353 	long  GetSamplerIndx(){ return samplerId; }
354 	void SetPixelSampler( Sampler * sampler );
355 
356 	// Dynamics properties
357 	float GetDynamicsProperty(TimeValue t, int mtlNum, int propID);
358 	void SetDynamicsProperty(TimeValue t, int mtlNum, int propID, float value);
359 
360 	// from StdMat
GetSoften()361 	BOOL GetSoften() { return GetFlag(NEWSTDMTL_SOFTEN); }
GetFaceMap()362 	BOOL GetFaceMap() { return GetFlag(NEWSTDMTL_FACEMAP); }
GetTwoSided()363 	BOOL GetTwoSided() { return GetFlag(NEWSTDMTL_2SIDE); }
GetWire()364 	BOOL GetWire() { return GetFlag(NEWSTDMTL_WIRE); }
GetWireUnits()365 	BOOL GetWireUnits() { return GetFlag(NEWSTDMTL_WIRE_UNITS); }
GetFalloffOut()366 	BOOL GetFalloffOut() { return GetFlag(NEWSTDMTL_FALLOFF_OUT); }  // 1: out, 0: in
GetAmbDiffTexLock()367 	BOOL GetAmbDiffTexLock(){ return GetFlag(NEWSTDMTL_LOCK_ADTEX); }
GetTransparencyType()368 	int GetTransparencyType() {
369 		return (flags&NEWSTDMTL_FILT_TRANSP)?TRANSP_FILTER:
370 		flags&NEWSTDMTL_ADD_TRANSP ? TRANSP_ADDITIVE: TRANSP_SUBTRACTIVE;
371 	}
372 	Color GetFilter(TimeValue t);
373 
374 	// these are stubs till i figure out scripting
375 	Color GetAmbient(TimeValue t);
376 	Color GetDiffuse(TimeValue t);
377 	Color GetSpecular(TimeValue t);
378 	float GetShininess( TimeValue t);
379 	float GetShinStr(TimeValue t);
380 	float GetSelfIllum(TimeValue t);
381 	BOOL  GetSelfIllumColorOn();
382 	Color GetSelfIllumColor(TimeValue t);
383 
384 	float GetOpacity( TimeValue t);
385 	float GetOpacFalloff(TimeValue t);
386 	float GetWireSize(TimeValue t);
387 	float GetIOR( TimeValue t);
388 	float GetDimIntens( TimeValue t);
389 	float GetDimMult( TimeValue t);
390 	float GetSoftenLevel( TimeValue t);
391 	BOOL MapEnabled(int i);
392 	float GetTexmapAmt(int imap, TimeValue t);
393 
394 	// internal
GetOpacity()395 	float GetOpacity() { return opacity; }
GetOpacFalloff()396 	float GetOpacFalloff() { return opfall; }
397 	float GetTexmapAmt(int imap);
398 	Color GetFilter();
GetIOR()399 	float GetIOR() { return ioRefract; }
400 
401 	XRayMtl(BOOL loading = FALSE);
~XRayMtl()402 	~XRayMtl() {
403 		DiscardTexHandles();
404 	}
405 	BOOL ParamWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
406 	ParamDlg* CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp);
407 	BOOL SetDlgThing(ParamDlg* dlg);
408 	void UpdateTexmaps();
409 	void UpdateMapButtons();
410 	void UpdateExtendedMapButtons();
411 	void UpdateMtlDisplay();
412 	void UpdateLockADTex( BOOL passOn );
413 	void UpdateExtraParams( ULONG stdParams );
414 	void UpdateSamplingParams();
415 
416 
417 	Color TranspColor(ShadeContext& sc, float opac, Color& diff);
418 	void Shade(ShadeContext& sc);
419 	float EvalDisplacement(ShadeContext& sc);
420 	Interval DisplacementValidity(TimeValue t);
421 	void Update(TimeValue t, Interval& validr);
422 	void Reset();
423 	void OldVerFix(int loadVer);
424 	void BumpFix();
425 	Interval Validity(TimeValue t);
426 	void NotifyChanged();
427 
428 	// Requirements
429 	ULONG Requirements(int subMtlNum);
430 	void MappingsRequired(int subMtlNum, BitArray & mapreq, BitArray &bumpreq);
431 
432 	// Methods to access texture maps of material
NumSubTexmaps()433 	int NumSubTexmaps() { return STD2_NMAX_TEXMAPS; }
GetSubTexmap(int i)434 	Texmap* GetSubTexmap(int i) { return (*maps)[i].map; }
435 	int MapSlotType(int i);
436 	void SetSubTexmap(int i, Texmap *m);
437 	TSTR GetSubTexmapSlotName(int i);
SubTexmapOn(int i)438 	int SubTexmapOn(int i) { return  MAPACTIVE(i); }
StdIDToChannel(long id)439 	long StdIDToChannel( long id ){ return stdIDToChannel[id]; }
440 
441 	Class_ID ClassID();
SuperClassID()442 	SClass_ID SuperClassID() { return MATERIAL_CLASS_ID; }
GetClassName(TSTR & s)443 	void GetClassName(TSTR& s) { s = GetString(IDS_CLASS_NAME); }
444 
445 	void DeleteThis();
446 
NumSubs()447 	int NumSubs() { return NUM_SUB_ANIMS; }
448 	Animatable* SubAnim(int i);
449 	TSTR SubAnimName(int i);
450 	int SubNumToRefNum(int subNum);
451 
452 	// JBW: add direct ParamBlock access
NumParamBlocks()453 	int	NumParamBlocks() { return 5; }
454 	IParamBlock2* GetParamBlock(int i);
455 	IParamBlock2* GetParamBlockByID(BlockID id);
456 
457 	// From ref
NumRefs()458 	int NumRefs() { return NUM_REFS; }
459 	RefTargetHandle GetReference(int i);
460 	void SetReference(int i, RefTargetHandle rtarg);
461 
462 	RefTargetHandle Clone(RemapDir &remap = NoRemap());
463 	RefResult NotifyRefChanged( Interval changeInt, RefTargetHandle hTarget,
464 		PartID& partID, RefMessage message );
465 
466 	// IO
467 	IOResult Save(ISave *isave);
468 	IOResult Load(ILoad *iload);
469 
470 	// begin - ke/mjm - 03.16.00 - merge reshading code
SupportsRenderElements()471 	BOOL SupportsRenderElements(){ return TRUE; }
472 	//		BOOL SupportsReShading(ShadeContext& sc);
473 	void UpdateReshadeRequirements(RefTargetHandle hTarget, PartID partID); // mjm - 06.02.00
GetReshadeRequirements()474 	ReshadeRequirements GetReshadeRequirements() { return mReshadeRQ; } // mjm - 06.02.00
475 	void PreShade(ShadeContext& sc, IReshadeFragment* pFrag);
476 	void PostShade(ShadeContext& sc, IReshadeFragment* pFrag, int& nextTexIndex, IllumParams* ip);
477 	// end - ke/mjm - 03.16.00 - merge reshading code
478 
479 	// begin - dds- 04.27.00 - multiple map display support
480 #define NTEXHANDLES 2
481 	TexHandle *texHandle[NTEXHANDLES];
482 	short useSubForTex[NTEXHANDLES];
483 	short texOpsType[NTEXHANDLES];
484 	int numTexHandlesUsed;
485 	Interval texHandleValid;
486 	void SetTexOps(Material *mtl, int i, int type);
487 	void DiscardTexHandles();
SupportTexDisplay()488 	BOOL SupportTexDisplay() { return TRUE; }
SupportsMultiMapsInViewport()489 	BOOL SupportsMultiMapsInViewport() { return TRUE; }
490 	void ActivateTexDisplay(BOOL onoff);
491 	void SetupGfxMultiMaps(TimeValue t, Material *mtl, MtlMakerCallback &cb);
492 	// end - dds- 04.27.00 - multiple map display support
493 
494 	// --- Material evaluation - from Mtl ---
495 	bool IsOutputConst( ShadeContext& sc, int stdID );
496 	bool EvalColorStdChannel( ShadeContext& sc, int stdID, Color& outClr );
497 	bool EvalMonoStdChannel( ShadeContext& sc, int stdID, float& outVal );
498 
499 	void* GetInterface(ULONG id);
500 
GetReflectionDim(float diffIllumIntensity)501 	float GetReflectionDim(float diffIllumIntensity ){
502 		if (dimReflect)
503 			return ((1.0f-dimIntens)*diffIllumIntensity*dimMult + dimIntens);
504 		else
505 			return 1.0f;
506 	}
507 	Color TranspColor( float opac, Color filt, Color diff );
508 
GetEffOpacity(ShadeContext & sc,float opac)509 	float GetEffOpacity(ShadeContext& sc, float opac){
510 		if ( opac != 1.0f || opfall != 0.0f) {
511 			if (opfall != 0.0f) {
512 				Point3 N = (flags & NEWSTDMTL_FACETED) ? sc.GNormal() : sc.Normal();
513 				float d = abs( DotProd( N, sc.V() ) );
514 				if (flags & NEWSTDMTL_FALLOFF_OUT) d = 1.0f-d;
515 				return opac * (1.0f - opfall * d);
516 			} else return opac;
517 		} else return 1.0f;
518 	}
519 
520 private:
521 	// --- Material evaluation ---
522 	bool EvalChannel( ShadeContext& sc, int channelID, Color& outClr);
523 	bool EvalBump( ShadeContext& sc, Color& outClr );
524 	bool EvalReflection( ShadeContext& sc, Color& outClr );
525 	bool EvalReflection( ShadeContext& sc, float& outVal );
526 	bool EvalRefraction( ShadeContext& sc, Color& outClr );
527 	bool EvalRefraction( ShadeContext& sc, float& outVal );
528 	bool EvalDisplacement( ShadeContext& sc, float& outVal );
529 	bool ShouldEvalSubTexmap( ShadeContext& sc, int id );
530 
531 };
532 
533 Mtl* CreateXRayMtl();
534 
535 #endif // __GAME_MATERIAL__H
536