1 // ---------------------------------------------------------------------------
2 //  Project:  NintendoWare
3 //  File:     VertexShader.h
4 //
5 //  Copyright (C)2009-2010 Nintendo Co., Ltd.  All rights reserved.
6 //
7 //  These coded instructions, statements, and computer programs contain
8 //  proprietary information of Nintendo of America Inc. and/or Nintendo
9 //  Company Ltd., and are protected by Federal copyright law.  They may
10 //  not be disclosed to third parties or copied or duplicated in any form,
11 //  in whole or in part, without the prior written consent of Nintendo.
12 //
13 //  $Revision: 22355 $
14 // ---------------------------------------------------------------------------
15 
16 #ifndef NW_VERTEXSHADER_H_
17 #define NW_VERTEXSHADER_H_
18 
19 //-----------------------------------------------------------------------------
20 // UNDONE: �����W�X�^�̃}�N�����̖����K���́A���ꂳ���\��ł��B
21 //-----------------------------------------------------------------------------
22 
23 //----------------------------------------
24 //! @name ��r�֘A
25 //@{
26 
27 #define EQ                  0
28 #define NEQ                 1
29 #define LESS                2
30 #define LEQ                 3
31 #define GT                  4
32 #define GEQ                 5
33 
34 //@}
35 
36 //----------------------------------------
37 //! @name �R���f�B�V�����֘A
38 //@{
39 
40 #define COND_MODE_OR        0
41 #define COND_MODE_AND       1
42 #define COND_MODE_STA0      2
43 #define COND_MODE_STA1      3
44 
45 //@}
46 
47 
48 //----------------------------------------
49 //! @name �X�e�[�^�X���W�X�^�֘A
50 //@{
51 
52 #define STAT0_0             0
53 #define STAT0_1             1
54 #define STAT1_0             0
55 #define STAT1_1             1
56 
57 //@}
58 
59 //----------------------------------------
60 //! @name ���_���C�g�֘A
61 //@{
62 
63 #define VERTEX_LIGHT_AMBIENT                0
64 #define VERTEX_LIGHT_DIFFUSE                1
65 #define VERTEX_LIGHT_POSITION               2
66 #define VERTEX_LIGHT_SPOT_DIRECTION         3
67 #define VERTEX_LIGHT_DISTANCE_ATTENUATION   4
68 #define VERTEX_LIGHT_SPOT_FACTOR            5
69 
70 // ���_���C�g�̃��j�t�H�[���ł��B
71 // ���j�o�[�T�����W�X�^�̊��蓖�Ă��ύX���ꂽ�ꍇ�͕K���C�����Ă��������B
72 // vertexLight = UserRegister + offset + UnivReg(25) - VertexLightUnit(6)
73 #define VERTEX_LIGHT_UNIFORM(offset) nw_user_register_start[offset + 19]
74 
75 //@}
76 
77 #define _XYZW xyzw
78 #define _XYWZ xywz
79 #define _XYZ  xyz
80 #define _XY   xy
81 #define _X    x
82 #define _Y    y
83 #define _Z    z
84 #define _W    w
85 
86 //----------------------------------------
87 //! @name �R���X�^���g���W�X�^����
88 //@{
89 
90 //! @brief World Matrix �ł��B
91 //!
92 //! (Smooth or Rigid)Skinning �L��� ModelCoordinate = true �̏ꍇ�� model_to_world �ƂȂ�܂��B
93 //! ModelCoordinate = false �̏ꍇ�͒P�ʃ}�g���N�X�ɂȂ�܂��B
94 //! Skinning �����̏ꍇ�͒P�ʃ}�g���N�X�ɂȂ�܂��B
95 //!
96 #define nw_local_to_world_matrix        c0
97 
98 //! @brief Normal Matrix �ł��B
99 //!
100 //! (Smooth or Rigid)Skinning �L��� ModelCoordinate = true �̏ꍇ�� model_to_view �ƂȂ�܂��B
101 //! ModelCoordinate = false �̏ꍇ�� world_to_view �ɂȂ�܂��B
102 //! Skinning �����̏ꍇ�� model_to_view �ɂȂ�܂��B
103 //! ������ Matrix �ɂ� ViewMatrix ���������āu���܂��v�B
104 //!
105 #define nw_normal_matrix                c3
106 
107 #define nw_position_offset              c6
108 #define nw_attribute_scale0             c7 // ���_�A�@���A�^���W�F���g�A�J���[�̃X�P�[���l
109 #define nw_attribute_scale1             c8 // �e�N�X�`���O�`�Q�̃X�P�[���l
110 #define nw_attribute_scale2             c9 // �{�[���C���f�b�N�X�A�E�F�C�g�̃X�P�[���l�A�}�g���N�X�p���b�g��
111 
112 #define nw_texture_coordinate           c10
113 #define nw_inverse_view_matrix          c11 // �L���[�u�}�b�s���O�̂Ƃ��ɂ̂݃r���[�}�g���N�X�̋t�s���i�[����Ă��܂��B
114 #define nw_texture_matrix0              c11
115 #define nw_texture_matrix1              c14
116 #define nw_texture_matrix2              c17
117 #define nw_texture_translate            c19
118 
119 #define nw_material_ambient             c20
120 #define nw_vertex_color_scale           c20._W // �A���r�G���g�J���[�̃��W�X�^�Ƌ��L���Ă���
121 #define nw_material_diffuse             c21
122 #define nw_hemi_sphere_ground           c22
123 #define nw_hemi_sphere_sky              c23
124 #define nw_hemi_sphere_direction        c24
125 #define nw_matrix_pallet                c25
126 
127 
128 // sincos �}�N�����g�������ꍇ�� c93-c95 ���g�p�����”\��������̂ŁAc86-c92 ���g���Ă��܂��B
129 
130 //! @brief Projection Matrix �ł��B
131 #define nw_projection_matrix            c86
132 
133 //! @brief ���_�ʒu�p�� View Matrix �ł��B
134 //!
135 //! �@�����ɂ͂��� View Matrix �͎g�p���Ă��܂���B
136 //!
137 #define nw_world_to_view_matrix         c90
138 
139 
140 
141 #define nw_is_smooth_skin               b1
142 #define nw_is_rigid_skin                b2
143 #define nw_is_use_normal_matrix         b4
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