1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     VertexShader.h
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: 31311 $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NW_VERTEXSHADER_H_
19 #define NW_VERTEXSHADER_H_
20 
21 //-----------------------------------------------------------------------------
22 // UNDONE: �����W�X�^�̃}�N�����̖����K���́A���ꂳ���\��ł��B
23 //-----------------------------------------------------------------------------
24 
25 //----------------------------------------
26 //! @name ��r�֘A
27 //@{
28 
29 #define EQ                  0
30 #define NEQ                 1
31 #define LESS                2
32 #define LEQ                 3
33 #define GT                  4
34 #define GEQ                 5
35 
36 //@}
37 
38 //----------------------------------------
39 //! @name �R���f�B�V�����֘A
40 //@{
41 
42 #define COND_MODE_OR        0
43 #define COND_MODE_AND       1
44 #define COND_MODE_STA0      2
45 #define COND_MODE_STA1      3
46 
47 //@}
48 
49 
50 //----------------------------------------
51 //! @name �X�e�[�^�X���W�X�^�֘A
52 //@{
53 
54 #define STAT0_0             0
55 #define STAT0_1             1
56 #define STAT1_0             0
57 #define STAT1_1             1
58 
59 //@}
60 
61 //----------------------------------------
62 //! @name ���_���C�g�֘A
63 //@{
64 
65 #define VERTEX_LIGHT_AMBIENT                0
66 #define VERTEX_LIGHT_DIFFUSE                1
67 #define VERTEX_LIGHT_POSITION               2
68 #define VERTEX_LIGHT_SPOT_DIRECTION         3
69 #define VERTEX_LIGHT_DISTANCE_ATTENUATION   4
70 #define VERTEX_LIGHT_SPOT_FACTOR            5
71 
72 // ���_���C�g�̃��j�t�H�[���ł��B
73 // ���j�o�[�T�����W�X�^�̊��蓖�Ă��ύX���ꂽ�ꍇ�͕K���C�����Ă��������B
74 // vertexLight = UserRegister + offset + UnivReg(25) - VertexLightUnit(6)
75 #define VERTEX_LIGHT_UNIFORM(offset) nw_user_register_start[offset + 19]
76 
77 //@}
78 
79 #define _XYZW xyzw
80 #define _XYWZ xywz
81 #define _XYZ  xyz
82 #define _XY   xy
83 #define _X    x
84 #define _Y    y
85 #define _Z    z
86 #define _W    w
87 
88 //----------------------------------------
89 //! @name �R���X�^���g���W�X�^����
90 //@{
91 
92 //! @brief World Matrix �ł��B
93 //!
94 //! (Smooth or Rigid)Skinning �L��� ModelCoordinate = true �̏ꍇ�� model_to_world �ƂȂ�܂��B
95 //! ModelCoordinate = false �̏ꍇ�͒P�ʃ}�g���N�X�ɂȂ�܂��B
96 //! Skinning �����̏ꍇ�͒P�ʃ}�g���N�X�ɂȂ�܂��B
97 //!
98 #define nw_local_to_world_matrix        c0
99 
100 //! @brief Normal Matrix �ł��B
101 //!
102 //! (Smooth or Rigid)Skinning �L��� ModelCoordinate = true �̏ꍇ�� model_to_view �ƂȂ�܂��B
103 //! ModelCoordinate = false �̏ꍇ�� world_to_view �ɂȂ�܂��B
104 //! Skinning �����̏ꍇ�� model_to_view �ɂȂ�܂��B
105 //! ������ Matrix �ɂ� ViewMatrix ���������āu���܂��v�B
106 //!
107 #define nw_normal_matrix                c3
108 
109 #define nw_position_offset              c6
110 #define nw_attribute_scale0             c7 // ���_�A�@���A�^���W�F���g�A�J���[�̃X�P�[���l
111 #define nw_attribute_scale1             c8 // �e�N�X�`���O�`�Q�̃X�P�[���l�A�E�F�C�g�̃X�P�[���l
112 
113 #define nw_texture_coordinate           c10
114 #define nw_inverse_view_matrix          c11 // �L���[�u�}�b�s���O�̂Ƃ��ɂ̂݃r���[�}�g���N�X�̋t�s���i�[����Ă��܂��B
115 #define nw_texture_matrix0              c11
116 #define nw_texture_matrix1              c14
117 #define nw_texture_matrix2              c17
118 #define nw_texture_translate            c19
119 
120 #define nw_material_ambient             c20
121 #define nw_vertex_color_scale           c20._W // �A���r�G���g�J���[�̃��W�X�^�Ƌ��L���Ă���
122 #define nw_material_diffuse             c21
123 #define nw_hemi_sphere_ground           c22
124 #define nw_hemi_sphere_sky              c23
125 #define nw_hemi_sphere_direction        c24
126 #define nw_matrix_pallet                c25
127 
128 
129 // sincos �}�N�����g�������ꍇ�� c93-c95 ���g�p�����”\��������̂ŁAc86-c92 ���g���Ă��܂��B
130 
131 //! @brief Projection Matrix �ł��B
132 #define nw_projection_matrix            c86
133 
134 //! @brief ���_�ʒu�p�� View Matrix �ł��B
135 //!
136 //! �@�����ɂ͂��� View Matrix �͎g�p���Ă��܂���B
137 //!
138 #define nw_world_to_view_matrix         c90
139 
140 
141 
142 #define nw_is_smooth_skin               b1
143 #define nw_is_rigid_skin                b2
144 #define nw_is_hemi_sphere_lighting      b5
145 #define nw_is_hemi_sphere_occlusion     b6
146 #define nw_is_vertex_alpha_enable       b7
147 #define nw_is_bone_weight_enable        b8
148 #define nw_uv_mapping_position0         b9
149 #define nw_uv_mapping_position1         b10
150 #define nw_uv_mapping_position2         b11
151 #define nw_is_vertex_lighting           b12
152 #define nw_is_texture1_enabled          b13
153 #define nw_is_texture2_enabled          b14
154 #define nw_is_quaternion_enabled        b15
155 
156 // �萔
157 #define CONSTANT                        c93
158 
159 def     CONSTANT[0], 0.0, 1.0, 2.0, 3.0
160 def     CONSTANT[1], 0.125, 0.00390625, 0.5, 0.25
161 def     CONSTANT[2], 3.0, 4.0, 5.0, 6.0
162 
163 #define CONST_0                         CONSTANT[0].x
164 #define CONST_1                         CONSTANT[0].y
165 #define CONST_2                         CONSTANT[0].z
166 #define CONST_3                         CONSTANT[0].w
167 #define CONST_4                         CONSTANT[2].y
168 #define CONST_5                         CONSTANT[2].z
169 #define CONST_6                         CONSTANT[2].w
170 #define CONST_HALF                      CONSTANT[1].z
171 #define CONST_QUARTER                   CONSTANT[1].w
172 #define CONST_1__4                      CONSTANT[1].w
173 #define CONST_1__8                      CONSTANT[1].x
174 #define CONST_1__256                    CONSTANT[1].y
175 
176 #define CONST_0_0_0_0                   CONSTANT[0].xx
177 #define CONST_0_1_1_1                   CONSTANT[0].xy
178 #define CONST_0_0_0_1                   CONSTANT[0].xxxy
179 #define CONST_0_0_1_1                   CONSTANT[0].xxyy
180 #define CONST_0_2_2_2                   CONSTANT[0].xz
181 #define CONST_0_3_3_3                   CONSTANT[0].xw
182 #define CONST_1_0_0_0                   CONSTANT[0].yx
183 #define CONST_1_1_1_1                   CONSTANT[0].yy
184 #define CONST_1_2_2_2                   CONSTANT[0].yz
185 #define CONST_1_3_3_3                   CONSTANT[0].yw
186 #define CONST_3_4_4_4                   CONSTANT[2].xy
187 
188 //@}
189 
190 //----------------------------------------
191 //! @name �������W�X�^����
192 //@{
193 
194 #define nw_vertex_light_count           i0
195 
196 //@}
197 
198 //----------------------------------------
199 //! @name �W�����̓��W�X�^����
200 //@{
201 
202 #define nw_position                     v0
203 #define nw_normal                       v1
204 #define nw_tangent                      v2
205 #define nw_color                        v3
206 #define nw_texcoord0                    v4
207 #define nw_texcoord1                    v5
208 #define nw_texcoord2                    v6
209 #define nw_boneIndex                    v7
210 #define nw_boneWeight                   v8
211 #define nw_userAttribute0               v9
212 #define nw_userAttribute1               v10
213 #define nw_userAttribute2               v11
214 
215 //@}
216 
217 //----------------------------------------
218 //! @name �W���o�̓��W�X�^����
219 //@{
220 
221 #define o_Position                      o0
222 #define o_Quaternion                    o1
223 #define o_View                          o2
224 #define o_Color                         o3
225 #define o_TexCoord0                     o4
226 #define o_TexCoord1                     o5
227 #define o_TexCoord2                     o6
228 
229 //@}
230 
231 //----------------------------------------
232 //! @name �e���|�������W�X�^����
233 //@{
234 
235 // ���[�`�����ȂǂŌv�Z�p�Ɏg�����W�X�^
236 #define TEMP0               r0
237 #define TEMP1               r1
238 #define TEMP2               r2
239 #define TEMP3               r3
240 #define TEMP4               r4
241 #define TEMP5               r5
242 
243 #define TEMP6               r6
244 #define TEMP7               r7
245 #define TEMP8               r8
246 #define TEMP9               r9
247 
248 // �N�H�[�^�j�I���v�Z���[�`�����ł͏��������֎~
249 #define TEMP_QUAT           r0
250 
251 #define TRAN_TEX0           r3
252 #define TRAN_TEX1           r4
253 #define TRAN_TEX2           r5
254 
255 // ���[�`���̈����ȂǂɎg�����W�X�^
256 #define TEMP_COLO           r9
257 #define TEMP_STUS           r8
258 
259 #define TEMP_TEX            r6
260 #define TEMP_TEX0           r7
261 #define TEMP_TEX1           r8
262 #define TEMP_TEX2           r9
263 #define MODL_POSI           r7
264 //#define MODL_TANG           r8
265 //#define MODL_NORM           r9
266 
267 // �F�X�Q�Ƃ����”\���̂��郌�W�X�^
268 // ���C�e�B���O��e�N�X�`�����W�ł��g���̂ŏ㏑�����Ȃ��悤��
269 #define WRLD_POSI           r10
270 #define WRLD_TANG           r11
271 #define WRLD_NORM           r12
272 
273 // ���[�`���̈����Ƃ��Ă��g���A�F�X�Q�Ƃ����”\���̂��郌�W�X�^
274 // ���C�e�B���O��e�N�X�`�����W�ł��g���̂ŏ㏑�����Ȃ��悤��
275 #define TEMP_TANG           r13
276 #define TEMP_NORM           r14
277 #define TEMP_POSI           r15
278 #define TEMP_VIEW           r15 // ���ӁI TEMP_POSI �Ɠ������W�X�^�ł��B
279 
280 //@}
281 
282 #endif // NW_VERTEXSHADER_H_
283