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