209
286
if(tex->stype==0) { /* lin */
287
texres->tin= (1.0+x)/2.0;
212
289
else if(tex->stype==1) { /* quad */
214
if(Tin<0.0) Tin= 0.0;
290
texres->tin= (1.0+x)/2.0;
291
if(texres->tin<0.0) texres->tin= 0.0;
292
else texres->tin*= texres->tin;
217
294
else if(tex->stype==2) { /* ease */
219
if(Tin<=.0) Tin= 0.0;
220
else if(Tin>=1.0) Tin= 1.0;
295
texres->tin= (1.0+x)/2.0;
296
if(texres->tin<=.0) texres->tin= 0.0;
297
else if(texres->tin>=1.0) texres->tin= 1.0;
223
Tin= (3.0*t-2.0*t*Tin);
299
t= texres->tin*texres->tin;
300
texres->tin= (3.0*t-2.0*t*texres->tin);
226
303
else if(tex->stype==3) { /* diag */
304
texres->tin= (2.0+x+y)/4.0;
229
306
else { /* sphere */
230
Tin= 1.0-sqrt(x*x+ y*y+texvec[2]*texvec[2]);
231
if(Tin<0.0) Tin= 0.0;
232
if(tex->stype==5) Tin*= Tin; /* halo */
307
texres->tin= 1.0-sqrt(x*x+ y*y+texvec[2]*texvec[2]);
308
if(texres->tin<0.0) texres->tin= 0.0;
309
if(tex->stype==5) texres->tin*= texres->tin; /* halo */
236
if(tex->flag & TEX_COLORBAND) return do_colorband(tex->coba);
241
317
/* ------------------------------------------------------------------------- */
242
318
/* ************************************************************************* */
243
/* clouds, wood & marble updated to do proper bumpmapping */
244
/* 0.025 seems reasonable value for offset */
247
320
/* newnoise: all noisebased types now have different noisebases to choose from */
249
static int clouds(Tex *tex, float *texvec)
322
static int clouds(Tex *tex, float *texvec, TexResult *texres)
251
324
int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
252
Tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
326
texres->tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
254
if (tex->nor!=NULL) {
328
if (texres->nor!=NULL) {
255
329
// calculate bumpnormal
256
tex->nor[0] = Tin - BLI_gTurbulence(tex->noisesize, texvec[0] + B_OFFS, texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
257
tex->nor[1] = Tin - BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1] + B_OFFS, texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
258
tex->nor[2] = Tin - BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2] + B_OFFS, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
330
texres->nor[0] = BLI_gTurbulence(tex->noisesize, texvec[0] + tex->nabla, texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
331
texres->nor[1] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1] + tex->nabla, texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
332
texres->nor[2] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2] + tex->nabla, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
334
tex_normal_derivate(tex, texres);
262
338
if (tex->stype==1) {
263
339
// in this case, int. value should really be computed from color,
264
340
// and bumpnormal from that, would be too slow, looks ok as is
266
Tg = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[0], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
267
Tb = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[2], texvec[0], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
341
texres->tr = texres->tin;
342
texres->tg = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[0], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
343
texres->tb = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[2], texvec[0], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
275
if (tex->flag & TEX_COLORBAND) return (rv + do_colorband(tex->coba));
355
/* creates a sine wave */
356
static float tex_sin(float a)
358
a = 0.5 + 0.5*sin(a);
363
/* creates a saw wave */
364
static float tex_saw(float a)
366
const float b = 2*M_PI;
368
int n = (int)(a / b);
374
/* creates a triangle wave */
375
static float tex_tri(float a)
377
const float b = 2*M_PI;
378
const float rmax = 1.0;
380
a = rmax - 2.0*fabs(floor((a*(1.0/b))+0.5) - (a*(1.0/b)));
281
385
/* computes basic wood intensity value at x,y,z */
282
386
static float wood_int(Tex *tex, float x, float y, float z)
287
wi = 0.5 + 0.5*sin((x + y + z)*10.0);
288
else if (tex->stype==1)
289
wi = 0.5 + 0.5*sin(sqrt(x*x + y*y + z*z)*20.0);
290
else if (tex->stype==2) {
291
wi = BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
292
wi = 0.5 + 0.5*sin(tex->turbul*wi + (x + y + z)*10.0);
294
else if (tex->stype==3) {
295
wi = BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
296
wi = 0.5 + 0.5*sin(tex->turbul*wi + (sqrt(x*x + y*y + z*z))*20.0);
389
short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
390
short wt = tex->stype; /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
392
float (*waveform[3])(float); /* create array of pointers to waveform functions */
393
waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
394
waveform[1] = tex_saw;
395
waveform[2] = tex_tri;
397
if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 is initialized ahead of time */
400
wi = waveform[wf]((x + y + z)*10.0);
402
else if (wt==TEX_RING) {
403
wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0);
405
else if (wt==TEX_BANDNOISE) {
406
wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
407
wi = waveform[wf]((x + y + z)*10.0 + wi);
409
else if (wt==TEX_RINGNOISE) {
410
wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
411
wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0 + wi);
302
static int wood(Tex *tex, float *texvec)
417
static int wood(Tex *tex, float *texvec, TexResult *texres)
304
int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
419
int rv=TEX_INT; /* return value, int:0, col:1, nor:2, everything:3 */
306
Tin = wood_int(tex, texvec[0], texvec[1], texvec[2]);
307
if (tex->nor!=NULL) {
421
texres->tin = wood_int(tex, texvec[0], texvec[1], texvec[2]);
422
if (texres->nor!=NULL) {
308
423
/* calculate bumpnormal */
309
tex->nor[0] = Tin - wood_int(tex, texvec[0] + B_OFFS, texvec[1], texvec[2]);
310
tex->nor[1] = Tin - wood_int(tex, texvec[0], texvec[1] + B_OFFS, texvec[2]);
311
tex->nor[2] = Tin - wood_int(tex, texvec[0], texvec[1], texvec[2] + B_OFFS);
424
texres->nor[0] = wood_int(tex, texvec[0] + tex->nabla, texvec[1], texvec[2]);
425
texres->nor[1] = wood_int(tex, texvec[0], texvec[1] + tex->nabla, texvec[2]);
426
texres->nor[2] = wood_int(tex, texvec[0], texvec[1], texvec[2] + tex->nabla);
428
tex_normal_derivate(tex, texres);
316
if (tex->flag & TEX_COLORBAND) return (rv + do_colorband(tex->coba));
322
438
static float marble_int(Tex *tex, float x, float y, float z)
441
short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
442
short mt = tex->stype; /* marble type: TEX_SOFT=0, TEX_SHARP=1,TEX_SHAPER=2 */
444
float (*waveform[3])(float); /* create array of pointers to waveform functions */
445
waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
446
waveform[1] = tex_saw;
447
waveform[2] = tex_tri;
449
if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 isn't initialized ahead of time */
326
451
n = 5.0 * (x + y + z);
453
mi = n + tex->turbul * BLI_gTurbulence(tex->noisesize, x, y, z, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
328
mi = 0.5 + 0.5 * sin(n + tex->turbul * BLI_gTurbulence(tex->noisesize, x, y, z, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis));
331
if (tex->stype==2) mi = sqrt(mi);
455
if (mt>=TEX_SOFT) { /* TEX_SOFT always true */
456
mi = waveform[wf](mi);
460
else if (mt==TEX_SHARPER) {
337
static int marble(Tex *tex, float *texvec)
468
static int marble(Tex *tex, float *texvec, TexResult *texres)
339
int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
341
Tin = marble_int(tex, texvec[0], texvec[1], texvec[2]);
343
if (tex->nor!=NULL) {
470
int rv=TEX_INT; /* return value, int:0, col:1, nor:2, everything:3 */
472
texres->tin = marble_int(tex, texvec[0], texvec[1], texvec[2]);
474
if (texres->nor!=NULL) {
344
475
/* calculate bumpnormal */
345
tex->nor[0] = Tin - marble_int(tex, texvec[0] + B_OFFS, texvec[1], texvec[2]);
346
tex->nor[1] = Tin - marble_int(tex, texvec[0], texvec[1] + B_OFFS, texvec[2]);
347
tex->nor[2] = Tin - marble_int(tex, texvec[0], texvec[1], texvec[2] + B_OFFS);
476
texres->nor[0] = marble_int(tex, texvec[0] + tex->nabla, texvec[1], texvec[2]);
477
texres->nor[1] = marble_int(tex, texvec[0], texvec[1] + tex->nabla, texvec[2]);
478
texres->nor[2] = marble_int(tex, texvec[0], texvec[1], texvec[2] + tex->nabla);
480
tex_normal_derivate(tex, texres);
352
if (tex->flag & TEX_COLORBAND) return (rv + do_colorband(tex->coba));
357
490
/* ------------------------------------------------------------------------- */
359
static int magic(Tex *tex, float *texvec)
492
static int magic(Tex *tex, float *texvec, TexResult *texres)
361
494
float x, y, z, turb=1.0;
430
565
/* ------------------------------------------------------------------------- */
432
567
/* newnoise: stucci also modified to use different noisebasis */
433
static int stucci(Tex *tex, float *texvec)
568
static int stucci(Tex *tex, float *texvec, TexResult *texres)
435
float b2, vec[3], ofs;
437
if(tex->nor == NULL) return 0;
572
if(texres->nor == NULL) return 0;
439
574
ofs= tex->turbul/200.0;
441
b2= BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
576
texres->tin=b2= BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
442
577
if(tex->stype) ofs*=(b2*b2);
443
vec[0] = b2 - BLI_gNoise(tex->noisesize, texvec[0]+ofs, texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
444
vec[1] = b2 - BLI_gNoise(tex->noisesize, texvec[0], texvec[1]+ofs, texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
445
vec[2] = b2 - BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2]+ofs, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
578
texres->nor[0] = BLI_gNoise(tex->noisesize, texvec[0]+ofs, texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
579
texres->nor[1] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1]+ofs, texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
580
texres->nor[2] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2]+ofs, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
453
tex->nor[0]= -vec[0];
454
tex->nor[1]= -vec[1];
455
tex->nor[2]= -vec[2];
582
tex_normal_derivate(tex, texres);
585
texres->nor[0]= -texres->nor[0];
586
texres->nor[1]= -texres->nor[1];
587
texres->nor[2]= -texres->nor[2];
472
604
mgravefunc = mg_fBm;
474
Tin = mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
606
texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
476
if (tex->nor!=NULL) {
608
if (texres->nor!=NULL) {
609
float offs= tex->nabla/tex->noisesize; // also scaling of texvec
477
611
/* calculate bumpnormal */
478
tex->nor[0] = Tin - mgravefunc(texvec[0] + B_OFFS, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
479
tex->nor[1] = Tin - mgravefunc(texvec[0], texvec[1] + B_OFFS, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
480
tex->nor[2] = Tin - mgravefunc(texvec[0], texvec[1], texvec[2] + B_OFFS, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
612
texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
613
texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
614
texres->nor[2] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
616
tex_normal_derivate(tex, texres);
484
Tin *= tex->ns_outscale;
488
if (tex->flag & TEX_COLORBAND) return (rv + do_colorband(tex->coba));
494
static float mg_ridgedOrHybridMFTex(Tex *tex, float *texvec)
626
static float mg_ridgedOrHybridMFTex(Tex *tex, float *texvec, TexResult *texres)
496
628
int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
497
629
float (*mgravefunc)(float, float, float, float, float, float, float, float, int);
502
634
mgravefunc = mg_HybridMultiFractal;
504
Tin = mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
506
if (tex->nor!=NULL) {
507
/* calculate bumpnormal */
508
tex->nor[0] = Tin - mgravefunc(texvec[0] + B_OFFS, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
509
tex->nor[1] = Tin - mgravefunc(texvec[0], texvec[1] + B_OFFS, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
510
tex->nor[2] = Tin - mgravefunc(texvec[0], texvec[1], texvec[2] + B_OFFS, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
514
Tin *= tex->ns_outscale;
518
if (tex->flag & TEX_COLORBAND) return (rv + do_colorband(tex->coba));
525
static float mg_HTerrainTex(Tex *tex, float *texvec)
527
int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
529
Tin = mg_HeteroTerrain(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
531
if (tex->nor!=NULL) {
532
/* calculate bumpnormal */
533
tex->nor[0] = Tin - mg_HeteroTerrain(texvec[0] + B_OFFS, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
534
tex->nor[1] = Tin - mg_HeteroTerrain(texvec[0], texvec[1] + B_OFFS, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
535
tex->nor[2] = Tin - mg_HeteroTerrain(texvec[0], texvec[1], texvec[2] + B_OFFS, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
539
Tin *= tex->ns_outscale;
543
if (tex->flag & TEX_COLORBAND) return (rv + do_colorband(tex->coba));
550
static float mg_distNoiseTex(Tex *tex, float *texvec)
552
int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
554
Tin = mg_VLNoise(texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
556
if (tex->nor!=NULL) {
557
/* calculate bumpnormal */
558
tex->nor[0] = Tin - mg_VLNoise(texvec[0] + B_OFFS, texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
559
tex->nor[1] = Tin - mg_VLNoise(texvec[0], texvec[1] + B_OFFS, texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
560
tex->nor[2] = Tin - mg_VLNoise(texvec[0], texvec[1], texvec[2] + B_OFFS, tex->dist_amount, tex->noisebasis, tex->noisebasis2);
566
if (tex->flag & TEX_COLORBAND) return (rv + do_colorband(tex->coba));
636
texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
638
if (texres->nor!=NULL) {
639
float offs= tex->nabla/tex->noisesize; // also scaling of texvec
641
/* calculate bumpnormal */
642
texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
643
texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
644
texres->nor[2] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
646
tex_normal_derivate(tex, texres);
657
static float mg_HTerrainTex(Tex *tex, float *texvec, TexResult *texres)
659
int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
661
texres->tin = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
663
if (texres->nor!=NULL) {
664
float offs= tex->nabla/tex->noisesize; // also scaling of texvec
666
/* calculate bumpnormal */
667
texres->nor[0] = tex->ns_outscale*mg_HeteroTerrain(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
668
texres->nor[1] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
669
texres->nor[2] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
671
tex_normal_derivate(tex, texres);
682
static float mg_distNoiseTex(Tex *tex, float *texvec, TexResult *texres)
684
int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
686
texres->tin = mg_VLNoise(texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
688
if (texres->nor!=NULL) {
689
float offs= tex->nabla/tex->noisesize; // also scaling of texvec
691
/* calculate bumpnormal */
692
texres->nor[0] = mg_VLNoise(texvec[0] + offs, texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
693
texres->nor[1] = mg_VLNoise(texvec[0], texvec[1] + offs, texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
694
texres->nor[2] = mg_VLNoise(texvec[0], texvec[1], texvec[2] + offs, tex->dist_amount, tex->noisebasis, tex->noisebasis2);
696
tex_normal_derivate(tex, texres);
585
720
if (sc!=0.f) sc = tex->ns_outscale/sc;
587
722
voronoi(texvec[0], texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
588
Tin = sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
723
texres->tin = sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
590
725
if (tex->vn_coltype) {
591
726
float ca[3]; /* cell color */
592
727
cellNoiseV(pa[0], pa[1], pa[2], ca);
728
texres->tr = aw1*ca[0];
729
texres->tg = aw1*ca[1];
730
texres->tb = aw1*ca[2];
596
731
cellNoiseV(pa[3], pa[4], pa[5], ca);
732
texres->tr += aw2*ca[0];
733
texres->tg += aw2*ca[1];
734
texres->tb += aw2*ca[2];
600
735
cellNoiseV(pa[6], pa[7], pa[8], ca);
736
texres->tr += aw3*ca[0];
737
texres->tg += aw3*ca[1];
738
texres->tb += aw3*ca[2];
604
739
cellNoiseV(pa[9], pa[10], pa[11], ca);
740
texres->tr += aw4*ca[0];
741
texres->tg += aw4*ca[1];
742
texres->tb += aw4*ca[2];
608
743
if (tex->vn_coltype>=2) {
609
744
float t1 = (da[1]-da[0])*10;
611
if (tex->vn_coltype==3) t1*=Tin; else t1*=sc;
746
if (tex->vn_coltype==3) t1*=texres->tin; else t1*=sc;
623
if (tex->nor!=NULL) {
758
if (texres->nor!=NULL) {
759
float offs= tex->nabla/tex->noisesize; // also scaling of texvec
624
761
/* calculate bumpnormal */
625
voronoi(texvec[0] + B_OFFS, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
626
tex->nor[0] = Tin - sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
627
voronoi(texvec[0], texvec[1] + B_OFFS, texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
628
tex->nor[1] = Tin - sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
629
voronoi(texvec[0], texvec[1], texvec[2] + B_OFFS, da, pa, tex->vn_mexp, tex->vn_distm);
630
tex->nor[2] = Tin - sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
762
voronoi(texvec[0] + offs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
763
texres->nor[0] = sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
764
voronoi(texvec[0], texvec[1] + offs, texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
765
texres->nor[1] = sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
766
voronoi(texvec[0], texvec[1], texvec[2] + offs, da, pa, tex->vn_mexp, tex->vn_distm);
767
texres->nor[2] = sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
769
tex_normal_derivate(tex, texres);
634
773
if (tex->vn_coltype) {
642
if (tex->flag & TEX_COLORBAND) return (rv + do_colorband(tex->coba));
666
Tin= ((float)val)/div;;
803
texres->tin= ((float)val)/div;;
669
if(tex->flag & TEX_COLORBAND) return do_colorband(tex->coba);
674
809
/* ------------------------------------------------------------------------- */
676
static int plugintex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
811
static int plugintex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres)
683
818
pit= tex->plugin;
684
819
if(pit && pit->doit) {
686
VECCOPY(pit->result+5, tex->nor);
821
VECCOPY(pit->result+5, texres->nor);
688
823
if(osatex) rgbnor= ((TexDoit)pit->doit)(tex->stype, pit->data, texvec, dxt, dyt);
689
824
else rgbnor= ((TexDoit)pit->doit)(tex->stype, pit->data, texvec, 0, 0);
826
texres->tin= pit->result[0];
693
828
if(rgbnor & TEX_NOR) {
695
VECCOPY(tex->nor, pit->result+5);
830
VECCOPY(texres->nor, pit->result+5);
699
834
if(rgbnor & TEX_RGB) {
835
texres->tr= pit->result[1];
836
texres->tg= pit->result[2];
837
texres->tb= pit->result[3];
838
texres->ta= pit->result[4];
709
if(tex->flag & TEX_COLORBAND) rgbnor |= do_colorband(tex->coba);
715
/* *************** PROJECTIONS ******************* */
717
void tubemap(float x, float y, float z, float *adr1, float *adr2)
721
*adr2 = (z + 1.0) / 2.0;
725
*adr1 = (1.0 - (atan2(x/len,y/len) / M_PI)) / 2.0;
729
/* ------------------------------------------------------------------------- */
731
void spheremap(float x, float y, float z, float *adr1, float *adr2)
735
len= sqrt(x*x+y*y+z*z);
738
if(x==0.0 && y==0.0) *adr1= 0.0; /* othwise domain error */
739
else *adr1 = (1.0 - atan2(x,y)/M_PI )/2.0;
742
*adr2 = 1.0- saacos(z)/M_PI;
746
/* ------------------------------------------------------------------------- */
748
850
static int cubemap_glob(MTex *mtex, VlakRen *vlr, float x, float y, float z, float *adr1, float *adr2)
1035
1137
/* ************************************** */
1037
int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
1139
static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres)
1141
int retval=0; /* return value, int:0, col:1, nor:2, everything:3 */
1143
texres->talpha= 0; /* is set when image texture returns alpha (considered premul) */
1040
1145
switch(tex->type) {
1045
1150
case TEX_CLOUDS:
1046
return clouds(tex, texvec);
1151
retval= clouds(tex, texvec, texres);
1048
return wood(tex, texvec);
1154
retval= wood(tex, texvec, texres);
1049
1156
case TEX_MARBLE:
1050
return marble(tex, texvec);
1157
retval= marble(tex, texvec, texres);
1051
1159
case TEX_MAGIC:
1052
return magic(tex, texvec);
1160
retval= magic(tex, texvec, texres);
1053
1162
case TEX_BLEND:
1054
return blend(tex, texvec);
1163
retval= blend(tex, texvec, texres);
1055
1165
case TEX_STUCCI:
1057
return stucci(tex, texvec);
1166
retval= stucci(tex, texvec, texres);
1167
if (tex->flag & TEX_COLORBAND);
1168
else texres->tin= 0.0; // stucci doesnt return Tin, for backwards compat...
1058
1170
case TEX_NOISE:
1059
return texnoise(tex);
1171
retval= texnoise(tex, texres);
1060
1173
case TEX_IMAGE:
1061
if(osatex) return imagewraposa(tex, texvec, dxt, dyt);
1062
else return imagewrap(tex, texvec);
1174
if(osatex) retval= imagewraposa(tex, tex->ima, texvec, dxt, dyt, texres);
1175
else retval= imagewrap(tex, tex->ima, texvec, texres);
1063
1177
case TEX_PLUGIN:
1064
return plugintex(tex, texvec, dxt, dyt, osatex);
1178
retval= plugintex(tex, texvec, dxt, dyt, osatex, texres);
1065
1180
case TEX_ENVMAP:
1066
return envmaptex(tex, texvec, dxt, dyt, osatex);
1181
retval= envmaptex(tex, texvec, dxt, dyt, osatex, texres);
1067
1183
case TEX_MUSGRAVE:
1068
1184
/* newnoise: musgrave types */
1070
/* ton: added this, for Blender convention reason. scaling texvec here is so-so... */
1186
/* ton: added this, for Blender convention reason. scaling texvec here is so-so ... */
1071
1187
VecMulf(texvec, 1.0/tex->noisesize);
1073
1189
switch(tex->stype) {
1074
1190
case TEX_MFRACTAL:
1076
return mg_mFractalOrfBmTex(tex, texvec);
1192
retval= mg_mFractalOrfBmTex(tex, texvec, texres);
1077
1194
case TEX_RIDGEDMF:
1078
1195
case TEX_HYBRIDMF:
1079
return mg_ridgedOrHybridMFTex(tex, texvec);
1196
retval= mg_ridgedOrHybridMFTex(tex, texvec, texres);
1080
1198
case TEX_HTERRAIN:
1081
return mg_HTerrainTex(tex, texvec);
1199
retval= mg_HTerrainTex(tex, texvec, texres);
1084
1203
/* newnoise: voronoi type */
1085
1204
case TEX_VORONOI:
1086
/* ton: added this, for Blender convention reason. scaling texvec here is so-so... */
1205
/* ton: added this, for Blender convention reason. scaling texvec here is so-so ... */
1087
1206
VecMulf(texvec, 1.0/tex->noisesize);
1089
return voronoiTex(tex, texvec);
1208
retval= voronoiTex(tex, texvec, texres);
1090
1210
case TEX_DISTNOISE:
1091
/* ton: added this, for Blender convention reason. scaling texvec here is so-so... */
1211
/* ton: added this, for Blender convention reason. scaling texvec here is so-so ... */
1092
1212
VecMulf(texvec, 1.0/tex->noisesize);
1094
return mg_distNoiseTex(tex, texvec);
1214
retval= mg_distNoiseTex(tex, texvec, texres);
1218
if (tex->flag & TEX_COLORBAND) {
1220
if (do_colorband(tex->coba, texres->tin, col)) {
1232
int multitex_ext(Tex *tex, float *texvec, float *tin, float *tr, float *tg, float *tb, float *ta)
1238
/* does not return Tin, hackish... */
1239
if(tex->type==TEX_STUCCI) {
1242
dummy[1]= dummy[2]= 0.0;
1244
else texr.nor= NULL;
1246
retval= multitex(tex, texvec, NULL, NULL, 0, &texr);
1247
if(tex->type==TEX_STUCCI) {
1248
*tin= 0.5 + 0.7*texr.nor[0];
1249
CLAMP(*tin, 0.0, 1.0);
1251
else *tin= texr.tin;
1099
1259
/* ------------------------------------------------------------------------- */
1261
/* in = destination, tex = texture, out = previous color */
1262
/* fact = texture strength, facg = button strength value */
1263
static void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg, int blendtype)
1272
in[0]= (fact*tex[0] + facm*out[0]);
1273
in[1]= (fact*tex[1] + facm*out[1]);
1274
in[2]= (fact*tex[2] + facm*out[2]);
1280
in[0]= (facm+fact*tex[0])*out[0];
1281
in[1]= (facm+fact*tex[1])*out[1];
1282
in[2]= (facm+fact*tex[2])*out[2];
1288
in[0]= 1.0-(facm+fact*(1.0-tex[0]))*(1.0-out[0]);
1289
in[1]= 1.0-(facm+fact*(1.0-tex[1]))*(1.0-out[1]);
1290
in[2]= 1.0-(facm+fact*(1.0-tex[2]))*(1.0-out[2]);
1297
in[0]= (fact*tex[0] + out[0]);
1298
in[1]= (fact*tex[1] + out[1]);
1299
in[2]= (fact*tex[2] + out[2]);
1307
in[0]= facm*out[0] + fact*out[0]/tex[0];
1309
in[1]= facm*out[1] + fact*out[1]/tex[1];
1311
in[2]= facm*out[2] + fact*out[2]/tex[2];
1318
in[0]= facm*out[0] + fact*fabs(tex[0]-out[0]);
1319
in[1]= facm*out[1] + fact*fabs(tex[1]-out[1]);
1320
in[2]= facm*out[2] + fact*fabs(tex[2]-out[2]);
1328
if(col < out[0]) in[0]= col; else in[0]= out[0];
1330
if(col < out[1]) in[1]= col; else in[1]= out[1];
1332
if(col < out[2]) in[2]= col; else in[2]= out[2];
1340
if(col > out[0]) in[0]= col; else in[0]= out[0];
1342
if(col > out[1]) in[1]= col; else in[1]= out[1];
1344
if(col > out[2]) in[2]= col; else in[2]= out[2];
1351
static float texture_value_blend(float tex, float out, float fact, float facg, int blendtype, int flip)
1353
float in=0.0, facm, col;
1357
if(flip) SWAP(float, fact, facm);
1361
in= fact*tex + facm*out;
1366
in= (facm+fact*tex)*out;
1371
in= 1.0-(facm+fact*(1.0-tex))*(1.0-out);
1382
in= facm*out + fact*out/tex;
1386
in= facm*out + fact*fabs(tex-out);
1391
if(col < out) in= col; else in= out;
1396
if(col > out) in= col; else in= out;
1101
1404
void do_material_tex(ShadeInput *shi)
1104
Material *mat_col, *mat_colspec, *mat_colmir, *mat_ref, *mat_amb;
1105
Material *mat_spec, *mat_har, *mat_emit, *mat_alpha, *mat_ray_mirr, *mat_translu;
1108
float *co = NULL, *dx = NULL, *dy = NULL, fact,
1109
facm, factt, facmm, facmul = 0.0, stencilTin=1.0;
1110
float texvec[3], dxt[3], dyt[3], tempvec[3], norvec[3], Tnor=1.0;
1111
int tex_nr, rgbnor= 0;
1409
float *co = NULL, *dx = NULL, *dy = NULL;
1410
float fact, facm, factt, facmm, stencilTin=1.0;
1411
float texvec[3], dxt[3], dyt[3], tempvec[3], norvec[3], warpvec[3], Tnor=1.0;
1412
int tex_nr, rgbnor= 0, warpdone=0;
1113
1414
/* here: test flag if there's a tex (todo) */
1115
mat_col=mat_colspec=mat_colmir=mat_ref=mat_spec=mat_har=mat_emit=mat_alpha=mat_ray_mirr=mat_translu=mat_amb= shi->mat;
1117
for(tex_nr=0; tex_nr<8; tex_nr++) {
1416
for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) {
1119
1418
/* separate tex switching */
1120
1419
if(shi->mat->septex & (1<<tex_nr)) continue;
1253
rgbnor= multitex(tex, texvec, dxt, dyt, shi->osatex);
1558
rgbnor= multitex(tex, texvec, dxt, dyt, shi->osatex, &texres);
1255
1560
/* texture output */
1257
1562
if( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
1258
Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
1563
texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
1261
1566
if(mtex->texflag & MTEX_NEGATIVE) {
1262
1567
if(rgbnor & TEX_RGB) {
1568
texres.tr= 1.0-texres.tr;
1569
texres.tg= 1.0-texres.tg;
1570
texres.tb= 1.0-texres.tb;
1572
texres.tin= 1.0-texres.tin;
1269
1574
if(mtex->texflag & MTEX_STENCIL) {
1270
1575
if(rgbnor & TEX_RGB) {
1577
texres.ta*= stencilTin;
1273
1578
stencilTin*= fact;
1582
texres.tin*= stencilTin;
1278
1583
stencilTin*= fact;
1587
texres.ta*= stencilTin;
1283
1588
Tnor*= stencilTin;
1287
if(tex->nor && (rgbnor & TEX_NOR)==0) {
1288
/* make our own normal */
1289
if(rgbnor & TEX_RGB) {
1295
float co= 0.5*cos(Tin-0.5);
1296
float si= 0.5*sin(Tin-0.5);
1301
tex->nor[0]= f1*co+f2*si;
1302
tex->nor[1]= f2*co-f1*si;
1305
tex->nor[1]= f1*co+f2*si;
1306
tex->nor[2]= f2*co-f1*si;
1589
texres.tin*= stencilTin;
1594
if((rgbnor & TEX_NOR)==0) {
1595
/* make our own normal */
1596
if(rgbnor & TEX_RGB) {
1597
texres.nor[0]= texres.tr;
1598
texres.nor[1]= texres.tg;
1599
texres.nor[2]= texres.tb;
1602
float co= 0.5*cos(texres.tin-0.5);
1603
float si= 0.5*sin(texres.tin-0.5);
1608
texres.nor[0]= f1*co+f2*si;
1609
texres.nor[1]= f2*co-f1*si;
1612
texres.nor[1]= f1*co+f2*si;
1613
texres.nor[2]= f2*co-f1*si;
1616
// warping, local space
1617
if(mtex->mapto & MAP_WARP) {
1618
warpvec[0]= mtex->warpfac*texres.nor[0];
1619
warpvec[1]= mtex->warpfac*texres.nor[1];
1620
warpvec[2]= mtex->warpfac*texres.nor[2];
1624
if(mtex->texflag & MTEX_VIEWSPACE) {
1625
// rotate to global coords
1626
if(mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) {
1627
if(shi->vlr && shi->vlr->ob) {
1628
float len= Normalise(texres.nor);
1629
// can be optimized... (ton)
1630
Mat4Mul3Vecfl(shi->vlr->ob->obmat, texres.nor);
1631
Mat4Mul3Vecfl(R.viewmat, texres.nor);
1632
Normalise(texres.nor);
1633
VecMulf(texres.nor, len);
1312
1640
if(mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) {
1643
tcol[0]=texres.tr; tcol[1]=texres.tg; tcol[2]=texres.tb;
1314
1645
if((rgbnor & TEX_RGB)==0) {
1319
1650
else if(mtex->mapto & MAP_ALPHA) {
1320
if(mtex->texflag & MTEX_ALPHAMIX) Tin= Ta;
1321
else Tin= stencilTin;
1651
texres.tin= stencilTin;
1325
fact= Tin*mtex->colfac;
1327
if(mtex->blendtype==MTEX_MUL) facm= 1.0-mtex->colfac;
1328
if(mtex->blendtype==MTEX_SUB) fact= -fact;
1653
else texres.tin= texres.ta;
1330
1655
if(mtex->mapto & MAP_COL) {
1331
if(mtex->blendtype==MTEX_BLEND) {
1332
shi->matren->r= (fact*Tr + facm*mat_col->r);
1333
shi->matren->g= (fact*Tg + facm*mat_col->g);
1334
shi->matren->b= (fact*Tb + facm*mat_col->b);
1336
else if(mtex->blendtype==MTEX_MUL) {
1337
shi->matren->r= (facm+fact*Tr)*mat_col->r;
1338
shi->matren->g= (facm+fact*Tg)*mat_col->g;
1339
shi->matren->b= (facm+fact*Tb)*mat_col->b;
1342
shi->matren->r= (fact*Tr + mat_col->r);
1343
shi->matren->g= (fact*Tg + mat_col->g);
1344
shi->matren->b= (fact*Tb + mat_col->b);
1346
mat_col= shi->matren;
1656
texture_rgb_blend(&shi->r, tcol, &shi->r, texres.tin, mtex->colfac, mtex->blendtype);
1348
1658
if(mtex->mapto & MAP_COLSPEC) {
1349
if(mtex->blendtype==MTEX_BLEND) {
1350
shi->matren->specr= (fact*Tr + facm*mat_colspec->specr);
1351
shi->matren->specg= (fact*Tg + facm*mat_colspec->specg);
1352
shi->matren->specb= (fact*Tb + facm*mat_colspec->specb);
1354
else if(mtex->blendtype==MTEX_MUL) {
1355
shi->matren->specr= (facm+fact*Tr)*mat_colspec->specr;
1356
shi->matren->specg= (facm+fact*Tg)*mat_colspec->specg;
1357
shi->matren->specb= (facm+fact*Tb)*mat_colspec->specb;
1360
shi->matren->specr= (fact*Tr + mat_colspec->specr);
1361
shi->matren->specg= (fact*Tg + mat_colspec->specg);
1362
shi->matren->specb= (fact*Tb + mat_colspec->specb);
1364
mat_colspec= shi->matren;
1659
texture_rgb_blend(&shi->specr, tcol, &shi->specr, texres.tin, mtex->colfac, mtex->blendtype);
1366
1661
if(mtex->mapto & MAP_COLMIR) {
1367
if(mtex->blendtype==MTEX_BLEND) {
1368
// exception for envmap only
1369
if(tex->type==TEX_ENVMAP) {
1370
shi->refcol[0]= fact + facm*shi->refcol[0];
1371
shi->refcol[1]= fact*Tr + facm*shi->refcol[1];
1372
shi->refcol[2]= fact*Tg + facm*shi->refcol[2];
1373
shi->refcol[3]= fact*Tb + facm*shi->refcol[3];
1375
shi->matren->mirr= fact*Tr + facm*mat_colmir->mirr;
1376
shi->matren->mirg= fact*Tg + facm*mat_colmir->mirg;
1377
shi->matren->mirb= fact*Tb + facm*mat_colmir->mirb;
1380
else if(mtex->blendtype==MTEX_MUL) {
1381
shi->matren->mirr= (facm+fact*Tr)*mat_colmir->mirr;
1382
shi->matren->mirg= (facm+fact*Tg)*mat_colmir->mirg;
1383
shi->matren->mirb= (facm+fact*Tb)*mat_colmir->mirb;
1662
// exception for envmap only
1663
if(tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) {
1664
fact= texres.tin*mtex->colfac;
1666
shi->refcol[0]= fact + facm*shi->refcol[0];
1667
shi->refcol[1]= fact*tcol[0] + facm*shi->refcol[1];
1668
shi->refcol[2]= fact*tcol[1] + facm*shi->refcol[2];
1669
shi->refcol[3]= fact*tcol[2] + facm*shi->refcol[3];
1386
shi->matren->mirr= (fact*Tr + mat_colmir->mirr);
1387
shi->matren->mirg= (fact*Tg + mat_colmir->mirg);
1388
shi->matren->mirb= (fact*Tb + mat_colmir->mirb);
1672
texture_rgb_blend(&shi->mirr, tcol, &shi->mirr, texres.tin, mtex->colfac, mtex->blendtype);
1390
mat_colmir= shi->matren;
1393
1676
if( (mtex->mapto & MAP_NORM) ) {
1396
1679
if(mtex->maptoneg & MAP_NORM) tex->norfac= -mtex->norfac;
1397
1680
else tex->norfac= mtex->norfac;
1399
shi->vn[0]+= Tnor*tex->norfac*tex->nor[0];
1400
shi->vn[1]+= Tnor*tex->norfac*tex->nor[1];
1401
shi->vn[2]+= Tnor*tex->norfac*tex->nor[2];
1682
/* we need to code blending modes for normals too once.. now 1 exception hardcoded */
1684
if(tex->type==TEX_IMAGE && (tex->imaflag & TEX_NORMALMAP)) {
1685
fact= Tnor*tex->norfac;
1686
if(fact>1.0) fact= 1.0; else if(fact<-1.0) fact= -1.0;
1688
shi->vn[0]= facm*shi->vn[0] + fact*texres.nor[0];
1689
shi->vn[1]= facm*shi->vn[1] + fact*texres.nor[1];
1690
shi->vn[2]= facm*shi->vn[2] + fact*texres.nor[2];
1693
shi->vn[0]+= Tnor*tex->norfac*texres.nor[0];
1694
shi->vn[1]+= Tnor*tex->norfac*texres.nor[1];
1695
shi->vn[2]+= Tnor*tex->norfac*texres.nor[2];
1403
1697
Normalise(shi->vn);
1405
1699
/* this makes sure the bump is passed on to the next texture */
1406
shi->orn[0]= shi->vn[0];
1407
shi->orn[1]= shi->vn[1];
1408
shi->orn[2]= shi->vn[2];
1700
shi->orn[0]= -shi->vn[0];
1701
shi->orn[1]= -shi->vn[1];
1702
shi->orn[2]= -shi->vn[2];
1410
1704
/* reflection vector */
1411
1705
calc_R_ref(shi);
1458
1752
if(mtex->mapto & MAP_VARS) {
1459
1753
if(rgbnor & TEX_RGB) {
1461
else Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
1754
if(texres.talpha) texres.tin= texres.ta;
1755
else texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
1464
fact= Tin*mtex->varfac;
1466
if(mtex->blendtype==MTEX_MUL) facmul= 1.0-mtex->varfac;
1467
if(mtex->blendtype==MTEX_SUB) fact= -fact;
1469
1758
if(mtex->mapto & MAP_REF) {
1470
if(mtex->maptoneg & MAP_REF) {factt= facm; facmm= fact;}
1471
else {factt= fact; facmm= facm;}
1759
int flip= mtex->maptoneg & MAP_REF;
1473
if(mtex->blendtype==MTEX_BLEND)
1474
shi->matren->ref= factt*mtex->def_var+ facmm*mat_ref->ref;
1475
else if(mtex->blendtype==MTEX_MUL)
1476
shi->matren->ref= (facmul+factt)*mat_ref->ref;
1478
shi->matren->ref= factt+mat_ref->ref;
1479
if(shi->matren->ref<0.0) shi->matren->ref= 0.0;
1481
mat_ref= shi->matren;
1761
shi->refl= texture_value_blend(mtex->def_var, shi->refl, texres.tin, mtex->varfac, mtex->blendtype, flip);
1762
if(shi->refl<0.0) shi->refl= 0.0;
1483
1764
if(mtex->mapto & MAP_SPEC) {
1484
if(mtex->maptoneg & MAP_SPEC) {factt= facm; facmm= fact;}
1485
else {factt= fact; facmm= facm;}
1487
if(mtex->blendtype==MTEX_BLEND)
1488
shi->matren->spec= factt*mtex->def_var+ facmm*mat_spec->spec;
1489
else if(mtex->blendtype==MTEX_MUL)
1490
shi->matren->spec= (facmul+factt)*mat_spec->spec;
1492
shi->matren->spec= factt+mat_spec->spec;
1493
if(shi->matren->spec<0.0) shi->matren->spec= 0.0;
1495
mat_spec= shi->matren;
1765
int flip= mtex->maptoneg & MAP_SPEC;
1767
shi->spec= texture_value_blend(mtex->def_var, shi->spec, texres.tin, mtex->varfac, mtex->blendtype, flip);
1768
if(shi->spec<0.0) shi->spec= 0.0;
1497
1770
if(mtex->mapto & MAP_EMIT) {
1498
if(mtex->maptoneg & MAP_EMIT) {factt= facm; facmm= fact;}
1499
else {factt= fact; facmm= facm;}
1771
int flip= mtex->maptoneg & MAP_EMIT;
1501
if(mtex->blendtype==MTEX_BLEND)
1502
shi->matren->emit= factt*mtex->def_var+ facmm*mat_emit->emit;
1503
else if(mtex->blendtype==MTEX_MUL)
1504
shi->matren->emit= (facmul+factt)*mat_emit->emit;
1506
shi->matren->emit= factt+mat_emit->emit;
1507
if(shi->matren->emit<0.0) shi->matren->emit= 0.0;
1509
mat_emit= shi->matren;
1773
shi->emit= texture_value_blend(mtex->def_var, shi->emit, texres.tin, mtex->varfac, mtex->blendtype, flip);
1774
if(shi->emit<0.0) shi->emit= 0.0;
1511
1776
if(mtex->mapto & MAP_ALPHA) {
1512
if(mtex->maptoneg & MAP_ALPHA) {factt= facm; facmm= fact;}
1513
else {factt= fact; facmm= facm;}
1777
int flip= mtex->maptoneg & MAP_ALPHA;
1515
if(mtex->blendtype==MTEX_BLEND)
1516
shi->matren->alpha= factt*mtex->def_var+ facmm*mat_alpha->alpha;
1517
else if(mtex->blendtype==MTEX_MUL)
1518
shi->matren->alpha= (facmul+factt)*mat_alpha->alpha;
1520
shi->matren->alpha= factt+mat_alpha->alpha;
1521
if(shi->matren->alpha<0.0) shi->matren->alpha= 0.0;
1522
else if(shi->matren->alpha>1.0) shi->matren->alpha= 1.0;
1524
mat_alpha= shi->matren;
1779
shi->alpha= texture_value_blend(mtex->def_var, shi->alpha, texres.tin, mtex->varfac, mtex->blendtype, flip);
1780
if(shi->alpha<0.0) shi->alpha= 0.0;
1781
else if(shi->alpha>1.0) shi->alpha= 1.0;
1526
1783
if(mtex->mapto & MAP_HAR) {
1527
if(mtex->maptoneg & MAP_HAR) {factt= facm; facmm= fact;}
1528
else {factt= fact; facmm= facm;}
1530
if(mtex->blendtype==MTEX_BLEND) {
1531
shi->matren->har= 128.0*factt*mtex->def_var+ facmm*mat_har->har;
1532
} else if(mtex->blendtype==MTEX_MUL) {
1533
shi->matren->har= (facmul+factt)*mat_har->har;
1535
shi->matren->har= 128.0*factt+mat_har->har;
1536
if(shi->matren->har<1) shi->matren->har= 1;
1538
mat_har= shi->matren;
1784
int flip= mtex->maptoneg & MAP_HAR;
1785
float har; // have to map to 0-1
1787
har= ((float)shi->har)/128.0;
1788
har= 128.0*texture_value_blend(mtex->def_var, har, texres.tin, mtex->varfac, mtex->blendtype, flip);
1790
if(har<1.0) shi->har= 1;
1791
else if(har>511.0) shi->har= 511;
1792
else shi->har= (int)har;
1540
1794
if(mtex->mapto & MAP_RAYMIRR) {
1541
if(mtex->maptoneg & MAP_RAYMIRR) {factt= facm; facmm= fact;}
1542
else {factt= fact; facmm= facm;}
1795
int flip= mtex->maptoneg & MAP_RAYMIRR;
1544
if(mtex->blendtype==MTEX_BLEND)
1545
shi->matren->ray_mirror= factt*mtex->def_var+ facmm*mat_ray_mirr->ray_mirror;
1546
else if(mtex->blendtype==MTEX_MUL)
1547
shi->matren->ray_mirror= (facmul+factt)*mat_ray_mirr->ray_mirror;
1549
shi->matren->ray_mirror= factt+mat_ray_mirr->ray_mirror;
1550
if(shi->matren->ray_mirror<0.0) shi->matren->ray_mirror= 0.0;
1551
else if(shi->matren->ray_mirror>1.0) shi->matren->ray_mirror= 1.0;
1553
mat_ray_mirr= shi->matren;
1797
shi->ray_mirror= texture_value_blend(mtex->def_var, shi->ray_mirror, texres.tin, mtex->varfac, mtex->blendtype, flip);
1798
if(shi->ray_mirror<0.0) shi->ray_mirror= 0.0;
1799
else if(shi->ray_mirror>1.0) shi->ray_mirror= 1.0;
1555
1801
if(mtex->mapto & MAP_TRANSLU) {
1556
if(mtex->maptoneg & MAP_TRANSLU) {factt= facm; facmm= fact;}
1557
else {factt= fact; facmm= facm;}
1802
int flip= mtex->maptoneg & MAP_TRANSLU;
1559
if(mtex->blendtype==MTEX_BLEND)
1560
shi->matren->translucency= factt*mtex->def_var+ facmm*mat_translu->translucency;
1561
else if(mtex->blendtype==MTEX_MUL)
1562
shi->matren->translucency= (facmul+factt)*mat_translu->translucency;
1564
shi->matren->translucency= factt+mat_translu->translucency;
1565
if(shi->matren->translucency<0.0) shi->matren->translucency= 0.0;
1566
else if(shi->matren->translucency>1.0) shi->matren->translucency= 1.0;
1568
mat_translu= shi->matren;
1804
shi->translucency= texture_value_blend(mtex->def_var, shi->translucency, texres.tin, mtex->varfac, mtex->blendtype, flip);
1805
if(shi->translucency<0.0) shi->translucency= 0.0;
1806
else if(shi->translucency>1.0) shi->translucency= 1.0;
1570
1808
if(mtex->mapto & MAP_AMB) {
1571
if(mtex->maptoneg & MAP_AMB) {factt= facm; facmm= fact;}
1572
else {factt= fact; facmm= facm;}
1809
int flip= mtex->maptoneg & MAP_AMB;
1574
if(mtex->blendtype==MTEX_BLEND)
1575
shi->matren->amb= factt*mtex->def_var+ facmm*mat_translu->amb;
1576
else if(mtex->blendtype==MTEX_MUL)
1577
shi->matren->amb= (facmul+factt)*mat_translu->amb;
1579
shi->matren->amb= factt+mat_translu->amb;
1580
if(shi->matren->amb<0.0) shi->matren->amb= 0.0;
1581
else if(shi->matren->amb>1.0) shi->matren->amb= 1.0;
1583
mat_amb= shi->matren;
1811
shi->amb= texture_value_blend(mtex->def_var, shi->amb, texres.tin, mtex->varfac, mtex->blendtype, flip);
1812
if(shi->amb<0.0) shi->amb= 0.0;
1813
else if(shi->amb>1.0) shi->amb= 1.0;
1624
1856
dxt[0]= mtex->size[0]*dx;
1625
1857
dyt[0]= mtex->size[0]*dx;
1859
else dxt[0]= dyt[0]= 0.0;
1628
1861
if(mtex->projy) {
1629
1862
dxt[1]= mtex->size[1]*dx;
1630
1863
dyt[1]= mtex->size[1]*dx;
1865
else dxt[1]= dyt[1]= 0.0;
1633
1867
if(mtex->projz) {
1871
else dxt[2]= dyt[2]= 0.0;
1641
1875
if(mtex->tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
1643
rgb= multitex(mtex->tex, texvec, dxt, dyt, osatex);
1877
rgb= multitex(mtex->tex, texvec, dxt, dyt, osatex, &texres);
1645
1879
/* texture output */
1646
1880
if(rgb && (mtex->texflag & MTEX_RGBTOINT)) {
1647
Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
1881
texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
1650
1884
if(mtex->texflag & MTEX_NEGATIVE) {
1886
texres.tr= 1.0-texres.tr;
1887
texres.tg= 1.0-texres.tg;
1888
texres.tb= 1.0-texres.tb;
1890
else texres.tin= 1.0-texres.tin;
1660
1894
if(mtex->mapto & MAP_COL) {
1667
1901
else if(mtex->mapto & MAP_ALPHA) {
1668
if(mtex->texflag & MTEX_ALPHAMIX) Tin= Ta;
1904
else texres.tin= texres.ta;
1673
fact= Tin*mtex->colfac;
1906
fact= texres.tin*mtex->colfac;
1674
1907
facm= 1.0-fact;
1676
1909
if(mtex->blendtype==MTEX_MUL) {
1677
1910
facm= 1.0-mtex->colfac;
1681
1913
if(mtex->blendtype==MTEX_SUB) fact= -fact;
1683
1915
if(mtex->blendtype==MTEX_BLEND) {
1684
colf[0]= (fact*Tr + facm*har->r);
1685
colf[1]= (fact*Tg + facm*har->g);
1686
colf[2]= (fact*Tb + facm*har->b);
1916
colf[0]= (fact*texres.tr + facm*har->r);
1917
colf[1]= (fact*texres.tg + facm*har->g);
1918
colf[2]= (fact*texres.tb + facm*har->b);
1688
1920
else if(mtex->blendtype==MTEX_MUL) {
1689
colf[0]= (facm+fact*Tr)*har->r;
1690
colf[1]= (facm+fact*Tg)*har->g;
1691
colf[2]= (facm+fact*Tb)*har->b;
1921
colf[0]= (facm+fact*texres.tr)*har->r;
1922
colf[1]= (facm+fact*texres.tg)*har->g;
1923
colf[2]= (facm+fact*texres.tb)*har->b;
1694
colf[0]= (fact*Tr + har->r);
1695
colf[1]= (fact*Tg + har->g);
1696
colf[2]= (fact*Tb + har->b);
1926
colf[0]= (fact*texres.tr + har->r);
1927
colf[1]= (fact*texres.tg + har->g);
1928
colf[2]= (fact*texres.tb + har->b);
1698
1930
CLAMP(colf[0], 0.0, 1.0);
1699
1931
CLAMP(colf[1], 0.0, 1.0);
1799
2029
if(mtex->tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
1801
rgb= multitex(mtex->tex, texvec, dxt, dyt, R.osa);
2031
rgb= multitex(mtex->tex, texvec, dxt, dyt, R.osa, &texres);
1803
2033
/* texture output */
1804
2034
if(rgb && (mtex->texflag & MTEX_RGBTOINT)) {
1805
Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
2035
texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
1808
2038
if(mtex->texflag & MTEX_NEGATIVE) {
2040
texres.tr= 1.0-texres.tr;
2041
texres.tg= 1.0-texres.tg;
2042
texres.tb= 1.0-texres.tb;
2044
else texres.tin= 1.0-texres.tin;
1816
2046
if(mtex->texflag & MTEX_STENCIL) {
2049
texres.ta*= stencilTin;
2054
texres.tin*= stencilTin;
1823
2055
stencilTin*= fact;
1828
else Tin*= stencilTin;
2059
if(rgb) texres.ta *= stencilTin;
2060
else texres.tin*= stencilTin;
1831
2063
/* colour mapping */
1832
2064
if(mtex->mapto & (WOMAP_HORIZ+WOMAP_ZENUP+WOMAP_ZENDOWN)) {
1841
fact= Tin*mtex->colfac;
1843
if(mtex->blendtype==MTEX_MUL) facm= 1.0-mtex->colfac;
1844
if(mtex->blendtype==MTEX_SUB) fact= -fact;
2072
else texres.tin= texres.ta;
2074
tcol[0]= texres.tr; tcol[1]= texres.tg; tcol[2]= texres.tb;
1846
2076
if(mtex->mapto & WOMAP_HORIZ) {
1847
if(mtex->blendtype==MTEX_BLEND) {
1848
R.wrld.horr= (fact*Tr + facm*wrld_hor->horr);
1849
R.wrld.horg= (fact*Tg + facm*wrld_hor->horg);
1850
R.wrld.horb= (fact*Tb + facm*wrld_hor->horb);
1852
else if(mtex->blendtype==MTEX_MUL) {
1853
R.wrld.horr= (facm+fact*Tr)*wrld_hor->horr;
1854
R.wrld.horg= (facm+fact*Tg)*wrld_hor->horg;
1855
R.wrld.horb= (facm+fact*Tb)*wrld_hor->horb;
1858
R.wrld.horr= (fact*Tr + wrld_hor->horr);
1859
R.wrld.horg= (fact*Tg + wrld_hor->horg);
1860
R.wrld.horb= (fact*Tb + wrld_hor->horb);
2077
texture_rgb_blend(hor, tcol, hor, texres.tin, mtex->colfac, mtex->blendtype);
1864
2079
if(mtex->mapto & (WOMAP_ZENUP+WOMAP_ZENDOWN)) {
1876
if(mtex->blendtype==MTEX_BLEND) {
1877
R.wrld.zenr= (fact*Tr + facm*wrld_zen->zenr);
1878
R.wrld.zeng= (fact*Tg + facm*wrld_zen->zeng);
1879
R.wrld.zenb= (fact*Tb + facm*wrld_zen->zenb);
1881
else if(mtex->blendtype==MTEX_MUL) {
1882
R.wrld.zenr= (facm+fact*Tr)*wrld_zen->zenr;
1883
R.wrld.zeng= (facm+fact*Tg)*wrld_zen->zeng;
1884
R.wrld.zenb= (facm+fact*Tb)*wrld_zen->zenb;
1887
R.wrld.zenr= (fact*Tr + wrld_zen->zenr);
1888
R.wrld.zeng= (fact*Tg + wrld_zen->zeng);
1889
R.wrld.zenb= (fact*Tb + wrld_zen->zenb);
1894
/* otherwise zenRGB undefined */
1895
R.wrld.zenr= wrld_zen->zenr;
1896
R.wrld.zeng= wrld_zen->zeng;
1897
R.wrld.zenb= wrld_zen->zenb;
2090
texture_rgb_blend(zen, tcol, zen, texres.tin, mtex->colfac, mtex->blendtype);
1901
2094
if(mtex->mapto & WOMAP_BLEND) {
1902
if(rgb) Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
1904
fact= Tin*mtex->varfac;
1906
if(mtex->blendtype==MTEX_MUL) facmul= 1.0-mtex->varfac;
1907
if(mtex->blendtype==MTEX_SUB) fact= -fact;
1909
factt= fact; facmm= facm;
1911
if(mtex->blendtype==MTEX_BLEND)
1912
R.inprz= factt*mtex->def_var+ facmm*R.inprz;
1913
else if(mtex->blendtype==MTEX_MUL)
1914
R.inprz= (facmul+factt)*R.inprz;
1916
R.inprz= factt+R.inprz;
2095
if(rgb) texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
2097
*blend= texture_value_blend(mtex->def_var, *blend, texres.tin, mtex->varfac, mtex->blendtype, 0);
1923
2103
/* ------------------------------------------------------------------------- */
1924
/* explicit lampren stuff should be factored out! or rather, the
1925
texturing stuff might need to go...*/
1926
void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi)
2104
/* colf supposed to be initialized with la->r,g,b */
2106
void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf)
1932
float *co = NULL, *dx = NULL, *dy = NULL, fact, facm, stencilTin=1.0;
2112
float *co = NULL, *dx = NULL, *dy = NULL, fact, stencilTin=1.0;
1933
2113
float texvec[3], dxt[3], dyt[3], tempvec[3];
1934
2114
int tex_nr, rgb= 0;
1940
for(; tex_nr<6; tex_nr++) {
2118
for(; tex_nr<MAX_MTEX; tex_nr++) {
1942
2120
if(la->mtex[tex_nr]) {
1943
2121
mtex= la->mtex[tex_nr];
1945
2123
tex= mtex->tex;
1946
if(tex==0) continue;
2124
if(tex==NULL) continue;
1949
2127
/* which coords */
1950
2128
if(mtex->texco==TEXCO_OBJECT) {
2028
2208
do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
2031
rgb= multitex(tex, texvec, dxt, dyt, shi->osatex);
2211
rgb= multitex(tex, texvec, dxt, dyt, shi->osatex, &texres);
2033
2213
/* texture output */
2034
2214
if(rgb && (mtex->texflag & MTEX_RGBTOINT)) {
2035
Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
2215
texres.tin= (0.35*texres.tr+0.45*texres.tg+0.2*texres.tb);
2038
2218
if(mtex->texflag & MTEX_NEGATIVE) {
2220
texres.tr= 1.0-texres.tr;
2221
texres.tg= 1.0-texres.tg;
2222
texres.tb= 1.0-texres.tb;
2224
else texres.tin= 1.0-texres.tin;
2046
2226
if(mtex->texflag & MTEX_STENCIL) {
2229
texres.ta*= stencilTin;
2050
2230
stencilTin*= fact;
2234
texres.tin*= stencilTin;
2055
2235
stencilTin*= fact;
2059
if(rgb) Ta*= stencilTin;
2060
else Tin*= stencilTin;
2239
if(rgb) texres.ta*= stencilTin;
2240
else texres.tin*= stencilTin;
2064
2244
if(mtex->mapto & LAMAP_COL) {
2071
2252
else if(mtex->mapto & MAP_ALPHA) {
2072
if(mtex->texflag & MTEX_ALPHAMIX) Tin= Ta;
2073
else Tin= stencilTin;
2081
fact= Tin*mtex->colfac;
2083
if(mtex->blendtype==MTEX_MUL) facm= 1.0-mtex->colfac;
2084
if(mtex->blendtype==MTEX_SUB) fact= -fact;
2086
if(mtex->blendtype==MTEX_BLEND) {
2087
la->r= (fact*Tr + facm*la_col->r);
2088
la->g= (fact*Tg + facm*la_col->g);
2089
la->b= (fact*Tb + facm*la_col->b);
2091
else if(mtex->blendtype==MTEX_MUL) {
2092
la->r= (facm+fact*Tr)*la_col->r;
2093
la->g= (facm+fact*Tg)*la_col->g;
2094
la->b= (facm+fact*Tb)*la_col->b;
2097
la->r= (fact*Tr + la_col->r);
2098
la->g= (fact*Tg + la_col->g);
2099
la->b= (fact*Tb + la_col->b);
2101
la_col= la; /* makes sure first run uses la->org, then la */
2253
texres.tin= stencilTin;
2255
else texres.tin= texres.ta;
2257
/* lamp colors were premultiplied with this */
2258
col[0]= texres.tr*la->energy;
2259
col[1]= texres.tg*la->energy;
2260
col[2]= texres.tb*la->energy;
2262
texture_rgb_blend(colf, col, colf, texres.tin, mtex->colfac, mtex->blendtype);
2108
2268
/* ------------------------------------------------------------------------- */
2110
void externtex(MTex *mtex, float *vec)
2270
void externtex(MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta)
2113
float dxt[3], dyt[3], texvec[3], dummy[3];
2274
float dxt[3], dyt[3], texvec[3];
2116
2277
tex= mtex->tex;
2278
if(tex==NULL) return;
2119
2281
/* placement */
2120
2282
if(mtex->projx) texvec[0]= mtex->size[0]*(vec[mtex->projx-1]+mtex->ofs[0]);
2130
2292
if(tex->type==TEX_IMAGE) {
2131
2293
do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
2133
if(mtex->mapto & MAP_NORM) {
2134
/* the pointer defines if there's bump */
2136
if(mtex->maptoneg & MAP_NORM) tex->norfac= -mtex->norfac;
2137
else tex->norfac= mtex->norfac;
2139
else tex->nor= NULL;
2142
rgb= multitex(tex, texvec, dxt, dyt, 0);
2296
rgb= multitex(tex, texvec, dxt, dyt, 0, &texr);
2145
Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
2299
texr.tin= (0.35*texr.tr+0.45*texr.tg+0.2*texr.tb);
2154
/* ------------------------------------------------------------------------- */
2156
void externtexcol(MTex *mtex, float *orco, char *col)
2161
if(mtex->tex==0) return;
2163
externtex(mtex, orco);
2167
temp= 255*(Tin*Tr)+b1*col[0];
2168
if(temp>255) col[0]= 255; else col[0]= temp;
2169
temp= 255*(Tin*Tg)+b1*col[1];
2170
if(temp>255) col[1]= 255; else col[1]= temp;
2171
temp= 255*(Tin*Tb)+b1*col[2];
2172
if(temp>255) col[2]= 255; else col[2]= temp;
2176
2315
/* ------------------------------------------------------------------------- */
2178
2317
void render_realtime_texture(ShadeInput *shi)
2321
static Tex tex1, tex2; // threadsafe
2181
2322
static int firsttime= 1;
2182
2324
float texvec[2], dx[2], dy[2];
2184
2326
if(firsttime) {
2186
tex.type= TEX_IMAGE;
2330
tex1.type= TEX_IMAGE;
2331
tex2.type= TEX_IMAGE;
2190
tex.ima = shi->vlr->tface->tpage;
2334
if(((int)(shi->ys+0.5)) & 1) tex= &tex1; else tex= &tex2; // threadsafe
2336
ima = shi->vlr->tface->tpage;
2193
2339
texvec[0]= 0.5+0.5*shi->uv[0];
2194
2340
texvec[1]= 0.5+0.5*shi->uv[1];
2195
2341
if(shi->osatex) {
2196
dx[0]= 0.5*O.dxuv[0];
2197
dx[1]= 0.5*O.dxuv[1];
2198
dy[0]= 0.5*O.dyuv[0];
2199
dy[1]= 0.5*O.dyuv[1];
2342
dx[0]= 0.5*shi->dxuv[0];
2343
dx[1]= 0.5*shi->dxuv[1];
2344
dy[0]= 0.5*shi->dyuv[0];
2345
dy[1]= 0.5*shi->dyuv[1];
2202
if(shi->osatex) imagewraposa(&tex, texvec, dx, dy);
2203
else imagewrap(&tex, texvec);
2350
if(shi->osatex) imagewraposa(tex, ima, texvec, dx, dy, &texr);
2351
else imagewrap(tex, ima, texvec, &texr);
2353
shi->vcol[0]*= texr.tr;
2354
shi->vcol[1]*= texr.tg;
2355
shi->vcol[2]*= texr.tb;