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: 22262 $
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_uniform_scale             b3
144 #define nw_is_use_normal_matrix         b4
145 #define nw_is_hemi_sphere_lighting      b5
146 #define nw_is_hemi_sphere_occlusion     b6
147 #define nw_is_vertex_alpha_enable       b7
148 #define nw_is_bone_weight_enable        b8
149 #define nw_uv_mapping_position0         b9
150 #define nw_uv_mapping_position1         b10
151 #define nw_uv_mapping_position2         b11
152 #define nw_is_vertex_lighting           b12
153 #define nw_is_texture1_enabled          b13
154 #define nw_is_texture2_enabled          b14
155 #define nw_is_quaternion_enabled        b15
156 
157 // �萔
158 #define CONSTANT                        c93
159 
160 def     CONSTANT[0], 0.0, 1.0, 2.0, 3.0
161 def     CONSTANT[1], 0.125, 0.00390625, 0.5, 0.25
162 def     CONSTANT[2], 3.0, 4.0, 5.0, 6.0
163 
164 #define CONST_0                         CONSTANT[0].x
165 #define CONST_1                         CONSTANT[0].y
166 #define CONST_2                         CONSTANT[0].z
167 #define CONST_3                         CONSTANT[0].w
168 #define CONST_4                         CONSTANT[2].y
169 #define CONST_5                         CONSTANT[2].z
170 #define CONST_6                         CONSTANT[2].w
171 #define CONST_HALF                      CONSTANT[1].z
172 #define CONST_QUARTER                   CONSTANT[1].w
173 #define CONST_1__4                      CONSTANT[1].w
174 #define CONST_1__8                      CONSTANT[1].x
175 #define CONST_1__256                    CONSTANT[1].y
176 
177 #define CONST_0_0_0_0                   CONSTANT[0].xx
178 #define CONST_0_1_1_1                   CONSTANT[0].xy
179 #define CONST_0_0_0_1                   CONSTANT[0].xxxy
180 #define CONST_0_0_1_1                   CONSTANT[0].xxyy
181 #define CONST_0_2_2_2                   CONSTANT[0].xz
182 #define CONST_0_3_3_3                   CONSTANT[0].xw
183 #define CONST_1_0_0_0                   CONSTANT[0].yx
184 #define CONST_1_1_1_1                   CONSTANT[0].yy
185 #define CONST_1_2_2_2                   CONSTANT[0].yz
186 #define CONST_1_3_3_3                   CONSTANT[0].yw
187 #define CONST_3_4_4_4                   CONSTANT[2].xy
188 
189 //@}
190 
191 //----------------------------------------
192 //! @name �������W�X�^����
193 //@{
194 
195 #define nw_vertex_light_count           i0
196 
197 //@}
198 
199 //----------------------------------------
200 //! @name �W�����̓��W�X�^����
201 //@{
202 
203 #define nw_position                     v0
204 #define nw_normal                       v1
205 #define nw_tangent                      v2
206 #define nw_color                        v3
207 #define nw_texcoord0                    v4
208 #define nw_texcoord1                    v5
209 #define nw_texcoord2                    v6
210 #define nw_boneIndex                    v7
211 #define nw_boneWeight                   v8
212 #define nw_userAttribute0               v9
213 #define nw_userAttribute1               v10
214 #define nw_userAttribute2               v11
215 
216 //@}
217 
218 //----------------------------------------
219 //! @name �W���o�̓��W�X�^����
220 //@{
221 
222 #define o_Position                      o0
223 #define o_Quaternion                    o1
224 #define o_View                          o2
225 #define o_Color                         o3
226 #define o_TexCoord0                     o4
227 #define o_TexCoord1                     o5
228 #define o_TexCoord2                     o6
229 
230 //@}
231 
232 //----------------------------------------
233 //! @name �e���|�������W�X�^����
234 //@{
235 
236 // ���[�`�����ȂǂŌv�Z�p�Ɏg�����W�X�^
237 #define TEMP0               r0
238 #define TEMP1               r1
239 #define TEMP2               r2
240 #define TEMP3               r3
241 #define TEMP4               r4
242 #define TEMP5               r5
243 
244 #define TEMP6               r6
245 #define TEMP7               r7
246 #define TEMP8               r8
247 #define TEMP9               r9
248 
249 // �N�H�[�^�j�I���v�Z���[�`�����ł͏��������֎~
250 #define TEMP_QUAT           r0
251 
252 #define TRAN_TEX0           r3
253 #define TRAN_TEX1           r4
254 #define TRAN_TEX2           r5
255 
256 // ���[�`���̈����ȂǂɎg�����W�X�^
257 #define TEMP_COLO           r9
258 #define TEMP_STUS           r8
259 
260 #define TEMP_TEX            r6
261 #define TEMP_TEX0           r7
262 #define TEMP_TEX1           r8
263 #define TEMP_TEX2           r9
264 #define MODL_POSI           r7
265 //#define MODL_TANG           r8
266 //#define MODL_NORM           r9
267 
268 // �F�X�Q�Ƃ����”\���̂��郌�W�X�^
269 // ���C�e�B���O��e�N�X�`�����W�ł��g���̂ŏ㏑�����Ȃ��悤��
270 #define WRLD_POSI           r10
271 #define WRLD_TANG           r11
272 #define WRLD_NORM           r12
273 
274 // ���[�`���̈����Ƃ��Ă��g���A�F�X�Q�Ƃ����”\���̂��郌�W�X�^
275 // ���C�e�B���O��e�N�X�`�����W�ł��g���̂ŏ㏑�����Ȃ��悤��
276 #define TEMP_TANG           r13
277 #define TEMP_NORM           r14
278 #define TEMP_POSI           r15
279 #define TEMP_VIEW           r15 // ���ӁI TEMP_POSI �Ɠ������W�X�^�ł��B
280 
281 //@}
282 
283 #endif // NW_VERTEXSHADER_H_
284