diff options
author | David Walter Seikel | 2014-01-13 19:47:58 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-01-13 19:47:58 +1000 |
commit | f9158592e1478b2013afc7041d9ed041cf2d2f4a (patch) | |
tree | b16e389d7988700e21b4c9741044cefa536dcbae /libraries/irrlicht-1.8/source/Irrlicht/CTRNormalMap.cpp | |
parent | Libraries readme updated with change markers and more of the Irrlicht changes. (diff) | |
download | SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.zip SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.gz SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.bz2 SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.xz |
Update Irrlicht to 1.8.1. Include actual change markers this time. lol
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CTRNormalMap.cpp | 848 |
1 files changed, 0 insertions, 848 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CTRNormalMap.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CTRNormalMap.cpp deleted file mode 100644 index a3d3f2b..0000000 --- a/libraries/irrlicht-1.8/source/Irrlicht/CTRNormalMap.cpp +++ /dev/null | |||
@@ -1,848 +0,0 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten | ||
2 | // This file is part of the "Irrlicht Engine". | ||
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | ||
4 | |||
5 | #include "IrrCompileConfig.h" | ||
6 | #include "IBurningShader.h" | ||
7 | |||
8 | #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ | ||
9 | |||
10 | // compile flag for this file | ||
11 | #undef USE_ZBUFFER | ||
12 | #undef IPOL_Z | ||
13 | #undef CMP_Z | ||
14 | #undef WRITE_Z | ||
15 | |||
16 | #undef IPOL_W | ||
17 | #undef CMP_W | ||
18 | #undef WRITE_W | ||
19 | |||
20 | #undef SUBTEXEL | ||
21 | #undef INVERSE_W | ||
22 | |||
23 | #undef IPOL_C0 | ||
24 | #undef IPOL_T0 | ||
25 | #undef IPOL_T1 | ||
26 | #undef IPOL_T2 | ||
27 | #undef IPOL_L0 | ||
28 | |||
29 | // define render case | ||
30 | #define SUBTEXEL | ||
31 | #define INVERSE_W | ||
32 | |||
33 | #define USE_ZBUFFER | ||
34 | #define IPOL_W | ||
35 | #define CMP_W | ||
36 | #define WRITE_W | ||
37 | |||
38 | #define IPOL_C0 | ||
39 | #define IPOL_T0 | ||
40 | #define IPOL_T1 | ||
41 | #define IPOL_L0 | ||
42 | |||
43 | // apply global override | ||
44 | #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT | ||
45 | #undef INVERSE_W | ||
46 | #endif | ||
47 | |||
48 | #ifndef SOFTWARE_DRIVER_2_SUBTEXEL | ||
49 | #undef SUBTEXEL | ||
50 | #endif | ||
51 | |||
52 | #ifndef SOFTWARE_DRIVER_2_USE_VERTEX_COLOR | ||
53 | #undef IPOL_C0 | ||
54 | #endif | ||
55 | |||
56 | #if !defined ( SOFTWARE_DRIVER_2_USE_WBUFFER ) && defined ( USE_ZBUFFER ) | ||
57 | #ifndef SOFTWARE_DRIVER_2_PERSPECTIVE_CORRECT | ||
58 | #undef IPOL_W | ||
59 | #endif | ||
60 | #define IPOL_Z | ||
61 | |||
62 | #ifdef CMP_W | ||
63 | #undef CMP_W | ||
64 | #define CMP_Z | ||
65 | #endif | ||
66 | |||
67 | #ifdef WRITE_W | ||
68 | #undef WRITE_W | ||
69 | #define WRITE_Z | ||
70 | #endif | ||
71 | |||
72 | #endif | ||
73 | |||
74 | |||
75 | namespace irr | ||
76 | { | ||
77 | |||
78 | namespace video | ||
79 | { | ||
80 | |||
81 | |||
82 | class CTRNormalMap : public IBurningShader | ||
83 | { | ||
84 | public: | ||
85 | |||
86 | //! constructor | ||
87 | CTRNormalMap(CBurningVideoDriver* driver); | ||
88 | |||
89 | //! draws an indexed triangle list | ||
90 | virtual void drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ); | ||
91 | |||
92 | |||
93 | private: | ||
94 | void scanline_bilinear (); | ||
95 | |||
96 | sScanConvertData scan; | ||
97 | sScanLineData line; | ||
98 | |||
99 | }; | ||
100 | |||
101 | //! constructor | ||
102 | CTRNormalMap::CTRNormalMap(CBurningVideoDriver* driver) | ||
103 | : IBurningShader(driver) | ||
104 | { | ||
105 | #ifdef _DEBUG | ||
106 | setDebugName("CTRNormalMap"); | ||
107 | #endif | ||
108 | } | ||
109 | |||
110 | |||
111 | |||
112 | /*! | ||
113 | */ | ||
114 | void CTRNormalMap::scanline_bilinear () | ||
115 | { | ||
116 | tVideoSample *dst; | ||
117 | |||
118 | #ifdef USE_ZBUFFER | ||
119 | fp24 *z; | ||
120 | #endif | ||
121 | |||
122 | s32 xStart; | ||
123 | s32 xEnd; | ||
124 | s32 dx; | ||
125 | |||
126 | |||
127 | #ifdef SUBTEXEL | ||
128 | f32 subPixel; | ||
129 | #endif | ||
130 | |||
131 | #ifdef IPOL_Z | ||
132 | f32 slopeZ; | ||
133 | #endif | ||
134 | #ifdef IPOL_W | ||
135 | fp24 slopeW; | ||
136 | #endif | ||
137 | #ifdef IPOL_C0 | ||
138 | sVec4 slopeC[MATERIAL_MAX_COLORS]; | ||
139 | #endif | ||
140 | #ifdef IPOL_T0 | ||
141 | sVec2 slopeT[BURNING_MATERIAL_MAX_TEXTURES]; | ||
142 | #endif | ||
143 | #ifdef IPOL_L0 | ||
144 | sVec3 slopeL[BURNING_MATERIAL_MAX_TANGENT]; | ||
145 | #endif | ||
146 | |||
147 | // apply top-left fill-convention, left | ||
148 | xStart = core::ceil32( line.x[0] ); | ||
149 | xEnd = core::ceil32( line.x[1] ) - 1; | ||
150 | |||
151 | dx = xEnd - xStart; | ||
152 | |||
153 | if ( dx < 0 ) | ||
154 | return; | ||
155 | |||
156 | // slopes | ||
157 | const f32 invDeltaX = core::reciprocal_approxim ( line.x[1] - line.x[0] ); | ||
158 | |||
159 | #ifdef IPOL_Z | ||
160 | slopeZ = (line.z[1] - line.z[0]) * invDeltaX; | ||
161 | #endif | ||
162 | #ifdef IPOL_W | ||
163 | slopeW = (line.w[1] - line.w[0]) * invDeltaX; | ||
164 | #endif | ||
165 | #ifdef IPOL_C0 | ||
166 | slopeC[0] = (line.c[0][1] - line.c[0][0]) * invDeltaX; | ||
167 | #endif | ||
168 | #ifdef IPOL_T0 | ||
169 | slopeT[0] = (line.t[0][1] - line.t[0][0]) * invDeltaX; | ||
170 | #endif | ||
171 | #ifdef IPOL_T1 | ||
172 | slopeT[1] = (line.t[1][1] - line.t[1][0]) * invDeltaX; | ||
173 | #endif | ||
174 | #ifdef IPOL_T2 | ||
175 | slopeT[2] = (line.t[2][1] - line.t[2][0]) * invDeltaX; | ||
176 | #endif | ||
177 | #ifdef IPOL_L0 | ||
178 | slopeL[0] = (line.l[0][1] - line.l[0][0]) * invDeltaX; | ||
179 | #endif | ||
180 | |||
181 | #ifdef SUBTEXEL | ||
182 | subPixel = ( (f32) xStart ) - line.x[0]; | ||
183 | #ifdef IPOL_Z | ||
184 | line.z[0] += slopeZ * subPixel; | ||
185 | #endif | ||
186 | #ifdef IPOL_W | ||
187 | line.w[0] += slopeW * subPixel; | ||
188 | #endif | ||
189 | #ifdef IPOL_C0 | ||
190 | line.c[0][0] += slopeC[0] * subPixel; | ||
191 | #endif | ||
192 | #ifdef IPOL_T0 | ||
193 | line.t[0][0] += slopeT[0] * subPixel; | ||
194 | #endif | ||
195 | #ifdef IPOL_T1 | ||
196 | line.t[1][0] += slopeT[1] * subPixel; | ||
197 | #endif | ||
198 | #ifdef IPOL_T2 | ||
199 | line.t[2][0] += slopeT[2] * subPixel; | ||
200 | #endif | ||
201 | #ifdef IPOL_L0 | ||
202 | line.l[0][0] += slopeL[0] * subPixel; | ||
203 | #endif | ||
204 | #endif | ||
205 | |||
206 | dst = (tVideoSample*)RenderTarget->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; | ||
207 | |||
208 | #ifdef USE_ZBUFFER | ||
209 | z = (fp24*) DepthBuffer->lock() + ( line.y * RenderTarget->getDimension().Width ) + xStart; | ||
210 | #endif | ||
211 | |||
212 | |||
213 | #ifdef INVERSE_W | ||
214 | f32 inversew; | ||
215 | #endif | ||
216 | |||
217 | tFixPoint tx0, tx1; | ||
218 | tFixPoint ty0, ty1; | ||
219 | |||
220 | tFixPoint r0, g0, b0; | ||
221 | tFixPoint r1, g1, b1; | ||
222 | tFixPoint r2, g2, b2; | ||
223 | |||
224 | tFixPoint lx, ly, lz; | ||
225 | tFixPoint ndotl; | ||
226 | |||
227 | sVec3 light; | ||
228 | |||
229 | |||
230 | #ifdef IPOL_C0 | ||
231 | tFixPoint r3, g3, b3; | ||
232 | #endif | ||
233 | |||
234 | for ( s32 i = 0; i <= dx; i++ ) | ||
235 | { | ||
236 | #ifdef CMP_Z | ||
237 | if ( line.z[0] < z[i] ) | ||
238 | #endif | ||
239 | #ifdef CMP_W | ||
240 | if ( line.w[0] >= z[i] ) | ||
241 | #endif | ||
242 | { | ||
243 | #ifdef INVERSE_W | ||
244 | inversew = fix_inverse32 ( line.w[0] ); | ||
245 | |||
246 | tx0 = tofix ( line.t[0][0].x,inversew); | ||
247 | ty0 = tofix ( line.t[0][0].y,inversew); | ||
248 | tx1 = tofix ( line.t[1][0].x,inversew); | ||
249 | ty1 = tofix ( line.t[1][0].y,inversew); | ||
250 | |||
251 | |||
252 | #ifdef IPOL_C0 | ||
253 | r3 = tofix ( line.c[0][0].y ,inversew ); | ||
254 | g3 = tofix ( line.c[0][0].z ,inversew ); | ||
255 | b3 = tofix ( line.c[0][0].w ,inversew ); | ||
256 | #endif | ||
257 | |||
258 | #else | ||
259 | tx0 = tofix ( line.t[0][0].x ); | ||
260 | ty0 = tofix ( line.t[0][0].y ); | ||
261 | tx1 = tofix ( line.t[1][0].x ); | ||
262 | ty1 = tofix ( line.t[1][0].y ); | ||
263 | |||
264 | #ifdef IPOL_C0 | ||
265 | r3 = tofix ( line.c[0][0].y ); | ||
266 | g3 = tofix ( line.c[0][0].z ); | ||
267 | b3 = tofix ( line.c[0][0].w ); | ||
268 | #endif | ||
269 | |||
270 | #endif | ||
271 | getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); | ||
272 | |||
273 | // normal map | ||
274 | getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 ); | ||
275 | |||
276 | r1 = ( r1 - FIX_POINT_HALF_COLOR) >> (COLOR_MAX_LOG2-1); | ||
277 | g1 = ( g1 - FIX_POINT_HALF_COLOR) >> (COLOR_MAX_LOG2-1); | ||
278 | b1 = ( b1 - FIX_POINT_HALF_COLOR) >> (COLOR_MAX_LOG2-1); | ||
279 | |||
280 | /* | ||
281 | sVec3 l = line.l[0][0] * inversew; | ||
282 | l.setLength( 2.f ); | ||
283 | |||
284 | lx = tofix ( l.x - 0.5f ); | ||
285 | ly = tofix ( l.y - 0.5f ); | ||
286 | lz = tofix ( l.z - 0.5f ); | ||
287 | */ | ||
288 | |||
289 | lx = tofix ( line.l[0][0].x, inversew ); | ||
290 | ly = tofix ( line.l[0][0].y, inversew ); | ||
291 | lz = tofix ( line.l[0][0].z, inversew ); | ||
292 | |||
293 | // DOT 3 Normal Map light in tangent space | ||
294 | ndotl = saturateFix ( FIX_POINT_HALF_COLOR + (( imulFix ( r1, lx ) + imulFix ( g1, ly ) + imulFix ( b1, lz ) ) << (COLOR_MAX_LOG2-1)) ); | ||
295 | |||
296 | #ifdef IPOL_C0 | ||
297 | |||
298 | // N . L | ||
299 | r2 = imulFix ( imulFix_tex1 ( r0, ndotl ), r3 ); | ||
300 | g2 = imulFix ( imulFix_tex1 ( g0, ndotl ), g3 ); | ||
301 | b2 = imulFix ( imulFix_tex1 ( b0, ndotl ), b3 ); | ||
302 | |||
303 | /* | ||
304 | // heightmap: (1 - neu ) + alt - 0.5, on_minus_srcalpha + add signed | ||
305 | // emboss bump map | ||
306 | a4 -= a1; | ||
307 | r2 = clampfix_maxcolor ( clampfix_mincolor ( imulFix ( r0 + a4, r3 ) ) ); | ||
308 | g2 = clampfix_maxcolor ( clampfix_mincolor ( imulFix ( g0 + a4, g3 ) ) ); | ||
309 | b2 = clampfix_maxcolor ( clampfix_mincolor ( imulFix ( b0 + a4, b3 ) ) ); | ||
310 | */ | ||
311 | |||
312 | /* | ||
313 | r2 = clampfix_maxcolor ( imulFix_tex1 ( r2, r1 ) ); | ||
314 | g2 = clampfix_maxcolor ( imulFix_tex1 ( g2, g1 ) ); | ||
315 | b2 = clampfix_maxcolor ( imulFix_tex1 ( b2, b1 ) ); | ||
316 | */ | ||
317 | #else | ||
318 | r2 = clampfix_maxcolor ( imulFix_tex4 ( r0, r1 ) ); | ||
319 | g2 = clampfix_maxcolor ( imulFix_tex4 ( g0, g1 ) ); | ||
320 | b2 = clampfix_maxcolor ( imulFix_tex4 ( b0, b1 ) ); | ||
321 | #endif | ||
322 | |||
323 | |||
324 | dst[i] = fix_to_color ( r2, g2, b2 ); | ||
325 | |||
326 | #ifdef WRITE_Z | ||
327 | z[i] = line.z[0]; | ||
328 | #endif | ||
329 | #ifdef WRITE_W | ||
330 | z[i] = line.w[0]; | ||
331 | #endif | ||
332 | } | ||
333 | |||
334 | #ifdef IPOL_Z | ||
335 | line.z[0] += slopeZ; | ||
336 | #endif | ||
337 | #ifdef IPOL_W | ||
338 | line.w[0] += slopeW; | ||
339 | #endif | ||
340 | #ifdef IPOL_C0 | ||
341 | line.c[0][0] += slopeC[0]; | ||
342 | #endif | ||
343 | #ifdef IPOL_T0 | ||
344 | line.t[0][0] += slopeT[0]; | ||
345 | #endif | ||
346 | #ifdef IPOL_T1 | ||
347 | line.t[1][0] += slopeT[1]; | ||
348 | #endif | ||
349 | #ifdef IPOL_T2 | ||
350 | line.t[2][0] += slopeT[2]; | ||
351 | #endif | ||
352 | #ifdef IPOL_L0 | ||
353 | line.l[0][0] += slopeL[0]; | ||
354 | #endif | ||
355 | } | ||
356 | |||
357 | } | ||
358 | |||
359 | void CTRNormalMap::drawTriangle ( const s4DVertex *a,const s4DVertex *b,const s4DVertex *c ) | ||
360 | { | ||
361 | // sort on height, y | ||
362 | if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); | ||
363 | if ( F32_A_GREATER_B ( b->Pos.y , c->Pos.y ) ) swapVertexPointer(&b, &c); | ||
364 | if ( F32_A_GREATER_B ( a->Pos.y , b->Pos.y ) ) swapVertexPointer(&a, &b); | ||
365 | |||
366 | const f32 ca = c->Pos.y - a->Pos.y; | ||
367 | const f32 ba = b->Pos.y - a->Pos.y; | ||
368 | const f32 cb = c->Pos.y - b->Pos.y; | ||
369 | // calculate delta y of the edges | ||
370 | scan.invDeltaY[0] = core::reciprocal( ca ); | ||
371 | scan.invDeltaY[1] = core::reciprocal( ba ); | ||
372 | scan.invDeltaY[2] = core::reciprocal( cb ); | ||
373 | |||
374 | if ( F32_LOWER_EQUAL_0 ( scan.invDeltaY[0] ) ) | ||
375 | return; | ||
376 | |||
377 | // find if the major edge is left or right aligned | ||
378 | f32 temp[4]; | ||
379 | |||
380 | temp[0] = a->Pos.x - c->Pos.x; | ||
381 | temp[1] = -ca; | ||
382 | temp[2] = b->Pos.x - a->Pos.x; | ||
383 | temp[3] = ba; | ||
384 | |||
385 | scan.left = ( temp[0] * temp[3] - temp[1] * temp[2] ) > 0.f ? 0 : 1; | ||
386 | scan.right = 1 - scan.left; | ||
387 | |||
388 | // calculate slopes for the major edge | ||
389 | scan.slopeX[0] = (c->Pos.x - a->Pos.x) * scan.invDeltaY[0]; | ||
390 | scan.x[0] = a->Pos.x; | ||
391 | |||
392 | #ifdef IPOL_Z | ||
393 | scan.slopeZ[0] = (c->Pos.z - a->Pos.z) * scan.invDeltaY[0]; | ||
394 | scan.z[0] = a->Pos.z; | ||
395 | #endif | ||
396 | |||
397 | #ifdef IPOL_W | ||
398 | scan.slopeW[0] = (c->Pos.w - a->Pos.w) * scan.invDeltaY[0]; | ||
399 | scan.w[0] = a->Pos.w; | ||
400 | #endif | ||
401 | |||
402 | #ifdef IPOL_C0 | ||
403 | scan.slopeC[0][0] = (c->Color[0] - a->Color[0]) * scan.invDeltaY[0]; | ||
404 | scan.c[0][0] = a->Color[0]; | ||
405 | #endif | ||
406 | |||
407 | #ifdef IPOL_T0 | ||
408 | scan.slopeT[0][0] = (c->Tex[0] - a->Tex[0]) * scan.invDeltaY[0]; | ||
409 | scan.t[0][0] = a->Tex[0]; | ||
410 | #endif | ||
411 | |||
412 | #ifdef IPOL_T1 | ||
413 | scan.slopeT[1][0] = (c->Tex[1] - a->Tex[1]) * scan.invDeltaY[0]; | ||
414 | scan.t[1][0] = a->Tex[1]; | ||
415 | #endif | ||
416 | |||
417 | #ifdef IPOL_T2 | ||
418 | scan.slopeT[2][0] = (c->Tex[2] - a->Tex[2]) * scan.invDeltaY[0]; | ||
419 | scan.t[2][0] = a->Tex[2]; | ||
420 | #endif | ||
421 | |||
422 | #ifdef IPOL_L0 | ||
423 | scan.slopeL[0][0] = (c->LightTangent[0] - a->LightTangent[0]) * scan.invDeltaY[0]; | ||
424 | scan.l[0][0] = a->LightTangent[0]; | ||
425 | #endif | ||
426 | |||
427 | // top left fill convention y run | ||
428 | s32 yStart; | ||
429 | s32 yEnd; | ||
430 | |||
431 | #ifdef SUBTEXEL | ||
432 | f32 subPixel; | ||
433 | #endif | ||
434 | |||
435 | |||
436 | // rasterize upper sub-triangle | ||
437 | //if ( (f32) 0.0 != scan.invDeltaY[1] ) | ||
438 | if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) | ||
439 | { | ||
440 | // calculate slopes for top edge | ||
441 | scan.slopeX[1] = (b->Pos.x - a->Pos.x) * scan.invDeltaY[1]; | ||
442 | scan.x[1] = a->Pos.x; | ||
443 | |||
444 | #ifdef IPOL_Z | ||
445 | scan.slopeZ[1] = (b->Pos.z - a->Pos.z) * scan.invDeltaY[1]; | ||
446 | scan.z[1] = a->Pos.z; | ||
447 | #endif | ||
448 | |||
449 | #ifdef IPOL_W | ||
450 | scan.slopeW[1] = (b->Pos.w - a->Pos.w) * scan.invDeltaY[1]; | ||
451 | scan.w[1] = a->Pos.w; | ||
452 | #endif | ||
453 | |||
454 | #ifdef IPOL_C0 | ||
455 | scan.slopeC[0][1] = (b->Color[0] - a->Color[0]) * scan.invDeltaY[1]; | ||
456 | scan.c[0][1] = a->Color[0]; | ||
457 | #endif | ||
458 | |||
459 | #ifdef IPOL_T0 | ||
460 | scan.slopeT[0][1] = (b->Tex[0] - a->Tex[0]) * scan.invDeltaY[1]; | ||
461 | scan.t[0][1] = a->Tex[0]; | ||
462 | #endif | ||
463 | |||
464 | #ifdef IPOL_T1 | ||
465 | scan.slopeT[1][1] = (b->Tex[1] - a->Tex[1]) * scan.invDeltaY[1]; | ||
466 | scan.t[1][1] = a->Tex[1]; | ||
467 | #endif | ||
468 | |||
469 | #ifdef IPOL_T2 | ||
470 | scan.slopeT[2][1] = (b->Tex[2] - a->Tex[2]) * scan.invDeltaY[1]; | ||
471 | scan.t[2][1] = a->Tex[2]; | ||
472 | #endif | ||
473 | |||
474 | #ifdef IPOL_L0 | ||
475 | scan.slopeL[0][1] = (b->LightTangent[0] - a->LightTangent[0]) * scan.invDeltaY[1]; | ||
476 | scan.l[0][1] = a->LightTangent[0]; | ||
477 | #endif | ||
478 | |||
479 | // apply top-left fill convention, top part | ||
480 | yStart = core::ceil32( a->Pos.y ); | ||
481 | yEnd = core::ceil32( b->Pos.y ) - 1; | ||
482 | |||
483 | #ifdef SUBTEXEL | ||
484 | subPixel = ( (f32) yStart ) - a->Pos.y; | ||
485 | |||
486 | // correct to pixel center | ||
487 | scan.x[0] += scan.slopeX[0] * subPixel; | ||
488 | scan.x[1] += scan.slopeX[1] * subPixel; | ||
489 | |||
490 | #ifdef IPOL_Z | ||
491 | scan.z[0] += scan.slopeZ[0] * subPixel; | ||
492 | scan.z[1] += scan.slopeZ[1] * subPixel; | ||
493 | #endif | ||
494 | |||
495 | #ifdef IPOL_W | ||
496 | scan.w[0] += scan.slopeW[0] * subPixel; | ||
497 | scan.w[1] += scan.slopeW[1] * subPixel; | ||
498 | #endif | ||
499 | |||
500 | #ifdef IPOL_C0 | ||
501 | scan.c[0][0] += scan.slopeC[0][0] * subPixel; | ||
502 | scan.c[0][1] += scan.slopeC[0][1] * subPixel; | ||
503 | #endif | ||
504 | |||
505 | #ifdef IPOL_T0 | ||
506 | scan.t[0][0] += scan.slopeT[0][0] * subPixel; | ||
507 | scan.t[0][1] += scan.slopeT[0][1] * subPixel; | ||
508 | #endif | ||
509 | |||
510 | #ifdef IPOL_T1 | ||
511 | scan.t[1][0] += scan.slopeT[1][0] * subPixel; | ||
512 | scan.t[1][1] += scan.slopeT[1][1] * subPixel; | ||
513 | #endif | ||
514 | |||
515 | #ifdef IPOL_T2 | ||
516 | scan.t[2][0] += scan.slopeT[2][0] * subPixel; | ||
517 | scan.t[2][1] += scan.slopeT[2][1] * subPixel; | ||
518 | #endif | ||
519 | |||
520 | #ifdef IPOL_L0 | ||
521 | scan.l[0][0] += scan.slopeL[0][0] * subPixel; | ||
522 | scan.l[0][1] += scan.slopeL[0][1] * subPixel; | ||
523 | #endif | ||
524 | |||
525 | #endif | ||
526 | |||
527 | // rasterize the edge scanlines | ||
528 | for( line.y = yStart; line.y <= yEnd; ++line.y) | ||
529 | { | ||
530 | line.x[scan.left] = scan.x[0]; | ||
531 | line.x[scan.right] = scan.x[1]; | ||
532 | |||
533 | #ifdef IPOL_Z | ||
534 | line.z[scan.left] = scan.z[0]; | ||
535 | line.z[scan.right] = scan.z[1]; | ||
536 | #endif | ||
537 | |||
538 | #ifdef IPOL_W | ||
539 | line.w[scan.left] = scan.w[0]; | ||
540 | line.w[scan.right] = scan.w[1]; | ||
541 | #endif | ||
542 | |||
543 | #ifdef IPOL_C0 | ||
544 | line.c[0][scan.left] = scan.c[0][0]; | ||
545 | line.c[0][scan.right] = scan.c[0][1]; | ||
546 | #endif | ||
547 | |||
548 | #ifdef IPOL_T0 | ||
549 | line.t[0][scan.left] = scan.t[0][0]; | ||
550 | line.t[0][scan.right] = scan.t[0][1]; | ||
551 | #endif | ||
552 | |||
553 | #ifdef IPOL_T1 | ||
554 | line.t[1][scan.left] = scan.t[1][0]; | ||
555 | line.t[1][scan.right] = scan.t[1][1]; | ||
556 | #endif | ||
557 | |||
558 | #ifdef IPOL_T2 | ||
559 | line.t[2][scan.left] = scan.t[2][0]; | ||
560 | line.t[2][scan.right] = scan.t[2][1]; | ||
561 | #endif | ||
562 | |||
563 | #ifdef IPOL_L0 | ||
564 | line.l[0][scan.left] = scan.l[0][0]; | ||
565 | line.l[0][scan.right] = scan.l[0][1]; | ||
566 | #endif | ||
567 | |||
568 | // render a scanline | ||
569 | scanline_bilinear (); | ||
570 | |||
571 | scan.x[0] += scan.slopeX[0]; | ||
572 | scan.x[1] += scan.slopeX[1]; | ||
573 | |||
574 | #ifdef IPOL_Z | ||
575 | scan.z[0] += scan.slopeZ[0]; | ||
576 | scan.z[1] += scan.slopeZ[1]; | ||
577 | #endif | ||
578 | |||
579 | #ifdef IPOL_W | ||
580 | scan.w[0] += scan.slopeW[0]; | ||
581 | scan.w[1] += scan.slopeW[1]; | ||
582 | #endif | ||
583 | |||
584 | #ifdef IPOL_C0 | ||
585 | scan.c[0][0] += scan.slopeC[0][0]; | ||
586 | scan.c[0][1] += scan.slopeC[0][1]; | ||
587 | #endif | ||
588 | |||
589 | #ifdef IPOL_T0 | ||
590 | scan.t[0][0] += scan.slopeT[0][0]; | ||
591 | scan.t[0][1] += scan.slopeT[0][1]; | ||
592 | #endif | ||
593 | |||
594 | #ifdef IPOL_T1 | ||
595 | scan.t[1][0] += scan.slopeT[1][0]; | ||
596 | scan.t[1][1] += scan.slopeT[1][1]; | ||
597 | #endif | ||
598 | |||
599 | #ifdef IPOL_T2 | ||
600 | scan.t[2][0] += scan.slopeT[2][0]; | ||
601 | scan.t[2][1] += scan.slopeT[2][1]; | ||
602 | #endif | ||
603 | |||
604 | #ifdef IPOL_L0 | ||
605 | scan.l[0][0] += scan.slopeL[0][0]; | ||
606 | scan.l[0][1] += scan.slopeL[0][1]; | ||
607 | #endif | ||
608 | |||
609 | } | ||
610 | } | ||
611 | |||
612 | // rasterize lower sub-triangle | ||
613 | //if ( (f32) 0.0 != scan.invDeltaY[2] ) | ||
614 | if ( F32_GREATER_0 ( scan.invDeltaY[2] ) ) | ||
615 | { | ||
616 | // advance to middle point | ||
617 | //if( (f32) 0.0 != scan.invDeltaY[1] ) | ||
618 | if ( F32_GREATER_0 ( scan.invDeltaY[1] ) ) | ||
619 | { | ||
620 | temp[0] = b->Pos.y - a->Pos.y; // dy | ||
621 | |||
622 | scan.x[0] = a->Pos.x + scan.slopeX[0] * temp[0]; | ||
623 | #ifdef IPOL_Z | ||
624 | scan.z[0] = a->Pos.z + scan.slopeZ[0] * temp[0]; | ||
625 | #endif | ||
626 | #ifdef IPOL_W | ||
627 | scan.w[0] = a->Pos.w + scan.slopeW[0] * temp[0]; | ||
628 | #endif | ||
629 | #ifdef IPOL_C0 | ||
630 | scan.c[0][0] = a->Color[0] + scan.slopeC[0][0] * temp[0]; | ||
631 | #endif | ||
632 | #ifdef IPOL_T0 | ||
633 | scan.t[0][0] = a->Tex[0] + scan.slopeT[0][0] * temp[0]; | ||
634 | #endif | ||
635 | #ifdef IPOL_T1 | ||
636 | scan.t[1][0] = a->Tex[1] + scan.slopeT[1][0] * temp[0]; | ||
637 | #endif | ||
638 | #ifdef IPOL_T2 | ||
639 | scan.t[2][0] = a->Tex[2] + scan.slopeT[2][0] * temp[0]; | ||
640 | #endif | ||
641 | #ifdef IPOL_L0 | ||
642 | scan.l[0][0] = a->LightTangent[0] + scan.slopeL[0][0] * temp[0]; | ||
643 | #endif | ||
644 | |||
645 | } | ||
646 | |||
647 | // calculate slopes for bottom edge | ||
648 | scan.slopeX[1] = (c->Pos.x - b->Pos.x) * scan.invDeltaY[2]; | ||
649 | scan.x[1] = b->Pos.x; | ||
650 | |||
651 | #ifdef IPOL_Z | ||
652 | scan.slopeZ[1] = (c->Pos.z - b->Pos.z) * scan.invDeltaY[2]; | ||
653 | scan.z[1] = b->Pos.z; | ||
654 | #endif | ||
655 | |||
656 | #ifdef IPOL_W | ||
657 | scan.slopeW[1] = (c->Pos.w - b->Pos.w) * scan.invDeltaY[2]; | ||
658 | scan.w[1] = b->Pos.w; | ||
659 | #endif | ||
660 | |||
661 | #ifdef IPOL_C0 | ||
662 | scan.slopeC[0][1] = (c->Color[0] - b->Color[0]) * scan.invDeltaY[2]; | ||
663 | scan.c[0][1] = b->Color[0]; | ||
664 | #endif | ||
665 | |||
666 | #ifdef IPOL_T0 | ||
667 | scan.slopeT[0][1] = (c->Tex[0] - b->Tex[0]) * scan.invDeltaY[2]; | ||
668 | scan.t[0][1] = b->Tex[0]; | ||
669 | #endif | ||
670 | |||
671 | #ifdef IPOL_T1 | ||
672 | scan.slopeT[1][1] = (c->Tex[1] - b->Tex[1]) * scan.invDeltaY[2]; | ||
673 | scan.t[1][1] = b->Tex[1]; | ||
674 | #endif | ||
675 | |||
676 | #ifdef IPOL_T2 | ||
677 | scan.slopeT[2][1] = (c->Tex[2] - b->Tex[2]) * scan.invDeltaY[2]; | ||
678 | scan.t[2][1] = b->Tex[2]; | ||
679 | #endif | ||
680 | |||
681 | #ifdef IPOL_L0 | ||
682 | scan.slopeL[0][1] = (c->LightTangent[0] - b->LightTangent[0]) * scan.invDeltaY[2]; | ||
683 | scan.l[0][1] = b->LightTangent[0]; | ||
684 | #endif | ||
685 | |||
686 | // apply top-left fill convention, top part | ||
687 | yStart = core::ceil32( b->Pos.y ); | ||
688 | yEnd = core::ceil32( c->Pos.y ) - 1; | ||
689 | |||
690 | #ifdef SUBTEXEL | ||
691 | |||
692 | subPixel = ( (f32) yStart ) - b->Pos.y; | ||
693 | |||
694 | // correct to pixel center | ||
695 | scan.x[0] += scan.slopeX[0] * subPixel; | ||
696 | scan.x[1] += scan.slopeX[1] * subPixel; | ||
697 | |||
698 | #ifdef IPOL_Z | ||
699 | scan.z[0] += scan.slopeZ[0] * subPixel; | ||
700 | scan.z[1] += scan.slopeZ[1] * subPixel; | ||
701 | #endif | ||
702 | |||
703 | #ifdef IPOL_W | ||
704 | scan.w[0] += scan.slopeW[0] * subPixel; | ||
705 | scan.w[1] += scan.slopeW[1] * subPixel; | ||
706 | #endif | ||
707 | |||
708 | #ifdef IPOL_C0 | ||
709 | scan.c[0][0] += scan.slopeC[0][0] * subPixel; | ||
710 | scan.c[0][1] += scan.slopeC[0][1] * subPixel; | ||
711 | #endif | ||
712 | |||
713 | #ifdef IPOL_T0 | ||
714 | scan.t[0][0] += scan.slopeT[0][0] * subPixel; | ||
715 | scan.t[0][1] += scan.slopeT[0][1] * subPixel; | ||
716 | #endif | ||
717 | |||
718 | #ifdef IPOL_T1 | ||
719 | scan.t[1][0] += scan.slopeT[1][0] * subPixel; | ||
720 | scan.t[1][1] += scan.slopeT[1][1] * subPixel; | ||
721 | #endif | ||
722 | |||
723 | #ifdef IPOL_T2 | ||
724 | scan.t[2][0] += scan.slopeT[2][0] * subPixel; | ||
725 | scan.t[2][1] += scan.slopeT[2][1] * subPixel; | ||
726 | #endif | ||
727 | |||
728 | #ifdef IPOL_L0 | ||
729 | scan.l[0][0] += scan.slopeL[0][0] * subPixel; | ||
730 | scan.l[0][1] += scan.slopeL[0][1] * subPixel; | ||
731 | #endif | ||
732 | |||
733 | #endif | ||
734 | |||
735 | // rasterize the edge scanlines | ||
736 | for( line.y = yStart; line.y <= yEnd; ++line.y) | ||
737 | { | ||
738 | line.x[scan.left] = scan.x[0]; | ||
739 | line.x[scan.right] = scan.x[1]; | ||
740 | |||
741 | #ifdef IPOL_Z | ||
742 | line.z[scan.left] = scan.z[0]; | ||
743 | line.z[scan.right] = scan.z[1]; | ||
744 | #endif | ||
745 | |||
746 | #ifdef IPOL_W | ||
747 | line.w[scan.left] = scan.w[0]; | ||
748 | line.w[scan.right] = scan.w[1]; | ||
749 | #endif | ||
750 | |||
751 | #ifdef IPOL_C0 | ||
752 | line.c[0][scan.left] = scan.c[0][0]; | ||
753 | line.c[0][scan.right] = scan.c[0][1]; | ||
754 | #endif | ||
755 | |||
756 | #ifdef IPOL_T0 | ||
757 | line.t[0][scan.left] = scan.t[0][0]; | ||
758 | line.t[0][scan.right] = scan.t[0][1]; | ||
759 | #endif | ||
760 | |||
761 | #ifdef IPOL_T1 | ||
762 | line.t[1][scan.left] = scan.t[1][0]; | ||
763 | line.t[1][scan.right] = scan.t[1][1]; | ||
764 | #endif | ||
765 | |||
766 | #ifdef IPOL_T2 | ||
767 | line.t[2][scan.left] = scan.t[2][0]; | ||
768 | line.t[2][scan.right] = scan.t[2][1]; | ||
769 | #endif | ||
770 | |||
771 | #ifdef IPOL_L0 | ||
772 | line.l[0][scan.left] = scan.l[0][0]; | ||
773 | line.l[0][scan.right] = scan.l[0][1]; | ||
774 | #endif | ||
775 | |||
776 | // render a scanline | ||
777 | scanline_bilinear (); | ||
778 | |||
779 | scan.x[0] += scan.slopeX[0]; | ||
780 | scan.x[1] += scan.slopeX[1]; | ||
781 | |||
782 | #ifdef IPOL_Z | ||
783 | scan.z[0] += scan.slopeZ[0]; | ||
784 | scan.z[1] += scan.slopeZ[1]; | ||
785 | #endif | ||
786 | |||
787 | #ifdef IPOL_W | ||
788 | scan.w[0] += scan.slopeW[0]; | ||
789 | scan.w[1] += scan.slopeW[1]; | ||
790 | #endif | ||
791 | |||
792 | #ifdef IPOL_C0 | ||
793 | scan.c[0][0] += scan.slopeC[0][0]; | ||
794 | scan.c[0][1] += scan.slopeC[0][1]; | ||
795 | #endif | ||
796 | |||
797 | #ifdef IPOL_T0 | ||
798 | scan.t[0][0] += scan.slopeT[0][0]; | ||
799 | scan.t[0][1] += scan.slopeT[0][1]; | ||
800 | #endif | ||
801 | |||
802 | #ifdef IPOL_T1 | ||
803 | scan.t[1][0] += scan.slopeT[1][0]; | ||
804 | scan.t[1][1] += scan.slopeT[1][1]; | ||
805 | #endif | ||
806 | #ifdef IPOL_T2 | ||
807 | scan.t[2][0] += scan.slopeT[2][0]; | ||
808 | scan.t[2][1] += scan.slopeT[2][1]; | ||
809 | #endif | ||
810 | |||
811 | #ifdef IPOL_L0 | ||
812 | scan.l[0][0] += scan.slopeL[0][0]; | ||
813 | scan.l[0][1] += scan.slopeL[0][1]; | ||
814 | #endif | ||
815 | |||
816 | } | ||
817 | } | ||
818 | |||
819 | } | ||
820 | |||
821 | |||
822 | } // end namespace video | ||
823 | } // end namespace irr | ||
824 | |||
825 | #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ | ||
826 | |||
827 | namespace irr | ||
828 | { | ||
829 | namespace video | ||
830 | { | ||
831 | |||
832 | |||
833 | //! creates a triangle renderer | ||
834 | IBurningShader* createTRNormalMap(CBurningVideoDriver* driver) | ||
835 | { | ||
836 | #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ | ||
837 | return new CTRNormalMap(driver); | ||
838 | #else | ||
839 | return 0; | ||
840 | #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ | ||
841 | } | ||
842 | |||
843 | |||
844 | } // end namespace video | ||
845 | } // end namespace irr | ||
846 | |||
847 | |||
848 | |||