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: 27904 $
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�A�E�F�C�g�̃X�P�[���l
110 
111 #define nw_texture_coordinate           c10
112 #define nw_inverse_view_matrix          c11 // �L���[�u�}�b�s���O�̂Ƃ��ɂ̂݃r���[�}�g���N�X�̋t�s���i�[����Ă��܂��B
113 #define nw_texture_matrix0              c11
114 #define nw_texture_matrix1              c14
115 #define nw_texture_matrix2              c17
116 #define nw_texture_translate            c19
117 
118 #define nw_material_ambient             c20
119 #define nw_vertex_color_scale           c20._W // �A���r�G���g�J���[�̃��W�X�^�Ƌ��L���Ă���
120 #define nw_material_diffuse             c21
121 #define nw_hemi_sphere_ground           c22
122 #define nw_hemi_sphere_sky              c23
123 #define nw_hemi_sphere_direction        c24
124 #define nw_matrix_pallet                c25
125 
126 
127 // sincos �}�N�����g�������ꍇ�� c93-c95 ���g�p�����”\��������̂ŁAc86-c92 ���g���Ă��܂��B
128 
129 //! @brief Projection Matrix �ł��B
130 #define nw_projection_matrix            c86
131 
132 //! @brief ���_�ʒu�p�� View Matrix �ł��B
133 //!
134 //! �@�����ɂ͂��� View Matrix �͎g�p���Ă��܂���B
135 //!
136 #define nw_world_to_view_matrix         c90
137 
138 
139 
140 #define nw_is_smooth_skin               b1
141 #define nw_is_rigid_skin                b2
142 #define nw_is_hemi_sphere_lighting      b5
143 #define nw_is_hemi_sphere_occlusion     b6
144 #define nw_is_vertex_alpha_enable       b7
145 #define nw_is_bone_weight_enable        b8
146 #define nw_uv_mapping_position0         b9
147 #define nw_uv_mapping_position1         b10
148 #define nw_uv_mapping_position2         b11
149 #define nw_is_vertex_lighting           b12
150 #define nw_is_texture1_enabled          b13
151 #define nw_is_texture2_enabled          b14
152 #define nw_is_quaternion_enabled        b15
153 
154 // �萔
155 #define CONSTANT                        c93
156 
157 def     CONSTANT[0], 0.0, 1.0, 2.0, 3.0
158 def     CONSTANT[1], 0.125, 0.00390625, 0.5, 0.25
159 def     CONSTANT[2], 3.0, 4.0, 5.0, 6.0
160 
161 #define CONST_0                         CONSTANT[0].x
162 #define CONST_1                         CONSTANT[0].y
163 #define CONST_2                         CONSTANT[0].z
164 #define CONST_3                         CONSTANT[0].w
165 #define CONST_4                         CONSTANT[2].y
166 #define CONST_5                         CONSTANT[2].z
167 #define CONST_6                         CONSTANT[2].w
168 #define CONST_HALF                      CONSTANT[1].z
169 #define CONST_QUARTER                   CONSTANT[1].w
170 #define CONST_1__4                      CONSTANT[1].w
171 #define CONST_1__8                      CONSTANT[1].x
172 #define CONST_1__256                    CONSTANT[1].y
173 
174 #define CONST_0_0_0_0                   CONSTANT[0].xx
175 #define CONST_0_1_1_1                   CONSTANT[0].xy
176 #define CONST_0_0_0_1                   CONSTANT[0].xxxy
177 #define CONST_0_0_1_1                   CONSTANT[0].xxyy
178 #define CONST_0_2_2_2                   CONSTANT[0].xz
179 #define CONST_0_3_3_3                   CONSTANT[0].xw
180 #define CONST_1_0_0_0                   CONSTANT[0].yx
181 #define CONST_1_1_1_1                   CONSTANT[0].yy
182 #define CONST_1_2_2_2                   CONSTANT[0].yz
183 #define CONST_1_3_3_3                   CONSTANT[0].yw
184 #define CONST_3_4_4_4                   CONSTANT[2].xy
185 
186 //@}
187 
188 //----------------------------------------
189 //! @name �������W�X�^����
190 //@{
191 
192 #define nw_vertex_light_count           i0
193 
194 //@}
195 
196 //----------------------------------------
197 //! @name �W�����̓��W�X�^����
198 //@{
199 
200 #define nw_position                     v0
201 #define nw_normal                       v1
202 #define nw_tangent                      v2
203 #define nw_color                        v3
204 #define nw_texcoord0                    v4
205 #define nw_texcoord1                    v5
206 #define nw_texcoord2                    v6
207 #define nw_boneIndex                    v7
208 #define nw_boneWeight                   v8
209 #define nw_userAttribute0               v9
210 #define nw_userAttribute1               v10
211 #define nw_userAttribute2               v11
212 
213 //@}
214 
215 //----------------------------------------
216 //! @name �W���o�̓��W�X�^����
217 //@{
218 
219 #define o_Position                      o0
220 #define o_Quaternion                    o1
221 #define o_View                          o2
222 #define o_Color                         o3
223 #define o_TexCoord0                     o4
224 #define o_TexCoord1                     o5
225 #define o_TexCoord2                     o6
226 
227 //@}
228 
229 //----------------------------------------
230 //! @name �e���|�������W�X�^����
231 //@{
232 
233 // ���[�`�����ȂǂŌv�Z�p�Ɏg�����W�X�^
234 #define TEMP0               r0
235 #define TEMP1               r1
236 #define TEMP2               r2
237 #define TEMP3               r3
238 #define TEMP4               r4
239 #define TEMP5               r5
240 
241 #define TEMP6               r6
242 #define TEMP7               r7
243 #define TEMP8               r8
244 #define TEMP9               r9
245 
246 // �N�H�[�^�j�I���v�Z���[�`�����ł͏��������֎~
247 #define TEMP_QUAT           r0
248 
249 #define TRAN_TEX0           r3
250 #define TRAN_TEX1           r4
251 #define TRAN_TEX2           r5
252 
253 // ���[�`���̈����ȂǂɎg�����W�X�^
254 #define TEMP_COLO           r9
255 #define TEMP_STUS           r8
256 
257 #define TEMP_TEX            r6
258 #define TEMP_TEX0           r7
259 #define TEMP_TEX1           r8
260 #define TEMP_TEX2           r9
261 #define MODL_POSI           r7
262 //#define MODL_TANG           r8
263 //#define MODL_NORM           r9
264 
265 // �F�X�Q�Ƃ����”\���̂��郌�W�X�^
266 // ���C�e�B���O��e�N�X�`�����W�ł��g���̂ŏ㏑�����Ȃ��悤��
267 #define WRLD_POSI           r10
268 #define WRLD_TANG           r11
269 #define WRLD_NORM           r12
270 
271 // ���[�`���̈����Ƃ��Ă��g���A�F�X�Q�Ƃ����”\���̂��郌�W�X�^
272 // ���C�e�B���O��e�N�X�`�����W�ł��g���̂ŏ㏑�����Ȃ��悤��
273 #define TEMP_TANG           r13
274 #define TEMP_NORM           r14
275 #define TEMP_POSI           r15
276 #define TEMP_VIEW           r15 // ���ӁI TEMP_POSI �Ɠ������W�X�^�ł��B
277 
278 //@}
279 
280 #endif // NW_VERTEXSHADER_H_
281