1 |
|
---|
2 | /*
|
---|
3 | -----------------------------------------------------------------------------
|
---|
4 | This source file is part of OGRE
|
---|
5 | (Object-oriented Graphics Rendering Engine)
|
---|
6 | For the latest info, see http://www.ogre3d.org/
|
---|
7 |
|
---|
8 | Copyright (c) 2000-2005 The OGRE Team
|
---|
9 | Also see acknowledgements in Readme.html
|
---|
10 |
|
---|
11 | This program is free software; you can redistribute it and/or modify it under
|
---|
12 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
13 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
14 | version.
|
---|
15 |
|
---|
16 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
18 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
21 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
22 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
23 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
24 | -----------------------------------------------------------------------------
|
---|
25 | */
|
---|
26 |
|
---|
27 | #include "OgreBiTerrainVertexProgram.h"
|
---|
28 |
|
---|
29 | namespace Ogre {
|
---|
30 |
|
---|
31 | String BiTerrainVertexProgram::mNoFogArbvp1 =
|
---|
32 | "!!ARBvp1.0\n"
|
---|
33 | "PARAM c5 = { 1, 1, 1, 1 };\n"
|
---|
34 | "#var float4x4 worldViewProj : : c[0], 4 : 8 : 1\n"
|
---|
35 | "#var float morphFactor : : c[4] : 9 : 1\n"
|
---|
36 | "TEMP R0;\n"
|
---|
37 | "ATTRIB v17 = vertex.weight;\n"
|
---|
38 | "ATTRIB v25 = vertex.texcoord[1];\n"
|
---|
39 | "ATTRIB v24 = vertex.texcoord[0];\n"
|
---|
40 | "ATTRIB v16 = vertex.position;\n"
|
---|
41 | "PARAM c0[4] = { program.local[0..3] };\n"
|
---|
42 | "PARAM c4 = program.local[4];\n"
|
---|
43 | " MOV result.texcoord[0], v24;\n"
|
---|
44 | " MOV result.texcoord[1], v25;\n"
|
---|
45 | " MOV R0, v16;\n"
|
---|
46 | " MAD R0.y, v17.x, c4.x, R0.y;\n"
|
---|
47 | " DP4 result.position.x, c0[0], R0;\n"
|
---|
48 | " DP4 result.position.y, c0[1], R0;\n"
|
---|
49 | " DP4 result.position.z, c0[2], R0;\n"
|
---|
50 | " DP4 result.position.w, c0[3], R0;\n"
|
---|
51 | " MOV result.color.front.primary, c5.x;\n"
|
---|
52 | "END\n";
|
---|
53 |
|
---|
54 | String BiTerrainVertexProgram::mShadowReceiverArbvp1 =
|
---|
55 | "!!ARBvp1.0\n"
|
---|
56 | "PARAM c[14] = { program.local[0..12], { 1 } };\n"
|
---|
57 | "TEMP R0;\n"
|
---|
58 | "TEMP R1;\n"
|
---|
59 | "TEMP R2;\n"
|
---|
60 | "MOV result.color, c[13].x;\n"
|
---|
61 | "MUL R0.x, vertex.weight, c[12];\n"
|
---|
62 | "ADD R1.y, R0.x, vertex.position;\n"
|
---|
63 | "MOV R1.xzw, vertex.position;\n"
|
---|
64 | "DP4 result.position.w, R1, c[3];\n"
|
---|
65 | "DP4 result.position.z, R1, c[2];\n"
|
---|
66 | "DP4 R0.w, R1, c[7];\n"
|
---|
67 | "DP4 R0.z, R1, c[6];\n"
|
---|
68 | "DP4 R0.y, R1, c[5];\n"
|
---|
69 | "DP4 R0.x, R1, c[4];\n"
|
---|
70 | "DP4 result.position.y, R1, c[1];\n"
|
---|
71 | "DP4 R2.y, R0, c[9];\n"
|
---|
72 | "DP4 R2.z, R0, c[11];\n"
|
---|
73 | "DP4 R2.x, R0, c[8];\n"
|
---|
74 | "RCP R0.x, R2.z;\n"
|
---|
75 | "DP4 result.position.x, R1, c[0];\n"
|
---|
76 | "MUL result.texcoord[0].xy, R2, R0.x;\n"
|
---|
77 | "END\n";
|
---|
78 | String BiTerrainVertexProgram::mLinearFogArbvp1 =
|
---|
79 | "!!ARBvp1.0\n"
|
---|
80 | "PARAM c5 = { 1, 1, 1, 1 };\n"
|
---|
81 | "#var float4x4 worldViewProj : : c[0], 4 : 9 : 1\n"
|
---|
82 | "#var float morphFactor : : c[4] : 10 : 1\n"
|
---|
83 | "TEMP R0, R1;\n"
|
---|
84 | "ATTRIB v17 = vertex.weight;\n"
|
---|
85 | "ATTRIB v25 = vertex.texcoord[1];\n"
|
---|
86 | "ATTRIB v24 = vertex.texcoord[0];\n"
|
---|
87 | "ATTRIB v16 = vertex.position;\n"
|
---|
88 | "PARAM c0[4] = { program.local[0..3] };\n"
|
---|
89 | "PARAM c4 = program.local[4];\n"
|
---|
90 | " MOV result.texcoord[0], v24;\n"
|
---|
91 | " MOV result.texcoord[1], v25;\n"
|
---|
92 | " MOV R1, v16;\n"
|
---|
93 | " MAD R1.y, v17.x, c4.x, R1.y;\n"
|
---|
94 | " DP4 R0.x, c0[0], R1;\n"
|
---|
95 | " DP4 R0.y, c0[1], R1;\n"
|
---|
96 | " DP4 R0.z, c0[2], R1;\n"
|
---|
97 | " DP4 R0.w, c0[3], R1;\n"
|
---|
98 | " MOV result.fogcoord.x, R0.z;\n"
|
---|
99 | " MOV result.position, R0;\n"
|
---|
100 | " MOV result.color.front.primary, c5.x;\n"
|
---|
101 | "END\n";
|
---|
102 | String BiTerrainVertexProgram::mExpFogArbvp1 =
|
---|
103 | "!!ARBvp1.0\n"
|
---|
104 | "PARAM c6 = { 1, 1, 1, 1 };\n"
|
---|
105 | "PARAM c7 = { 2.71828, 0, 0, 0 };\n"
|
---|
106 | "#var float4x4 worldViewProj : : c[0], 4 : 9 : 1\n"
|
---|
107 | "#var float morphFactor : : c[4] : 10 : 1\n"
|
---|
108 | "#var float fogDensity : : c[5] : 11 : 1\n"
|
---|
109 | "TEMP R0, R1;\n"
|
---|
110 | "ATTRIB v17 = vertex.weight;\n"
|
---|
111 | "ATTRIB v25 = vertex.texcoord[1];\n"
|
---|
112 | "ATTRIB v24 = vertex.texcoord[0];\n"
|
---|
113 | "ATTRIB v16 = vertex.position;\n"
|
---|
114 | "PARAM c5 = program.local[5];\n"
|
---|
115 | "PARAM c0[4] = { program.local[0..3] };\n"
|
---|
116 | "PARAM c4 = program.local[4];\n"
|
---|
117 | " MOV result.texcoord[0], v24;\n"
|
---|
118 | " MOV result.texcoord[1], v25;\n"
|
---|
119 | " MOV R1, v16;\n"
|
---|
120 | " MAD R1.y, v17.x, c4.x, R1.y;\n"
|
---|
121 | " DP4 R0.x, c0[0], R1;\n"
|
---|
122 | " DP4 R0.y, c0[1], R1;\n"
|
---|
123 | " DP4 R0.z, c0[2], R1;\n"
|
---|
124 | " DP4 R0.w, c0[3], R1;\n"
|
---|
125 | " MOV result.position, R0;\n"
|
---|
126 | " MOV result.color.front.primary, c6.x;\n"
|
---|
127 | " MUL R0.zw, R0.z, c5.x;\n"
|
---|
128 | " MOV R0.xy, c7.x;\n"
|
---|
129 | " LIT R0.z, R0;\n"
|
---|
130 | " RCP result.fogcoord.x, R0.z;\n"
|
---|
131 | "END\n";
|
---|
132 | String BiTerrainVertexProgram::mExp2FogArbvp1 =
|
---|
133 | "!!ARBvp1.0\n"
|
---|
134 | "PARAM c6 = { 1, 1, 1, 1 };\n"
|
---|
135 | "PARAM c7 = { 0.002, 2.71828, 0, 0 };\n"
|
---|
136 | "#var float4x4 worldViewProj : : c[0], 4 : 9 : 1\n"
|
---|
137 | "#var float morphFactor : : c[4] : 10 : 1\n"
|
---|
138 | "#var float fogDensity : : c[5] : 11 : 1\n"
|
---|
139 | "TEMP R0, R1;\n"
|
---|
140 | "ATTRIB v17 = vertex.weight;\n"
|
---|
141 | "ATTRIB v25 = vertex.texcoord[1];\n"
|
---|
142 | "ATTRIB v24 = vertex.texcoord[0];\n"
|
---|
143 | "ATTRIB v16 = vertex.position;\n"
|
---|
144 | "PARAM c0[4] = { program.local[0..3] };\n"
|
---|
145 | "PARAM c4 = program.local[4];\n"
|
---|
146 | " MOV result.texcoord[0], v24;\n"
|
---|
147 | " MOV result.texcoord[1], v25;\n"
|
---|
148 | " MOV R1, v16;\n"
|
---|
149 | " MAD R1.y, v17.x, c4.x, R1.y;\n"
|
---|
150 | " DP4 R0.x, c0[0], R1;\n"
|
---|
151 | " DP4 R0.y, c0[1], R1;\n"
|
---|
152 | " DP4 R0.z, c0[2], R1;\n"
|
---|
153 | " DP4 R0.w, c0[3], R1;\n"
|
---|
154 | " MOV result.position, R0;\n"
|
---|
155 | " MOV result.color.front.primary, c6.x;\n"
|
---|
156 | " MUL R0.x, R0.z, c7.x;\n"
|
---|
157 | " MUL R0.zw, R0.x, R0.x;\n"
|
---|
158 | " MOV R0.xy, c7.y;\n"
|
---|
159 | " LIT R0.z, R0;\n"
|
---|
160 | " RCP result.fogcoord.x, R0.z;\n"
|
---|
161 | "END\n";
|
---|
162 |
|
---|
163 | String BiTerrainVertexProgram::mNoFogVs_1_1 =
|
---|
164 | "vs_1_1\n"
|
---|
165 | "def c5, 1, 1, 1, 1\n"
|
---|
166 | "//var float4x4 worldViewProj : : c[0], 4 : 8 : 1\n"
|
---|
167 | "//var float morphFactor : : c[4] : 9 : 1\n"
|
---|
168 | "dcl_blendweight v1\n"
|
---|
169 | "dcl_texcoord1 v8\n"
|
---|
170 | "dcl_texcoord0 v7\n"
|
---|
171 | "dcl_position v0\n"
|
---|
172 | " mov oT0.xy, v7\n"
|
---|
173 | " mov oT1.xy, v8\n"
|
---|
174 | " mov r0, v0\n"
|
---|
175 | " mad r0.y, v1.x, c4.x, r0.y\n"
|
---|
176 | " dp4 oPos.x, c0, r0\n"
|
---|
177 | " dp4 oPos.y, c1, r0\n"
|
---|
178 | " dp4 oPos.z, c2, r0\n"
|
---|
179 | " dp4 oPos.w, c3, r0\n"
|
---|
180 | " mov oD0, c5.x\n";
|
---|
181 | String BiTerrainVertexProgram::mLinearFogVs_1_1 =
|
---|
182 | "vs_1_1\n"
|
---|
183 | "def c5, 1, 1, 1, 1\n"
|
---|
184 | "//var float4x4 worldViewProj : : c[0], 4 : 9 : 1\n"
|
---|
185 | "//var float morphFactor : : c[4] : 10 : 1\n"
|
---|
186 | "dcl_blendweight v1\n"
|
---|
187 | "dcl_texcoord1 v8\n"
|
---|
188 | "dcl_texcoord0 v7\n"
|
---|
189 | "dcl_position v0\n"
|
---|
190 | " mov oT0.xy, v7\n"
|
---|
191 | " mov oT1.xy, v8\n"
|
---|
192 | " mov r1, v0\n"
|
---|
193 | " mad r1.y, v1.x, c4.x, r1.y\n"
|
---|
194 | " dp4 r0.x, c0, r1\n"
|
---|
195 | " dp4 r0.y, c1, r1\n"
|
---|
196 | " dp4 r0.z, c2, r1\n"
|
---|
197 | " dp4 r0.w, c3, r1\n"
|
---|
198 | " mov oFog, r0.z\n"
|
---|
199 | " mov oPos, r0\n"
|
---|
200 | " mov oD0, c5.x\n";
|
---|
201 |
|
---|
202 | String BiTerrainVertexProgram::mShadowReceiverVs_1_1 =
|
---|
203 | "vs_1_1\n"
|
---|
204 | "def c13, 1, 1, 1, 1\n"
|
---|
205 | "dcl_blendweight v1\n"
|
---|
206 | "dcl_texcoord1 v8\n"
|
---|
207 | "dcl_texcoord0 v7\n"
|
---|
208 | "dcl_position v0\n"
|
---|
209 | "mov r1, v0\n"
|
---|
210 | "mad r1.y, v1.x, c12.x, r1.y\n"
|
---|
211 | "dp4 oPos.x, c0, r1\n"
|
---|
212 | "dp4 oPos.y, c1, r1\n"
|
---|
213 | "dp4 oPos.z, c2, r1\n"
|
---|
214 | "dp4 oPos.w, c3, r1\n"
|
---|
215 | "dp4 r0.x, c4, r1\n"
|
---|
216 | "dp4 r0.y, c5, r1\n"
|
---|
217 | "dp4 r0.z, c6, r1\n"
|
---|
218 | "dp4 r0.w, c7, r1\n"
|
---|
219 | "dp4 r1.x, c8, r0\n"
|
---|
220 | "dp4 r1.y, c9, r0\n"
|
---|
221 | "dp4 r1.w, c11, r0\n"
|
---|
222 | "rcp r0.x, r1.w\n"
|
---|
223 | "mul oT0.xy, r1.xy, r0.x\n"
|
---|
224 | "mov oD0, c13\n";
|
---|
225 | String BiTerrainVertexProgram::mExpFogVs_1_1 =
|
---|
226 | "vs_1_1\n"
|
---|
227 | "def c6, 1, 1, 1, 1\n"
|
---|
228 | "def c7, 2.71828, 0, 0, 0\n"
|
---|
229 | "//var float4x4 worldViewProj : : c[0], 4 : 9 : 1\n"
|
---|
230 | "//var float morphFactor : : c[4] : 10 : 1\n"
|
---|
231 | "//var float fogDensity : : c[5] : 11 : 1\n"
|
---|
232 | "dcl_blendweight v1\n"
|
---|
233 | "dcl_texcoord1 v8\n"
|
---|
234 | "dcl_texcoord0 v7\n"
|
---|
235 | "dcl_position v0\n"
|
---|
236 | " mov oT0.xy, v7\n"
|
---|
237 | " mov oT1.xy, v8\n"
|
---|
238 | " mov r1, v0\n"
|
---|
239 | " mad r1.y, v1.x, c4.x, r1.y\n"
|
---|
240 | " dp4 r0.x, c0, r1\n"
|
---|
241 | " dp4 r0.y, c1, r1\n"
|
---|
242 | " dp4 r0.z, c2, r1\n"
|
---|
243 | " dp4 r0.w, c3, r1\n"
|
---|
244 | " mov oPos, r0\n"
|
---|
245 | " mov oD0, c6.x\n"
|
---|
246 | " mul r0.zw, r0.z, c5.x\n"
|
---|
247 | " mov r0.xy, c7.x\n"
|
---|
248 | " lit r0.z, r0\n"
|
---|
249 | " rcp oFog, r0.z\n";
|
---|
250 | String BiTerrainVertexProgram::mExp2FogVs_1_1 =
|
---|
251 | "vs_1_1\n"
|
---|
252 | "def c6, 1, 1, 1, 1\n"
|
---|
253 | "def c7, 0.002, 2.71828, 0, 0\n"
|
---|
254 | "//var float4x4 worldViewProj : : c[0], 4 : 9 : 1\n"
|
---|
255 | "//var float morphFactor : : c[4] : 10 : 1\n"
|
---|
256 | "//var float fogDensity : : c[5] : 11 : 1\n"
|
---|
257 | "dcl_blendweight v1\n"
|
---|
258 | "dcl_texcoord1 v8\n"
|
---|
259 | "dcl_texcoord0 v7\n"
|
---|
260 | "dcl_position v0\n"
|
---|
261 | " mov oT0.xy, v7\n"
|
---|
262 | " mov oT1.xy, v8\n"
|
---|
263 | " mov r1, v0\n"
|
---|
264 | " mad r1.y, v1.x, c4.x, r1.y\n"
|
---|
265 | " dp4 r0.x, c0, r1\n"
|
---|
266 | " dp4 r0.y, c1, r1\n"
|
---|
267 | " dp4 r0.z, c2, r1\n"
|
---|
268 | " dp4 r0.w, c3, r1\n"
|
---|
269 | " mov oPos, r0\n"
|
---|
270 | " mov oD0, c6.x\n"
|
---|
271 | " mul r0.x, r0.z, c7.x\n"
|
---|
272 | " mul r0.zw, r0.x, r0.x\n"
|
---|
273 | " mov r0.xy, c7.y\n"
|
---|
274 | " lit r0.z, r0\n"
|
---|
275 | " rcp oFog, r0.z\n";
|
---|
276 |
|
---|
277 | const String& BiTerrainVertexProgram::getProgramSource(
|
---|
278 | FogMode fogMode, const String syntax, bool shadowReceiver)
|
---|
279 | {
|
---|
280 | if (shadowReceiver)
|
---|
281 | {
|
---|
282 | if (syntax == "arbvp1")
|
---|
283 | {
|
---|
284 | return mShadowReceiverArbvp1;
|
---|
285 | }
|
---|
286 | else
|
---|
287 | {
|
---|
288 | return mShadowReceiverVs_1_1;
|
---|
289 | }
|
---|
290 | }
|
---|
291 | else
|
---|
292 | {
|
---|
293 |
|
---|
294 | switch(fogMode)
|
---|
295 | {
|
---|
296 | case FOG_NONE:
|
---|
297 | if (syntax == "arbvp1")
|
---|
298 | {
|
---|
299 | return mNoFogArbvp1;
|
---|
300 | }
|
---|
301 | else
|
---|
302 | {
|
---|
303 | return mNoFogVs_1_1;
|
---|
304 | }
|
---|
305 | break;
|
---|
306 | case FOG_LINEAR:
|
---|
307 | if (syntax == "arbvp1")
|
---|
308 | {
|
---|
309 | return mLinearFogArbvp1;
|
---|
310 | }
|
---|
311 | else
|
---|
312 | {
|
---|
313 | return mLinearFogVs_1_1;
|
---|
314 | }
|
---|
315 | break;
|
---|
316 | case FOG_EXP:
|
---|
317 | if (syntax == "arbvp1")
|
---|
318 | {
|
---|
319 | return mExpFogArbvp1;
|
---|
320 | }
|
---|
321 | else
|
---|
322 | {
|
---|
323 | return mExpFogVs_1_1;
|
---|
324 | }
|
---|
325 | break;
|
---|
326 | case FOG_EXP2:
|
---|
327 | if (syntax == "arbvp1")
|
---|
328 | {
|
---|
329 | return mExp2FogArbvp1;
|
---|
330 | }
|
---|
331 | else
|
---|
332 | {
|
---|
333 | return mExp2FogVs_1_1;
|
---|
334 | }
|
---|
335 | break;
|
---|
336 | };
|
---|
337 | }
|
---|
338 | // default
|
---|
339 | return StringUtil::BLANK;
|
---|
340 |
|
---|
341 | }
|
---|
342 | }
|
---|