/*---------------------------------------------------------------------------

    NN material header for DXG20

    Copyright (C) 2002, 2003 SEGA Corporation Creative Center Graphics Sect.
    All Rights Reserved.

    Module  : NN material format for DXG20
    File    : nnfmaterialxe.h
    Create  : 2003/06/05
    Modify  : 2003/07/14 Xbox,PC共通化向けの修正
    Modify  : 2003/10/17 各種ブレンド定義を追加
    Modify  : 2003/10/24 新フォーマット、マテリアルフラグ形式に
    Modify  : 2004/03/10 NND_TEXMAPTYPE_STAGE_DECAL2対応
    Modify  : 2004/03/25 大幅修正
    Modify  : 2004/03/29 NND_MATFLAG_DISABLE_TEXMATRIX追加
    Modify  : 2004/04/28 NND_TEXMAPTYPE_STAGE_SPECULARMAPを追加
    Modify  : 2004/05/25 NND_TEXMAPTYPE_STAGE_SPECULARMAP2を追加
    Modify  : 2004/06/20 DX8,DX9版統合
    Modify  : 2004/06/28 NND_MATFLAG_TWOSIDED_LIGHTINGを追加
    Modify  : 2004/08/05 NND_PLATFORM_XENON追加
    Modify  : 2004/09/13 NNS_MATERIAL_TEXMAP2_DESC対応
    Modify  : 2005/01/13 NND_TEXMAPTYPE_STAGE_NORMALMAP追加
    Modify  : 2008/10/28 NND_WRAPMODE_STDSHADER_*** の不具合修正
    Modify  : 2008/11/27 NND_BLENDFUNC_STDSHADER_CONSTANT_ALPHA はないのでコメント
	                     NND_BLENDFUNC_STDSHADER_ONE_MINUS_CONSTANT_ALPHA はないのでコメント
						 NND_TEXFILTER_STDSHADER_*** の設定を以下のように変更(ただし変更前の値と同じ)
						   NND_TEXFILTER_STDSHADER_NONE			D3DTEXF_NONE		// 0
						   NND_TEXFILTER_STDSHADER_NEAREST		D3DTEXF_POINT		// 1
						   NND_TEXFILTER_STDSHADER_LINEAR		D3DTEXF_LINEAR		// 2
						   NND_TEXFILTER_STDSHADER_ANISOTROPIC	D3DTEXF_ANISOTROPIC	// 3
    Modify  : 2009/05/12 ヘッダ整理
    Modify  : 2009/06/11 ヘッダ整理２
    Version : 1.18.14
    Note    : 

---------------------------------------------------------------------------*/

#ifndef	__NNFMATERIALDXG20_H__
#define	__NNFMATERIALDXG20_H__

// Material type value
#define	NND_MATTYPE_MATRIEALDESC				((Uint32) 0 <<  28)
#define NND_MATTYPE_STDSHADERDESC				((Uint32) 1 <<  28)
#define NND_MATTYPE_USERPROFILE					((Uint32) 2 <<  28)
#define NND_MATTYPE_MATTYPE_MASK				(0xf0000000)

/*------ Custom Shader ----------------------------------------------------*/



// Material type value
#define	NND_MATTYPE_NOTEXTURE		(0)
#define	NND_MATTYPE_TEXTURE			(1)
#define	NND_MATTYPE_TEXTURE2		(2)
#define	NND_MATTYPE_TEXTURE3		(3)
#define	NND_MATTYPE_TEXTURE4		(4)
#define NND_MATTYPE_TEXTURE_NUM_MASK	(0x0000000F)

#define NND_MATTYPE_TEXMATTYPE1			(0x00000000)
#define NND_MATTYPE_TEXMATTYPE2			(0x00000010)
#define NND_MATTYPE_TEXMATTYPE_MASK		(0x000000F0)

// Material flag
typedef	Uint32	NNF_MATFLAG;

#define	NND_MATFLAG_HIDE				((Uint32)1 <<  0)	// 表示しない
#define	NND_MATFLAG_DOUBLESIDE			((Uint32)1 <<  1)	// 両面ポリゴン(カリング無し)

#define	NND_MATFLAG_DISABLE_LIGHTING	((Uint32)1 <<  2)	// ライティングをしない
#define	NND_MATFLAG_DISABLE_FOGGING		((Uint32)1 <<  3)	// フォグをしない
#define	NND_MATFLAG_VERTEX_COLOR		((Uint32)1 <<  4)	// 頂点カラーを使用する
#define	NND_MATFLAG_DISABLE_TEXMATRIX	((Uint32)1 <<  5)	// テクスチャマトリクスを使用しない
#define	NND_MATFLAG_TWOSIDED_LIGHTING	((Uint32)1 <<  6)	// 2面ライティング（カリング無し）

//#define	NND_MATFLAG_DISABLE_ALPHATEST	((Uint32)1 <<  8)	// アルファテストをしない
//#define	NND_MATFLAG_DISABLE_ZCOMP		((Uint32)1 << 16)	// Zバッファ比較をしない
//#define	NND_MATFLAG_DISABLE_ZBUF_UPDATE	((Uint32)1 << 17)	// Zバッファ更新をしない

#define	NND_MATFLAG_SPECULAR_OFF		((Uint32)0 << 24)
#define	NND_MATFLAG_SPECULAR_LIGHT		((Uint32)1 << 24)	// スペキュラ有り

#define	NND_MATFLAG_CALLBACK			((Uint32)1 << 31)	// マテリアルコールバック

// Texture mapping type
typedef Uint32	NNF_TEXMAPTYPE;

// Texture mapping descriptor 32byte
typedef struct {
    NNF_TEXMAPTYPE              fTexMapType;
    Sint32                      iTexIdx;
    NNS_TEXCOORD                Offset;
    Float                       Blend;          // Texture blend ratio
    void                        *pTexInfo;
    Uint32                      Reserved[2];    // 予約領域
} NNS_MATERIAL_TEXMAP_DESC;

typedef struct {
    NNF_TEXMAPTYPE              fTexMapType;
    Sint32                      iTexIdx;
    NNS_TEXCOORD                Offset;
    Float                       Blend;          // Texture blend ratio
    void                        *pTexInfo;
    NNF_TEXFILE_MINFILTER       MinFilter;      /* Texture minfilter mode */
    NNF_TEXFILE_MAGFILTER       MagFilter;      /* Texture magfilter mode */
    Float                       MipMapBias;
    Uint32                      MaxMipLevel;
    Uint32                      Reserved[3];    // 予約領域
} NNS_MATERIAL_TEXMAP2_DESC;

// Texture mapping type value
// Texture stage blending
#define	NND_TEXMAPTYPE_STAGE_MODULATE		((Uint32) 1)
#define	NND_TEXMAPTYPE_STAGE_DECAL			((Uint32) 2)
#define	NND_TEXMAPTYPE_STAGE_REPLACE		((Uint32) 3)
#define	NND_TEXMAPTYPE_STAGE_BLEND			((Uint32) 4)
#define	NND_TEXMAPTYPE_STAGE_DECAL2			((Uint32) 5)
#define NND_TEXMAPTYPE_STAGE_LIGHT			((Uint32) 6)
#define NND_TEXMAPTYPE_STAGE_SPECULARMAP	((Uint32) 7)
#define NND_TEXMAPTYPE_STAGE_SPECULARMAP2	((Uint32) 8)
#define	NND_TEXMAPTYPE_STAGE_ADD			((Uint32) 9)
#define	NND_TEXMAPTYPE_STAGE_SUBTRACT		((Uint32)10)
#define	NND_TEXMAPTYPE_STAGE_NORMALMAP		((Uint32)11)
#define	NND_TEXMAPTYPE_STAGE_MASK			(0x0000000F)

// UV type
#define	NND_TEXMAPTYPE_UV0					((Uint32)1 << 8)
#define	NND_TEXMAPTYPE_UV1					((Uint32)1 << 9)
#define	NND_TEXMAPTYPE_UV2					((Uint32)1 << 10)
#define	NND_TEXMAPTYPE_UV3					((Uint32)1 << 11)
#define	NND_TEXMAPTYPE_POSITION				((Uint32)1 << 12)	// no support
#define	NND_TEXMAPTYPE_ENVIRONMENT			((Uint32)1 << 13)
#define	NND_TEXMAPTYPE_BUMP					((Uint32)1 << 14)	// no support

// Wrap mode
#define	NND_TEXMAPTYPE_CLAMP_U				((Uint32)1 << 16)
#define	NND_TEXMAPTYPE_CLAMP_V				((Uint32)1 << 17)
#define	NND_TEXMAPTYPE_REPEAT_U				((Uint32)1 << 18)
#define	NND_TEXMAPTYPE_REPEAT_V				((Uint32)1 << 19)
#define	NND_TEXMAPTYPE_MIRROR_U				((Uint32)1 << 20)
#define	NND_TEXMAPTYPE_MIRROR_V				((Uint32)1 << 21)

#define	NND_TEXMAPTYPE_ALPHAKILL			((Uint32)1 << 24)	// no support

#define NND_TEXMAPTYPE_TEXFILTER			((Uint32)1 << 25)   
#define NND_TEXMAPTYPE_MIPMAPBIAS			((Uint32)1 << 26)   
#define NND_TEXMAPTYPE_MIPMAPLEVEL			((Uint32)1 << 27)   

// Skip offset, scale, crop
#define	NND_TEXMAPTYPE_NO_UV_TRANSFORM		((Uint32)1 << 30)	// no support
// Callback
#define	NND_TEXMAPTYPE_CALLBACK				((Uint32)1 << 31)	// no support


// Frame buffer blend mode (D3DBLEND)
typedef enum {
	NNE_BLENDMODE_ZERO             = 0,		// (0, 0, 0, 0) 
	NNE_BLENDMODE_ONE              = 1,		// (1, 1, 1, 1)
	NNE_BLENDMODE_SRCCOL           = 0x300,	// (Rs, Gs, Bs, As)
	NNE_BLENDMODE_INVSRCCOL        = 0x301,	// (1-Rs, 1-Gs, 1-Bs, 1-As)
	NNE_BLENDMODE_SRCALPHA         = 0x302,	// (As, As, As, As)
	NNE_BLENDMODE_INVSRCALPHA      = 0x303,	// (1-As, 1-As, 1-As, 1-As)
	NNE_BLENDMODE_DSTALPHA         = 0x304,	// (Ad, Ad, Ad, Ad)
	NNE_BLENDMODE_INVDSTALPHA      = 0x305,	// (1-Ad, 1-Ad, 1-Ad, 1-Ad)
	NNE_BLENDMODE_DSTCOL           = 0x306,	// (Rd, Gd, Bd, Ad)
	NNE_BLENDMODE_INVDSTCOL        = 0x307,	// (1-Rd, 1-Gd, 1-Bd, 1-Ad)
	NNE_BLENDMODE_SRCALPHASAT      = 0x308,	// (f, f, f, 1)、f = min(A, 1-Ad)
	NNE_BLENDMODE_CONSTANTCOLOR    = 0x8001,// Xbox
	NNE_BLENDMODE_INVCONSTANTCOLOR = 0x8002,// Xbox
	NNE_BLENDMODE_CONSTANTALPHA    = 0x8003,// Xbox
	NNE_BLENDMODE_INVCONSTANTALPHA = 0x8004,// Xbox
} NNE_BLENDMODE;


// ブレンディング算術演算式 (D3DBLENDOP)
typedef enum {
	NNE_BLENDOP_ADD               = 0x8006,	// Src + Dest
	NNE_BLENDOP_SUB               = 0x800a,	// Src - Dest
	NNE_BLENDOP_REVSUB            = 0x800b,	// Dest - Src
	NNE_BLENDOP_MIN               = 0x8007,	// MIN( Src, Dest )
	NNE_BLENDOP_MAX               = 0x8008,	// MAX( Src, Dest )
	NNE_BLENDOP_ADDSIGNED         = 0xf006,	// Xbox
	NNE_BLENDOP_REVSUBTRACTSIGNED = 0xf005,	// Xbox
} NNE_BLENDOP;

// 比較式 (D3DCMPFUNC)
typedef enum {
	NNE_CMPFUNC_NEVER        = 0x200,		// 常に失敗
	NNE_CMPFUNC_LESS         = 0x201,		// <
	NNE_CMPFUNC_EQUAL        = 0x202,		// =
	NNE_CMPFUNC_LESSEQUAL    = 0x203,		// <=
	NNE_CMPFUNC_GREATER      = 0x204,		// >
	NNE_CMPFUNC_NOTEQUAL     = 0x205,		// !=
	NNE_CMPFUNC_GREATEREQUAL = 0x206,		// >=
	NNE_CMPFUNC_ALWAYS       = 0x207,		// 常にパス
} NNE_CMPFUNC;


// ブレンドロジック(D3DLOGICOP)
typedef enum {
	NNE_LOGICOP_NONE             = 0,
	NNE_LOGICOP_CLEAR            = 0x1500,
	NNE_LOGICOP_AND              = 0x1501,
	NNE_LOGICOP_AND_REVERSE      = 0x1502,
	NNE_LOGICOP_COPY             = 0x1503,
	NNE_LOGICOP_AND_INVERTED     = 0x1504,
	NNE_LOGICOP_NOOP             = 0x1505,
	NNE_LOGICOP_XOR              = 0x1506,
	NNE_LOGICOP_OR               = 0x1507,
	NNE_LOGICOP_NOR              = 0x1508,
	NNE_LOGICOP_EQUIV            = 0x1509,
	NNE_LOGICOP_INVERT           = 0x150a,
	NNE_LOGICOP_OR_REVERSE       = 0x150b,
	NNE_LOGICOP_COPY_INVERTED    = 0x150c,
	NNE_LOGICOP_OR_INVERTED      = 0x150d,
	NNE_LOGICOP_NAND             = 0x150e,
	NNE_LOGICOP_SET              = 0x150f,
} NNE_BLENDLOGICOP;


//
// Default material
//
//Material Color 32byte
typedef struct{
	NNS_RGBA                    Diffuse;        // ディフューズカラー
	NNS_RGBA                    Ambient;        // アンビエントカラー
	NNS_RGBA                    Specular;       // スペキュラカラー
	NNS_RGBA                    Emissive;       // エミッシブカラー
	Float                       Power;          // スペキュラ乗数
	Uint32                      Reserved[3];    // 予約領域
}NNS_MATERIAL_COLOR;

//Material Logic 64byte
typedef struct{
	NNE_BOOL                    bBlend;         // オペーク、パンチスルーの場合のブレンディングのTRUE、FALSE
	NNE_BLENDMODE               SrcBlend;       // ブレンドモードソースカラー係数
	NNE_BLENDMODE               DstBlend;       // ブレンドモードフレームバッファカラー係数
	Uint32                      BlendFactor;    // 定数ブレンディング係数(ARGB8888)
	NNE_BLENDOP                 BlendOp;        // ブレンドモード
	NNE_BLENDLOGICOP            LogicOp;        // フレームバッファブレンド論理演算
	NNE_BOOL                    bAlpha;         // アルファテストのTRUE、FALSE
	NNE_CMPFUNC                 AlphaFunc;      // アルファテスト比較式
	Uint32                      AlphaRef;       // アルファテスト用の基準アルファ値(下位8ビット)
	NNE_BOOL                    bZComp;         // Zバッファ比較のTRUE、FALSE
	NNE_CMPFUNC                 ZFunc;          // Zバッファ比較式
	NNE_BOOL                    bZUpdate;       // Z更新のTRUE、FALSE
	Uint32                      Reserved[4];    // 予約領域
}NNS_MATERIAL_LOGIC;

//Material descriptor 32byte
typedef struct {
	NNF_MATFLAG                 fMatFlag;
	Uint32                      User;
	NNS_MATERIAL_COLOR          *pMatColor;
	NNS_MATERIAL_LOGIC          *pMatLogic;
	void                        *pTexDesc;
	Uint32                      Reserved[3];    // 予約領域
} NNS_MATERIAL_DESC;



/*------ Standard Shader --------------------------------------------------*/



// Material flag
typedef	Uint32 NNF_MATFLAG_STDSHADER;

#define	NND_MATFLAG_STDSHADER_DOUBLESIDE				((Uint32) 1 <<  0)
#define	NND_MATFLAG_STDSHADER_DISABLE_LIGHTING			((Uint32) 1 <<  1)
#define	NND_MATFLAG_STDSHADER_DISABLE_FOGGING			((Uint32) 1 <<  2)
#define	NND_MATFLAG_STDSHADER_TWOSIDED_LIGHTING			((Uint32) 1 <<  3)	/* for vertex-lighting only */
#define	NND_MATFLAG_STDSHADER_TWOSIDED_MATERIAL			((Uint32) 1 <<  4)	/* no support */

#define NND_MATFLAG_STDSHADER_DISABLE_DEPTH_WRITING		((Uint32) 1 <<  8)
#define NND_MATFLAG_STDSHADER_DISABLE_COLOR_R_WRITING	((Uint32) 1 <<  9)
#define NND_MATFLAG_STDSHADER_DISABLE_COLOR_G_WRITING	((Uint32) 1 << 10)
#define NND_MATFLAG_STDSHADER_DISABLE_COLOR_B_WRITING	((Uint32) 1 << 11)
#define NND_MATFLAG_STDSHADER_DISABLE_COLOR_A_WRITING	((Uint32) 1 << 12)

#define	NND_MATFLAG_STDSHADER_CALLBACK					((Uint32) 1 << 31)


// Material Color Flag
typedef Uint32 NNF_MATCOLFLAG_STDSHADER;
#define NND_MATCOLFLAG_STDSHADER_VTXCOL_MATERIAL			((Uint32) 1 <<  0)
#define NND_MATCOLFLAG_STDSHADER_SPECULAR_INTENSITY			((Uint32) 1 <<  1)


// Logic Flag
typedef Uint32 NNF_MATLOGICFLAG_STDSHADER;
#define NND_MATLOGICFLAG_STDSHADER_ENABLE_BLEND				((Uint32) 1 <<  0)
#define NND_MATLOGICFLAG_STDSHADER_BLEND_FUNC_SEPARATE		((Uint32) 1 <<  1)
#define NND_MATLOGICFLAG_STDSHADER_ENABLE_LOGIC_OP			((Uint32) 1 <<  2)
#define NND_MATLOGICFLAG_STDSHADER_ENABLE_ALPHA_TEST		((Uint32) 1 <<  3)
#define NND_MATLOGICFLAG_STDSHADER_ENABLE_DEPTH_TEST		((Uint32) 1 <<  4)


// glBlendFunc, glBlendFuncSeparate
#define NND_BLENDFUNC_STDSHADER_ZERO						D3DBLEND_ZERO 				// (0, 0, 0, 0)
#define NND_BLENDFUNC_STDSHADER_ONE							D3DBLEND_ONE 				// (1, 1, 1, 1)
#define NND_BLENDFUNC_STDSHADER_SRC_COLOR					D3DBLEND_SRCCOLOR			// (Rs, Gs, Bs, As)
#define NND_BLENDFUNC_STDSHADER_ONE_MINUS_SRC_COLOR			D3DBLEND_INVSRCCOLOR		// (1-Rs, 1-Gs, 1-Bs, 1-As)
#define NND_BLENDFUNC_STDSHADER_SRC_ALPHA					D3DBLEND_SRCALPHA 			// (As, As, As, As)
#define NND_BLENDFUNC_STDSHADER_ONE_MINUS_SRC_ALPHA			D3DBLEND_INVSRCALPHA		// (1-As, 1-As, 1-As, 1-As)
#define NND_BLENDFUNC_STDSHADER_DST_ALPHA					D3DBLEND_DESTALPHA 			// (Ad, Ad, Ad, Ad)
#define NND_BLENDFUNC_STDSHADER_ONE_MINUS_DST_ALPHA			D3DBLEND_INVDESTALPHA		// (1-Ad, 1-Ad, 1-Ad, 1-Ad)
#define NND_BLENDFUNC_STDSHADER_DST_COLOR					D3DBLEND_DESTCOLOR			// (Rd, Gd, Bd, Ad)
#define NND_BLENDFUNC_STDSHADER_ONE_MINUS_DST_COLOR			D3DBLEND_INVDESTCOLOR		// (1-Rd, 1-Gd, 1-Bd, 1-Ad)
#define NND_BLENDFUNC_STDSHADER_CONSTANT_COLOR				D3DBLEND_BLENDFACTOR		// (Rc, Gc, Bc, Ac)
#define NND_BLENDFUNC_STDSHADER_ONE_MINUS_CONSTANT_COLOR	D3DBLEND_INVBLENDFACTOR		// (1-Rc, 1-Gc, 1-Bc, 1-Ac)
#if 1 /* 機能はしてないがエクスポータから出力されているので宣言は必要(2009.06.11) */
#define NND_BLENDFUNC_STDSHADER_CONSTANT_ALPHA				D3DBLEND_CONSTANTALPHA 		// (Ac, Ac, Ac, Ac)
#define NND_BLENDFUNC_STDSHADER_ONE_MINUS_CONSTANT_ALPHA	D3DBLEND_INVCONSTANTALPHA	// (1-Ac, 1-Ac, 1-Ac, 1-Ac)
#endif
#define NND_BLENDFUNC_STDSHADER_SRC_ALPHA_SATURATE			D3DBLEND_SRCALPHASAT		// (f, f, f, 1), f = min(As, 1-Ad)

// glBlendEquation
#define NND_BLENDOP_STDSHADER_MIN							D3DBLENDOP_MIN				// Rr = min( Rs, Rd )
#define NND_BLENDOP_STDSHADER_MAX							D3DBLENDOP_MAX				// Rr = max( Rs, Rd )
#define NND_BLENDOP_STDSHADER_FUNC_ADD						D3DBLENDOP_ADD				// Rr = min( 1, Rs*sR + Rd*dR )
#define NND_BLENDOP_STDSHADER_FUNC_SUBTRACT					D3DBLENDOP_SUBTRACT			// Rr = max( 0, Rs*sR - Rd*dR )
#define NND_BLENDOP_STDSHADER_FUNC_REVERSE_SUBTRACT			D3DBLENDOP_REVSUBTRACT		// Rr = max( 0, Rd*dR - Rs*sR )

// glAlphaFunc, glDepthFunc
#define NND_CMPFUNC_STDSHADER_NEVER							D3DCMP_NEVER				// 0
#define NND_CMPFUNC_STDSHADER_LESS							D3DCMP_LESS					// val <  ref
#define NND_CMPFUNC_STDSHADER_EQUAL							D3DCMP_EQUAL				// val == ref
#define NND_CMPFUNC_STDSHADER_LEQUAL						D3DCMP_LESSEQUAL			// val <= ref
#define NND_CMPFUNC_STDSHADER_GREATER						D3DCMP_GREATER				// val >  ref
#define NND_CMPFUNC_STDSHADER_NOTEQUAL						D3DCMP_NOTEQUAL				// val != ref
#define NND_CMPFUNC_STDSHADER_GEQUAL						D3DCMP_GREATEREQUAL			// val >= ref
#define NND_CMPFUNC_STDSHADER_ALWAYS						D3DCMP_ALWAYS				// 1

// glLogicOp
/*   DXG20 では機能しません(2008.07.29) */
/*   機能はしてないがエクスポータから出力されているので宣言は必要(2009.06.11) */
#define NND_LOGICOP_STDSHADER_CLEAR							0x1500	// 0
#define NND_LOGICOP_STDSHADER_AND							0x1501	// s & d
#define NND_LOGICOP_STDSHADER_AND_REVERSE					0x1502	// s & ~d
#define NND_LOGICOP_STDSHADER_COPY							0x1503	// s
#define NND_LOGICOP_STDSHADER_AND_INVERTED					0x1504	// ~s & d
#define NND_LOGICOP_STDSHADER_NOOP							0x1505	// d
#define NND_LOGICOP_STDSHADER_XOR							0x1506	// s ^ d
#define NND_LOGICOP_STDSHADER_OR							0x1507	// s | d
#define NND_LOGICOP_STDSHADER_NOR							0x1508	// ~(s | d)
#define NND_LOGICOP_STDSHADER_EQUIV							0x1509	// ~(s ^ d)
#define NND_LOGICOP_STDSHADER_INVERT						0x150A	// ~d
#define NND_LOGICOP_STDSHADER_OR_REVERSE					0x150B	// s | ~d
#define NND_LOGICOP_STDSHADER_COPY_INVERTED					0x150C	// ~s
#define NND_LOGICOP_STDSHADER_OR_INVERTED					0x150D	// ~s | d
#define NND_LOGICOP_STDSHADER_NAND							0x150E	// ~(s & d)
#define NND_LOGICOP_STDSHADER_SET							0x150F	// s


// Material Color
typedef struct {
	NNF_MATCOLFLAG_STDSHADER	fFlag;
	NNS_RGBA					Ambient;
	NNS_RGBA					Diffuse;
	NNS_RGBA					Specular;
	NNS_RGBA					Emission;
	Float						Shininess;
	Float						SpecularIntensity;
} NNS_MATERIAL_STDSHADER_COLOR;


// Logic
typedef struct{
	NNF_MATLOGICFLAG_STDSHADER	fFlag;
	Uint16						SrcFactorRGB;   // D3DBLEND
	Uint16						DstFactorRGB;   // D3DBLEND
	Uint16						SrcFactorA;     // D3DBLEND
	Uint16						DstFactorA;     // D3DBLEND
	Uint32						BlendColor;     // D3DCOLOR デフォルト 0x00000000
	Uint16						BlendOp;        // D3DBLENDOP
	Uint16						LogicOp;        // glLogicOp (DXG20 では機能しません)
	Uint16						AlphaFunc;      // D3DCMPFUNC
	Uint16						DepthFunc;      // D3DCMPFUNC
	Uint32						AlphaRef;       // 0x0 <-> 0xff
} NNS_MATERIAL_STDSHADER_LOGIC;


// Texture Type
typedef Uint32 NNF_TEXTURETYPE_STDSHADER;
#define NND_TEXTURETYPE_STDSHADER_NORMAL_MAP				((Uint32) 1 <<  0)
#define NND_TEXTURETYPE_STDSHADER_BASE_MAP					((Uint32) 1 <<  1)
#define NND_TEXTURETYPE_STDSHADER_DECAL_MAP					((Uint32) 1 <<  2)
#define NND_TEXTURETYPE_STDSHADER_SPECULAR_MAP				((Uint32) 1 <<  3)
#define NND_TEXTURETYPE_STDSHADER_MODULATE_MAP				((Uint32) 1 <<  4)
#define NND_TEXTURETYPE_STDSHADER_ADD_MAP					((Uint32) 1 <<  5)
#define NND_TEXTURETYPE_STDSHADER_OPACITY_MAP				((Uint32) 1 <<  6)

#define NND_TEXTURETYPE_STDSHADER_DECAL2_MAP				((Uint32) 1 <<  7)		/* new */
#define NND_TEXTURETYPE_STDSHADER_DECAL3_MAP				((Uint32) 1 <<  8)		/* new */
#define NND_TEXTURETYPE_STDSHADER_SHININESS_MAP				((Uint32) 1 <<  9)		/* new */
#define NND_TEXTURETYPE_STDSHADER_DUALPARABOLOID_MAP		((Uint32) 1 << 10)		/* new */
#define NND_TEXTURETYPE_STDSHADER_ENVMASK_MAP				((Uint32) 1 << 11)		/* new */
#define NND_TEXTURETYPE_STDSHADER_USER1_MAP					((Uint32) 1 << 12)		/* new */
#define NND_TEXTURETYPE_STDSHADER_USER2_MAP					((Uint32) 1 << 13)		/* new */
#define NND_TEXTURETYPE_STDSHADER_USER3_MAP					((Uint32) 1 << 14)		/* new */
#define NND_TEXTURETYPE_STDSHADER_USER4_MAP					((Uint32) 1 << 15)		/* new */
#define NND_TEXTURETYPE_STDSHADER_USER5_MAP					((Uint32) 1 << 16)		/* new */
#define NND_TEXTURETYPE_STDSHADER_USER6_MAP					((Uint32) 1 << 17)		/* new */
#define NND_TEXTURETYPE_STDSHADER_USER7_MAP					((Uint32) 1 << 18)		/* new */
#define NND_TEXTURETYPE_STDSHADER_USER8_MAP					((Uint32) 1 << 19)		/* new */
#define NND_TEXTURETYPE_STDSHADER_MAP_MASK					((Uint32) 0x000fffff)

#define NND_TEXTURETYPE_STDSHADER_NORMAL_MAP_AXLY			((Uint32) 1 << 28)		/* new */
#define	NND_TEXTURETYPE_STDSHADER_UV_SCALE					((Uint32) 1 << 29)
#define	NND_TEXTURETYPE_STDSHADER_NO_UV_TRANSFORM			((Uint32) 1 << 30)
#define	NND_TEXTURETYPE_STDSHADER_CALLBACK					((Uint32) 1 << 31)

typedef Sint32 NNS_TEXCOORDTYPE_STDSHADER;
enum {
	NNE_TEXCOORDTYPE_STDSHADER_TEXCOORD0			=  0,
	NNE_TEXCOORDTYPE_STDSHADER_TEXCOORD1,
	NNE_TEXCOORDTYPE_STDSHADER_TEXCOORD2,
	NNE_TEXCOORDTYPE_STDSHADER_TEXCOORD3,

	NNE_TEXCOORDTYPE_STDSHADER_SPHERE_MAP			= -1,
	NNE_TEXCOORDTYPE_STDSHADER_PROJECTION_MAP		= -2,
	NNE_TEXCOORDTYPE_STDSHADER_DUALPARABOLOID_MAP	= -3,
};


// Wrap Mode
#define NND_WRAPMODE_STDSHADER_CLAMP						D3DTADDRESS_CLAMP	/* 3 */
#define NND_WRAPMODE_STDSHADER_REPEAT						D3DTADDRESS_WRAP	/* 1 */
#define NND_WRAPMODE_STDSHADER_MIRRORED_REPEAT				D3DTADDRESS_MIRROR	/* 2 */
#define NND_WRAPMODE_STDSHADER_CLAMP_TO_BORDER				D3DTADDRESS_BORDER	/* 4 */


// Filter mode
#define NND_TEXFILTER_STDSHADER_NONE						D3DTEXF_NONE			/* 0 */
#define NND_TEXFILTER_STDSHADER_NEAREST						D3DTEXF_POINT			/* 1 */
#define NND_TEXFILTER_STDSHADER_LINEAR						D3DTEXF_LINEAR			/* 2 */
#define NND_TEXFILTER_STDSHADER_ANISOTROPIC					D3DTEXF_ANISOTROPIC		/* 3 */

typedef struct {
	Uint16						MinFilter;
	Uint16						MagFilter;
	Uint16						MipFilter;
	Uint16						Anisotropy;	// 1 <-> 16
} NNS_TEXTURE_FILTERMODE_STDSHADER;


typedef struct {
	// Sint32						BaseLevel;
	Sint32						MaxLevel;
	// Float						MinLOD;
	// Float						MaxLOD;
	Float						LODBias;	// ?16.0f <-> 15.99 
} NNS_TEXTURE_LOD_PARAM_STDSHADER;


// Texture Mapping Descriptor
typedef struct {
	NNF_TEXTURETYPE_STDSHADER			fType;
	Sint32								iTexIdx;
	NNS_TEXCOORDTYPE_STDSHADER			TexCoord;
	Float								Blend;
	NNS_TEXCOORD						Offset;
	NNS_TEXCOORD						Scale;
	Uint16								WrapS;			// D3DTEXTUREADDRESS
	Uint16								WrapT;			// D3DTEXTUREADDRESS
	Uint32								BorderColor;	// D3DCOLOR デフォルト 0x00000000
	NNS_TEXTURE_FILTERMODE_STDSHADER	*pFilterMode;
	NNS_TEXTURE_LOD_PARAM_STDSHADER		*pLODParam;
	void								*pTexInfo;
	Uint32								Reserved0;
	Uint32								Reserved1;
	Uint32								Reserved2;
} NNS_MATERIAL_STDSHADER_TEXMAP_DESC;


// Material Descriptor
typedef struct {
	NNF_MATFLAG_STDSHADER				fFlag;
	Uint32								User;
	NNS_MATERIAL_STDSHADER_COLOR		*pColor;
	NNS_MATERIAL_STDSHADER_LOGIC		*pLogic;
	NNF_TEXTURETYPE_STDSHADER			fTexType;
	Sint32								nTex;
	NNS_MATERIAL_STDSHADER_TEXMAP_DESC	*pTexDesc;
} NNS_MATERIAL_STDSHADER_DESC;

typedef struct {
	NNF_MATFLAG_STDSHADER				fFlag;
	Uint32								User;
	NNS_MATERIAL_STDSHADER_COLOR		*pColor;
	NNS_MATERIAL_STDSHADER_LOGIC		*pLogic;
	NNF_TEXTURETYPE_STDSHADER			fTexType;
	Sint32								nTex;
	NNS_MATERIAL_STDSHADER_TEXMAP_DESC	*pTexDesc;
	Uint32								UserProfile;
} NNS_MATERIAL_STDSHADER_DESC_USER_PROFILE;


#endif	//__NNFMATERIALDXG20_H__

/* End of file */
