#define MATERIALDEFINE_VERSION	  0.1

#define FALSE 	 0
#define TRUE	 1

#define DETAIL_LOW
#define DETAIL_MEDIUM
#define DETAIL_HIGH

#define RE_BEFORE  0
#define RE_NORMAL  1
#define RE_TRANSPARENT 2
#define RE_AFTER  3

#define TEXT_AMBIENT  		0
#define TEXT_DIFFUSE  		1
#define TEXT_SPECULAR 		2
#define TEXT_SPECULARLEVEL 	3
#define TEXT_GLOSSINESS 	4
#define TEXT_SELFILLUM		5
#define TEXT_OPACITY		6
#define TEXT_FILTERCOLOR 	6
#define TEXT_BUMP		8
#define TEXT_REFLECTION 	9
#define TEXT_REFRACTION 	10

;        ID_AM = 0,   // ambient
;        ID_DI = 1,   // diffuse
;        ID_SP = 2,   // specular
;        ID_SH = 3,   // shininesNs
;        ID_SS = 4,   // shininess strength
;        ID_SI = 5,   // self-illumination
;        ID_OP = 6,   // opacity
;        ID_FI = 7,   // filter color
;        ID_BU = 8,   // bump 
;        ID_RL = 9,   // reflection
;        ID_RR = 10,  // refraction 
;        ID_DP = 11,  // displacement 


#define ASORT_NONE 		 0
#define ASORT_LOCALTRISET	 1
#define ASORT_GLOBALTRISET 	 2


#define FILL_POINT                1
#define FILL_WIREFRAME            2
#define FILL_SOLID                3


#define BLEND_ZERO                1
#define BLEND_ONE                 2
#define BLEND_SRCCOLOR            3
#define BLEND_INVSRCCOLOR         4
#define BLEND_SRCALPHA            5
#define BLEND_INVSRCALPHA         6
#define BLEND_DESTALPHA           7
#define BLEND_INVDESTALPHA        8
#define BLEND_DESTCOLOR           9
#define BLEND_INVDESTCOLOR        10
#define BLEND_SRCALPHASAT         11
#define BLEND_BOTHSRCALPHA        12
#define BLEND_BOTHINVSRCALPHA     13


#define BLENDOP_ADD               1
#define BLENDOP_SUBTRACT          2
#define BLENDOP_REVSUBTRACT       3
#define BLENDOP_MIN               4
#define BLENDOP_MAX               5


#define TADDRESS_WRAP             1
#define TADDRESS_MIRROR           2
#define TADDRESS_CLAMP            3
#define TADDRESS_BORDER           4
#define TADDRESS_MIRRORONCE       5


#define CULL_NONE                 1
#define CULL_CW                   2
#define CULL_CCW                  3

#define SHADE_FLAT		1
#define SHADE_GOURAUD		2
#define SHADE_PHONG		3

#define CMP_NEVER                 1
#define CMP_LESS                  2
#define CMP_EQUAL                 3
#define CMP_LESSEQUAL             4
#define CMP_GREATER               5
#define CMP_NOTEQUAL              6
#define CMP_GREATEREQUAL          7
#define CMP_ALWAYS                8


#define STENCILOP_KEEP            1
#define STENCILOP_ZERO            2
#define STENCILOP_REPLACE         3
#define STENCILOP_INCRSAT         4
#define STENCILOP_DECRSAT         5
#define STENCILOP_INVERT          6
#define STENCILOP_INCR            7
#define STENCILOP_DECR            8


#define ZB_FALSE                  0
#define ZB_TRUE                   1 ; Z buffering
#define ZB_USEW                   2 ; W buffering


#define TS_VIEW           2
#define TS_PROJECTION     3
#define TS_TEXTURE0       16
#define TS_TEXTURE1       17
#define TS_TEXTURE2       18
#define TS_TEXTURE3       19
#define TS_TEXTURE4       20
#define TS_TEXTURE5       21
#define TS_TEXTURE6       22
#define TS_TEXTURE7       23


#define MCS_MATERIAL  0 ; Color from material is used
#define MCS_COLOR1    1 ; Diffuse vertex color is used
#define MCS_DIFFUSE   1
#define MCS_COLOR2    2 ; Specular vertex color is used
#define MCS_SPECULAR  2 


#define COLORWRITEENABLE_RED      1
#define COLORWRITEENABLE_GREEN    2
#define COLORWRITEENABLE_BLUE     4
#define COLORWRITEENABLE_ALPHA    8
#define COLORWRITEENABLE_ALL	  15


#define TSS_COLOROP          1 ; D3DTEXTUREOP - per-stage blending controls for color channels 
#define TSS_COLORARG1        2 ; D3DTA_* (texture arg) 
#define TSS_COLORARG2        3 ; D3DTA_* (texture arg) 
#define TSS_ALPHAOP          4 ; D3DTEXTUREOP - per-stage blending controls for alpha channel 
#define TSS_ALPHAARG1        5 ; D3DTA_* (texture arg) 
#define TSS_ALPHAARG2        6 ; D3DTA_* (texture arg) 
#define TSS_BUMPENVMAT00     7 ; float (bump mapping matrix) 
#define TSS_BUMPENVMAT01     8 ; float (bump mapping matrix) 
#define TSS_BUMPENVMAT10     9 ; float (bump mapping matrix) 
#define TSS_BUMPENVMAT11    10 ; float (bump mapping matrix) 
#define TSS_TEXCOORDINDEX   11 ; identifies which set of texture coordinates index this texture 
#define TSS_ADDRESSU        13 ; D3DTEXTUREADDRESS for U coordinate 
#define TSS_ADDRESSV        14 ; D3DTEXTUREADDRESS for V coordinate 
#define TSS_BORDERCOLOR     15 ; D3DCOLOR 
#define TSS_MAGFILTER       16 ; D3DTEXTUREFILTER filter to use for magnification 
#define TSS_MINFILTER       17 ; D3DTEXTUREFILTER filter to use for minification 
#define TSS_MIPFILTER       18 ; D3DTEXTUREFILTER filter to use between mipmaps during minification 
#define TSS_MIPMAPLODBIAS   19 ; float Mipmap LOD bias 
#define TSS_MAXMIPLEVEL     20 ; DWORD 0..(n-1) LOD index of largest map to use (0  largest) 
#define TSS_MAXANISOTROPY   21 ; DWORD maximum anisotropy 
#define TSS_BUMPENVLSCALE   22 ; float scale for bump map luminance 
#define TSS_BUMPENVLOFFSET  23 ; float offset for bump map luminance 
#define TSS_TEXTURETRANSFORMFLAGS  24 ; D3DTEXTURETRANSFORMFLAGS controls texture transform
#define TSS_ADDRESSW        25 ; D3DTEXTUREADDRESS for W coordinate
#define TSS_COLORARG0       26 ; D3DTA_* third arg for triadic ops
#define TSS_ALPHAARG0       27 ; D3DTA_* third arg for triadic ops
#define TSS_RESULTARG       28 ; D3DTA_* arg for result (CURRENT or TEMP)


    ; Control
#define TOP_DISABLE              1 ; disables stage
#define TOP_SELECTARG1           2 ; the default
#define TOP_SELECTARG2           3

    ; Modulate
#define TOP_MODULATE             4 ; multiply args together
#define TOP_MODULATE2X           5 ; multiply and  1 bit
#define TOP_MODULATE4X           6 ; multiply and  2 bits

    ; Add
#define TOP_ADD                   7 ; add arguments together
#define TOP_ADDSIGNED             8 ; add with -0.5 bias
#define TOP_ADDSIGNED2X           9 ; as above but left  1 bit
#define TOP_SUBTRACT             10 ; Arg1 - Arg2, with no saturation
#define TOP_ADDSMOOTH            11 ; add 2 args, subtract product
                                     ; Arg1 + Arg2 - Arg1*Arg2
                                     ;  Arg1 + (1-Arg1)*Arg2

    ; Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha)
#define TOP_BLENDDIFFUSEALPHA    12 ; iterated alpha
#define TOP_BLENDTEXTUREALPHA    13 ; texture alpha
#define TOP_BLENDFACTORALPHA     14 ; alpha from D3DRENDERSTATE_TEXTUREFACTOR

    ; Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha)
#define TOP_BLENDTEXTUREALPHAPM  15 ; texture alpha
#define TOP_BLENDCURRENTALPHA    16 ; by alpha of current color

    ; Specular mapping
#define TOP_PREMODULATE             17 ; modulate with next texture before use
#define TOP_MODULATEALPHA_ADDCOLOR  18 ; Arg1.RGB + Arg1.A*Arg2.RGB
                                        ; COLOROP only
#define TOP_MODULATECOLOR_ADDALPHA  19 ; Arg1.RGB*Arg2.RGB + Arg1.A
                                        ; COLOROP only
#define TOP_MODULATEINVALPHA_ADDCOLOR  20 ; (1-Arg1.A)*Arg2.RGB + Arg1.RGB
                                           ; COLOROP only
#define TOP_MODULATEINVCOLOR_ADDALPHA  21 ;  (1-Arg1.RGB)*Arg2.RGB + Arg1.A
                                           ; COLOROP only
    ; Bump mapping
#define TOP_BUMPENVMAP           22 ; per pixel env map perturbation
#define TOP_BUMPENVMAPLUMINANCE  23 ; with luminance channel

    ; This can do either diffuse or specular bump mapping with correct input.
    ; Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B)
    ; where each component has been scaled and offset to make it signed.
    ; The result is replicated into all four (including alpha) channels.
    ; This is a valid COLOROP only.
#define TOP_DOTPRODUCT3          24
#define TOP_MULTIPLYADD          25 ; Arg0 + Arg1*Arg2
#define TOP_LERP				 26 ; (Arg0)*Arg1 + (1-Arg0)*Arg2


#define TA_SELECTMASK        15 ; mask for arg selector
#define TA_DIFFUSE           0 ; select diffuse color (read only)
#define TA_CURRENT           1 ; select stage destination register (read/write)
#define TA_TEXTURE           2 ; select texture color (read only)
#define TA_TFACTOR           3 ; select RENDERSTATE_TEXTUREFACTOR (read only)
#define TA_SPECULAR          4 ; select specular color (read only)
#define TA_TEMP              5 ; select temporary register color (read/write)
#define TA_COMPLEMENT        16 ; take 1.0 - x (read modifier)
#define TA_ALPHAREPLICATE    32 ; replicate alpha to color components (read modifier)

#define TA_INVDIFFUSE        16
#define TA_INVCURRENT        17
#define TA_INVTEXTURE        18
#define TA_INVTFACTOR        19
#define TA_INVSPECULAR       20
#define TA_INVTEMP    	     21	

#define TA_DIFFUSEALPHA	     32
#define TA_CURRENTALPHA      33
#define TA_TEXTUREALPHA      34
#define TA_TFACTORALPHA      35
#define TA_SPECULARALPHA     36
#define TA_TEMPALPHA	     47	

#define TA_INVDIFFUSEALPHA   48
#define TA_INVCURRENTALPHA   49
#define TA_INVTEXTUREALPHA   50
#define TA_INVTFACTORALPHA   51
#define TA_INVSPECULARALPHA  52
#define TA_INVTEMPALPHA      53	


#define TEXF_NONE            0 ; filtering disabled (valid for mip filter only)
#define TEXF_POINT           1 ; nearest
#define TEXF_LINEAR          2 ; linear interpolation
#define TEXF_ANISOTROPIC     3 ; anisotropic
#define TEXF_FLATCUBIC       4 ; cubic
#define TEXF_GAUSSIANCUBIC   5 ; different cubic kernel

#define	TF_POINT 		0
#define TF_POINT_MIP_POINT 	1
#define TF_POINT_MIP_LINEAR 	2
#define TF_LINEAR 		3
#define TF_LINEAR_MIP_POINT 	4
#define TF_LINEAR_MIP_LINEAR 	5
#define TF_ANISOTROPIC 		6
#define TF_FLATCUBIC 		7
#define TF_GAUSSIANCUBIC	8
#define TF_UNUSED		9


#define PV_DONOTCOPYDATA     1


#define SP_WRITEMASK_0       0x00010000  ; Component 0 (X;Red)
#define SP_WRITEMASK_1       0x00020000  ; Component 1 (Y;Green)
#define SP_WRITEMASK_2       0x00040000  ; Component 2 (Z;Blue)
#define SP_WRITEMASK_3       0x00080000  ; Component 3 (W;Alpha)
#define SP_WRITEMASK_ALL     0x000F0000


#define VBF_DISABLE   0     Disable vertex blending
#define VBF_1WEIGHTS  1     2 matrix blending
#define VBF_2WEIGHTS  2     3 matrix blending
#define VBF_3WEIGHTS  3     4 matrix blending
#define VBF_TWEENING  255   blending using D3DRS_TWEENFACTOR
#define VBF_0WEIGHTS  256   one matrix is used with weight 1.0


#define TTFF_DISABLE          0	; texture coordinates are passed directly
#define TTFF_COUNT1           1	; rasterizer should expect 1-D texture coords
#define TTFF_COUNT2           2	; rasterizer should expect 2-D texture coords
#define TTFF_COUNT3           3	; rasterizer should expect 3-D texture coords
#define TTFF_COUNT4           4	; rasterizer should expect 4-D texture coords
#define TTFF_PROJECTED1       257	; texcoords to be divided by COUNTth element
#define TTFF_PROJECTED2       258	; texcoords to be divided by COUNTth element
#define TTFF_PROJECTED3       259	; texcoords to be divided by COUNTth element
#define TTFF_PROJECTED4       260	; texcoords to be divided by COUNTth element


#define CUBEMAP_FACE_POSITIVE_X	 0
#define CUBEMAP_FACE_NEGATIVE_X  1
#define CUBEMAP_FACE_POSITIVE_Y  2
#define CUBEMAP_FACE_NEGATIVE_Y  3
#define CUBEMAP_FACE_POSITIVE_Z  4 
#define CUBEMAP_FACE_NEGATIVE_Z  5

#define ASORT_FALSE     0
#define ASORT_TRUE 	1
#define ASORT_PRIORITY  2

#define TSS_TCI_PASSTHRU0 			0	;0
#define TSS_TCI_PASSTHRU1 			1	;0
#define TSS_TCI_PASSTHRU2 			2	;0
#define TSS_TCI_PASSTHRU3 			3	;0
#define TSS_TCI_CAMERASPACENORMAL 		65536	;65536
#define TSS_TCI_CAMERASPACEPOSITION 		131072	;131072
#define TSS_TCI_CAMERASPACEREFLECTIONVECTOR 	196608	;196608

#define TTM_NONE	    0
#define TTM_SPHERICALENVMAP 1
#define TTM_CUBEENVMAP      2
#define TTM_UVTRANSFORM	    3

#define DPBM_FIRSTSUNLIGHT	0
#define DPBM_SUNLIGHT		1
#define DPBM_NEARESTLIGHT	2
#define DPBM_ALLIGHT		3

;VertexShader declarator

#define VSD_TOKEN_NOP		0 ;NOP or extension
#define VSD_TOKEN_STREAM	1 ;stream selector
#define VSD_TOKEN_STREAMDATA	2 ;stream data definition (map to vertex input memory)
#define VSD_TOKEN_TESSELLATOR	3 ;vertex input memory from tessellator
#define VSD_TOKEN_CONSTMEM	4 ;constant memory from shader
#define VSD_TOKEN_EXT		5 ;extension
#define VSD_TOKEN_END 		7 ;


#define VSDT_FLOAT1	0 ;1D float expanded to (value,0.,0.,1.)
#define VSDT_FLOAT2     1 ;2D float expanded to (value,value,0.,1.)
#define VSDT_FLOAT3     2 ;3D float expanded to (value,value,value,1.)
#define VSDT_FLOAT4     3 ;4D float
#define VSDT_D3DCOLOR   4 ;4D packed unsigned bytes mapped to 0. to 1. range
#define VSDT_UBYTE4     5 ;4D unsigned byte
#define VSDT_SHORT2     6 ;2D signed short expanded to (value,value,0.,1.)
#define VSDT_SHORT4     7 ;4D signed short

#define VSDE_POSITION 		0
#define VSDE_BLENDWEIGHT 	1
#define VSDE_BLENDINDICES 	2
#define VSDE_NORMAL 		3
#define VSDE_PSIZE 		4
#define VSDE_DIFFUSE 		5
#define VSDE_SPECULAR 		6
#define VSDE_TEXCOORD0 		7
#define VSDE_TEXCOORD1 		8
#define VSDE_TEXCOORD2 		9
#define VSDE_TEXCOORD3 		10
#define VSDE_TEXCOORD4 		11
#define VSDE_TEXCOORD5 		12
#define VSDE_TEXCOORD6 		13
#define VSDE_TEXCOORD7 		14
#define VSDE_POSITION2 		15
#define VSDE_NORMAL2 		16
