/*---------------------------------------------------------------------------* Project: NintendoWare File: VertexShader.h Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. The content herein is highly confidential and should be handled accordingly. $Revision: 31311 $ *---------------------------------------------------------------------------*/ #ifndef NW_VERTEXSHADER_H_ #define NW_VERTEXSHADER_H_ //----------------------------------------------------------------------------- // UNDONE: ※レジスタのマクロ名の命名規則は、統一される予定です。 //----------------------------------------------------------------------------- //---------------------------------------- //! @name 比較関連 //@{ #define EQ 0 #define NEQ 1 #define LESS 2 #define LEQ 3 #define GT 4 #define GEQ 5 //@} //---------------------------------------- //! @name コンディション関連 //@{ #define COND_MODE_OR 0 #define COND_MODE_AND 1 #define COND_MODE_STA0 2 #define COND_MODE_STA1 3 //@} //---------------------------------------- //! @name ステータスレジスタ関連 //@{ #define STAT0_0 0 #define STAT0_1 1 #define STAT1_0 0 #define STAT1_1 1 //@} //---------------------------------------- //! @name 頂点ライト関連 //@{ #define VERTEX_LIGHT_AMBIENT 0 #define VERTEX_LIGHT_DIFFUSE 1 #define VERTEX_LIGHT_POSITION 2 #define VERTEX_LIGHT_SPOT_DIRECTION 3 #define VERTEX_LIGHT_DISTANCE_ATTENUATION 4 #define VERTEX_LIGHT_SPOT_FACTOR 5 // 頂点ライトのユニフォームです。 // ユニバーサルレジスタの割り当てが変更された場合は必ず修正してください。 // vertexLight = UserRegister + offset + UnivReg(25) - VertexLightUnit(6) #define VERTEX_LIGHT_UNIFORM(offset) nw_user_register_start[offset + 19] //@} #define _XYZW xyzw #define _XYWZ xywz #define _XYZ xyz #define _XY xy #define _X x #define _Y y #define _Z z #define _W w //---------------------------------------- //! @name コンスタントレジスタ割当 //@{ //! @brief World Matrix です。 //! //! (Smooth or Rigid)Skinning 有りで ModelCoordinate = true の場合は model_to_world となります。 //! ModelCoordinate = false の場合は単位マトリクスになります。 //! Skinning 無しの場合は単位マトリクスになります。 //! #define nw_local_to_world_matrix c0 //! @brief Normal Matrix です。 //! //! (Smooth or Rigid)Skinning 有りで ModelCoordinate = true の場合は model_to_view となります。 //! ModelCoordinate = false の場合は world_to_view になります。 //! Skinning 無しの場合は model_to_view になります。 //! ※この Matrix には ViewMatrix がかかって「います」。 //! #define nw_normal_matrix c3 #define nw_position_offset c6 #define nw_attribute_scale0 c7 // 頂点、法線、タンジェント、カラーのスケール値 #define nw_attribute_scale1 c8 // テクスチャ0〜2のスケール値、ウェイトのスケール値 #define nw_texture_coordinate c10 #define nw_inverse_view_matrix c11 // キューブマッピングのときにのみビューマトリクスの逆行列が格納されています。 #define nw_texture_matrix0 c11 #define nw_texture_matrix1 c14 #define nw_texture_matrix2 c17 #define nw_texture_translate c19 #define nw_material_ambient c20 #define nw_vertex_color_scale c20._W // アンビエントカラーのレジスタと共有している #define nw_material_diffuse c21 #define nw_hemi_sphere_ground c22 #define nw_hemi_sphere_sky c23 #define nw_hemi_sphere_direction c24 #define nw_matrix_pallet c25 // sincos マクロを使いたい場合に c93-c95 が使用される可能性があるので、c86-c92 を使っています。 //! @brief Projection Matrix です。 #define nw_projection_matrix c86 //! @brief 頂点位置用の View Matrix です。 //! //! 法線等にはこの View Matrix は使用していません。 //! #define nw_world_to_view_matrix c90 #define nw_is_smooth_skin b1 #define nw_is_rigid_skin b2 #define nw_is_hemi_sphere_lighting b5 #define nw_is_hemi_sphere_occlusion b6 #define nw_is_vertex_alpha_enable b7 #define nw_is_bone_weight_enable b8 #define nw_uv_mapping_position0 b9 #define nw_uv_mapping_position1 b10 #define nw_uv_mapping_position2 b11 #define nw_is_vertex_lighting b12 #define nw_is_texture1_enabled b13 #define nw_is_texture2_enabled b14 #define nw_is_quaternion_enabled b15 // 定数 #define CONSTANT c93 def CONSTANT[0], 0.0, 1.0, 2.0, 3.0 def CONSTANT[1], 0.125, 0.00390625, 0.5, 0.25 def CONSTANT[2], 3.0, 4.0, 5.0, 6.0 #define CONST_0 CONSTANT[0].x #define CONST_1 CONSTANT[0].y #define CONST_2 CONSTANT[0].z #define CONST_3 CONSTANT[0].w #define CONST_4 CONSTANT[2].y #define CONST_5 CONSTANT[2].z #define CONST_6 CONSTANT[2].w #define CONST_HALF CONSTANT[1].z #define CONST_QUARTER CONSTANT[1].w #define CONST_1__4 CONSTANT[1].w #define CONST_1__8 CONSTANT[1].x #define CONST_1__256 CONSTANT[1].y #define CONST_0_0_0_0 CONSTANT[0].xx #define CONST_0_1_1_1 CONSTANT[0].xy #define CONST_0_0_0_1 CONSTANT[0].xxxy #define CONST_0_0_1_1 CONSTANT[0].xxyy #define CONST_0_2_2_2 CONSTANT[0].xz #define CONST_0_3_3_3 CONSTANT[0].xw #define CONST_1_0_0_0 CONSTANT[0].yx #define CONST_1_1_1_1 CONSTANT[0].yy #define CONST_1_2_2_2 CONSTANT[0].yz #define CONST_1_3_3_3 CONSTANT[0].yw #define CONST_3_4_4_4 CONSTANT[2].xy //@} //---------------------------------------- //! @name 整数レジスタ割当 //@{ #define nw_vertex_light_count i0 //@} //---------------------------------------- //! @name 標準入力レジスタ割当 //@{ #define nw_position v0 #define nw_normal v1 #define nw_tangent v2 #define nw_color v3 #define nw_texcoord0 v4 #define nw_texcoord1 v5 #define nw_texcoord2 v6 #define nw_boneIndex v7 #define nw_boneWeight v8 #define nw_userAttribute0 v9 #define nw_userAttribute1 v10 #define nw_userAttribute2 v11 //@} //---------------------------------------- //! @name 標準出力レジスタ割当 //@{ #define o_Position o0 #define o_Quaternion o1 #define o_View o2 #define o_Color o3 #define o_TexCoord0 o4 #define o_TexCoord1 o5 #define o_TexCoord2 o6 //@} //---------------------------------------- //! @name テンポラリレジスタ割当 //@{ // ルーチン内などで計算用に使うレジスタ #define TEMP0 r0 #define TEMP1 r1 #define TEMP2 r2 #define TEMP3 r3 #define TEMP4 r4 #define TEMP5 r5 #define TEMP6 r6 #define TEMP7 r7 #define TEMP8 r8 #define TEMP9 r9 // クォータニオン計算ルーチン内では書き換え禁止 #define TEMP_QUAT r0 #define TRAN_TEX0 r3 #define TRAN_TEX1 r4 #define TRAN_TEX2 r5 // ルーチンの引数などに使うレジスタ #define TEMP_COLO r9 #define TEMP_STUS r8 #define TEMP_TEX r6 #define TEMP_TEX0 r7 #define TEMP_TEX1 r8 #define TEMP_TEX2 r9 #define MODL_POSI r7 //#define MODL_TANG r8 //#define MODL_NORM r9 // 色々参照される可能性のあるレジスタ // ライティングやテクスチャ座標でも使うので上書きしないように #define WRLD_POSI r10 #define WRLD_TANG r11 #define WRLD_NORM r12 // ルーチンの引数としても使われ、色々参照される可能性のあるレジスタ // ライティングやテクスチャ座標でも使うので上書きしないように #define TEMP_TANG r13 #define TEMP_NORM r14 #define TEMP_POSI r15 #define TEMP_VIEW r15 // 注意! TEMP_POSI と同じレジスタです。 //@} #endif // NW_VERTEXSHADER_H_