Blender  V2.93
texture_procedural.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include <math.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 
29 #include "BLI_math.h"
30 #include "BLI_noise.h"
31 #include "BLI_rand.h"
32 #include "BLI_utildefines.h"
33 
34 #include "DNA_anim_types.h"
35 #include "DNA_image_types.h"
36 #include "DNA_light_types.h"
37 #include "DNA_material_types.h"
38 #include "DNA_meshdata_types.h"
39 #include "DNA_node_types.h"
40 #include "DNA_object_types.h"
41 #include "DNA_texture_types.h"
42 
43 #include "IMB_colormanagement.h"
44 #include "IMB_imbuf_types.h"
45 
46 #include "BKE_image.h"
47 #include "BKE_node.h"
48 
49 #include "BKE_colorband.h"
50 #include "BKE_material.h"
51 #include "BKE_scene.h"
52 
53 #include "BKE_texture.h"
54 
55 #include "MEM_guardedalloc.h"
56 
57 #include "render_types.h"
58 #include "texture_common.h"
59 
60 #include "RE_texture.h"
61 
63 
65 {
67 }
68 
70 {
71  if (random_tex_array == NULL) {
72  return;
73  }
76 }
77 
78 /* ------------------------------------------------------------------------- */
79 
80 /* This allows color-banded textures to control normals as well. */
81 static void tex_normal_derivate(const Tex *tex, TexResult *texres)
82 {
83  if (tex->flag & TEX_COLORBAND) {
84  float col[4];
85  if (BKE_colorband_evaluate(tex->coba, texres->tin, col)) {
86  float fac0, fac1, fac2, fac3;
87 
88  fac0 = (col[0] + col[1] + col[2]);
89  BKE_colorband_evaluate(tex->coba, texres->nor[0], col);
90  fac1 = (col[0] + col[1] + col[2]);
91  BKE_colorband_evaluate(tex->coba, texres->nor[1], col);
92  fac2 = (col[0] + col[1] + col[2]);
93  BKE_colorband_evaluate(tex->coba, texres->nor[2], col);
94  fac3 = (col[0] + col[1] + col[2]);
95 
96  texres->nor[0] = (fac0 - fac1) / 3.0f;
97  texres->nor[1] = (fac0 - fac2) / 3.0f;
98  texres->nor[2] = (fac0 - fac3) / 3.0f;
99 
100  return;
101  }
102  }
103  texres->nor[0] = texres->tin - texres->nor[0];
104  texres->nor[1] = texres->tin - texres->nor[1];
105  texres->nor[2] = texres->tin - texres->nor[2];
106 }
107 
108 static int blend(const Tex *tex, const float texvec[3], TexResult *texres)
109 {
110  float x, y, t;
111 
112  if (tex->flag & TEX_FLIPBLEND) {
113  x = texvec[1];
114  y = texvec[0];
115  }
116  else {
117  x = texvec[0];
118  y = texvec[1];
119  }
120 
121  if (tex->stype == TEX_LIN) { /* lin */
122  texres->tin = (1.0f + x) / 2.0f;
123  }
124  else if (tex->stype == TEX_QUAD) { /* quad */
125  texres->tin = (1.0f + x) / 2.0f;
126  if (texres->tin < 0.0f) {
127  texres->tin = 0.0f;
128  }
129  else {
130  texres->tin *= texres->tin;
131  }
132  }
133  else if (tex->stype == TEX_EASE) { /* ease */
134  texres->tin = (1.0f + x) / 2.0f;
135  if (texres->tin <= 0.0f) {
136  texres->tin = 0.0f;
137  }
138  else if (texres->tin >= 1.0f) {
139  texres->tin = 1.0f;
140  }
141  else {
142  t = texres->tin * texres->tin;
143  texres->tin = (3.0f * t - 2.0f * t * texres->tin);
144  }
145  }
146  else if (tex->stype == TEX_DIAG) { /* diag */
147  texres->tin = (2.0f + x + y) / 4.0f;
148  }
149  else if (tex->stype == TEX_RAD) { /* radial */
150  texres->tin = (atan2f(y, x) / (float)(2 * M_PI) + 0.5f);
151  }
152  else { /* sphere TEX_SPHERE */
153  texres->tin = 1.0f - sqrtf(x * x + y * y + texvec[2] * texvec[2]);
154  if (texres->tin < 0.0f) {
155  texres->tin = 0.0f;
156  }
157  if (tex->stype == TEX_HALO) {
158  texres->tin *= texres->tin; /* halo */
159  }
160  }
161 
162  BRICONT;
163 
164  return TEX_INT;
165 }
166 
167 /* ------------------------------------------------------------------------- */
168 /* ************************************************************************* */
169 
170 /* newnoise: all noise-based types now have different noise-bases to choose from. */
171 
172 static int clouds(const Tex *tex, const float texvec[3], TexResult *texres)
173 {
174  int rv = TEX_INT;
175 
177  texvec[0],
178  texvec[1],
179  texvec[2],
180  tex->noisedepth,
182  tex->noisebasis);
183 
184  if (texres->nor != NULL) {
185  /* calculate bumpnormal */
187  texvec[0] + tex->nabla,
188  texvec[1],
189  texvec[2],
190  tex->noisedepth,
192  tex->noisebasis);
194  texvec[0],
195  texvec[1] + tex->nabla,
196  texvec[2],
197  tex->noisedepth,
199  tex->noisebasis);
201  texvec[0],
202  texvec[1],
203  texvec[2] + tex->nabla,
204  tex->noisedepth,
206  tex->noisebasis);
207 
208  tex_normal_derivate(tex, texres);
209  rv |= TEX_NOR;
210  }
211 
212  if (tex->stype == TEX_COLOR) {
213  /* in this case, int. value should really be computed from color,
214  * and bumpnormal from that, would be too slow, looks ok as is */
215  texres->tr = texres->tin;
217  texvec[1],
218  texvec[0],
219  texvec[2],
220  tex->noisedepth,
222  tex->noisebasis);
224  texvec[1],
225  texvec[2],
226  texvec[0],
227  tex->noisedepth,
229  tex->noisebasis);
230  BRICONTRGB;
231  texres->ta = 1.0;
232  return (rv | TEX_RGB);
233  }
234 
235  BRICONT;
236 
237  return rv;
238 }
239 
240 /* creates a sine wave */
241 static float tex_sin(float a)
242 {
243  a = 0.5f + 0.5f * sinf(a);
244 
245  return a;
246 }
247 
248 /* creates a saw wave */
249 static float tex_saw(float a)
250 {
251  const float b = 2 * M_PI;
252 
253  int n = (int)(a / b);
254  a -= n * b;
255  if (a < 0) {
256  a += b;
257  }
258  return a / b;
259 }
260 
261 /* creates a triangle wave */
262 static float tex_tri(float a)
263 {
264  const float b = 2 * M_PI;
265  const float rmax = 1.0;
266 
267  a = rmax - 2.0f * fabsf(floorf((a * (1.0f / b)) + 0.5f) - (a * (1.0f / b)));
268 
269  return a;
270 }
271 
272 /* computes basic wood intensity value at x,y,z */
273 static float wood_int(const Tex *tex, float x, float y, float z)
274 {
275  float wi = 0;
276  /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
277  short wf = tex->noisebasis2;
278  /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
279  short wt = tex->stype;
280 
281  float (*waveform[3])(float); /* create array of pointers to waveform functions */
282  waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
283  waveform[1] = tex_saw;
284  waveform[2] = tex_tri;
285 
286  if ((wf > TEX_TRI) || (wf < TEX_SIN)) {
287  wf = 0; /* check to be sure noisebasis2 is initialized ahead of time */
288  }
289 
290  if (wt == TEX_BAND) {
291  wi = waveform[wf]((x + y + z) * 10.0f);
292  }
293  else if (wt == TEX_RING) {
294  wi = waveform[wf](sqrtf(x * x + y * y + z * z) * 20.0f);
295  }
296  else if (wt == TEX_BANDNOISE) {
297  wi = tex->turbul *
300  wi = waveform[wf]((x + y + z) * 10.0f + wi);
301  }
302  else if (wt == TEX_RINGNOISE) {
303  wi = tex->turbul *
306  wi = waveform[wf](sqrtf(x * x + y * y + z * z) * 20.0f + wi);
307  }
308 
309  return wi;
310 }
311 
312 static int wood(const Tex *tex, const float texvec[3], TexResult *texres)
313 {
314  int rv = TEX_INT;
315 
316  texres->tin = wood_int(tex, texvec[0], texvec[1], texvec[2]);
317  if (texres->nor != NULL) {
318  /* calculate bumpnormal */
319  texres->nor[0] = wood_int(tex, texvec[0] + tex->nabla, texvec[1], texvec[2]);
320  texres->nor[1] = wood_int(tex, texvec[0], texvec[1] + tex->nabla, texvec[2]);
321  texres->nor[2] = wood_int(tex, texvec[0], texvec[1], texvec[2] + tex->nabla);
322 
323  tex_normal_derivate(tex, texres);
324  rv |= TEX_NOR;
325  }
326 
327  BRICONT;
328 
329  return rv;
330 }
331 
332 /* computes basic marble intensity at x,y,z */
333 static float marble_int(const Tex *tex, float x, float y, float z)
334 {
335  float n, mi;
336  short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
337  short mt = tex->stype; /* marble type: TEX_SOFT=0, TEX_SHARP=1, TEX_SHAPER=2 */
338 
339  float (*waveform[3])(float); /* create array of pointers to waveform functions */
340  waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
341  waveform[1] = tex_saw;
342  waveform[2] = tex_tri;
343 
344  if ((wf > TEX_TRI) || (wf < TEX_SIN)) {
345  wf = 0; /* check to be sure noisebasis2 isn't initialized ahead of time */
346  }
347 
348  n = 5.0f * (x + y + z);
349 
351  x,
352  y,
353  z,
354  tex->noisedepth,
356  tex->noisebasis);
357 
358  if (mt >= TEX_SOFT) { /* TEX_SOFT always true */
359  mi = waveform[wf](mi);
360  if (mt == TEX_SHARP) {
361  mi = sqrtf(mi);
362  }
363  else if (mt == TEX_SHARPER) {
364  mi = sqrtf(sqrtf(mi));
365  }
366  }
367 
368  return mi;
369 }
370 
371 static int marble(const Tex *tex, const float texvec[3], TexResult *texres)
372 {
373  int rv = TEX_INT;
374 
375  texres->tin = marble_int(tex, texvec[0], texvec[1], texvec[2]);
376 
377  if (texres->nor != NULL) {
378  /* calculate bumpnormal */
379  texres->nor[0] = marble_int(tex, texvec[0] + tex->nabla, texvec[1], texvec[2]);
380  texres->nor[1] = marble_int(tex, texvec[0], texvec[1] + tex->nabla, texvec[2]);
381  texres->nor[2] = marble_int(tex, texvec[0], texvec[1], texvec[2] + tex->nabla);
382 
383  tex_normal_derivate(tex, texres);
384 
385  rv |= TEX_NOR;
386  }
387 
388  BRICONT;
389 
390  return rv;
391 }
392 
393 /* ------------------------------------------------------------------------- */
394 
395 static int magic(const Tex *tex, const float texvec[3], TexResult *texres)
396 {
397  float x, y, z, turb;
398  int n;
399 
400  n = tex->noisedepth;
401  turb = tex->turbul / 5.0f;
402 
403  x = sinf((texvec[0] + texvec[1] + texvec[2]) * 5.0f);
404  y = cosf((-texvec[0] + texvec[1] - texvec[2]) * 5.0f);
405  z = -cosf((-texvec[0] - texvec[1] + texvec[2]) * 5.0f);
406  if (n > 0) {
407  x *= turb;
408  y *= turb;
409  z *= turb;
410  y = -cosf(x - y + z);
411  y *= turb;
412  if (n > 1) {
413  x = cosf(x - y - z);
414  x *= turb;
415  if (n > 2) {
416  z = sinf(-x - y - z);
417  z *= turb;
418  if (n > 3) {
419  x = -cosf(-x + y - z);
420  x *= turb;
421  if (n > 4) {
422  y = -sinf(-x + y + z);
423  y *= turb;
424  if (n > 5) {
425  y = -cosf(-x + y + z);
426  y *= turb;
427  if (n > 6) {
428  x = cosf(x + y + z);
429  x *= turb;
430  if (n > 7) {
431  z = sinf(x + y - z);
432  z *= turb;
433  if (n > 8) {
434  x = -cosf(-x - y + z);
435  x *= turb;
436  if (n > 9) {
437  y = -sinf(x - y + z);
438  y *= turb;
439  }
440  }
441  }
442  }
443  }
444  }
445  }
446  }
447  }
448  }
449 
450  if (turb != 0.0f) {
451  turb *= 2.0f;
452  x /= turb;
453  y /= turb;
454  z /= turb;
455  }
456  texres->tr = 0.5f - x;
457  texres->tg = 0.5f - y;
458  texres->tb = 0.5f - z;
459 
460  texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb);
461 
462  BRICONTRGB;
463  texres->ta = 1.0f;
464 
465  return TEX_RGB;
466 }
467 
468 /* ------------------------------------------------------------------------- */
469 
470 /* newnoise: stucci also modified to use different noisebasis */
471 static int stucci(const Tex *tex, const float texvec[3], TexResult *texres)
472 {
473  float nor[3], b2, ofs;
474  int retval = TEX_INT;
475 
477  texvec[0],
478  texvec[1],
479  texvec[2],
481  tex->noisebasis);
482 
483  ofs = tex->turbul / 200.0f;
484 
485  if (tex->stype) {
486  ofs *= (b2 * b2);
487  }
489  texvec[0] + ofs,
490  texvec[1],
491  texvec[2],
493  tex->noisebasis);
495  texvec[0],
496  texvec[1] + ofs,
497  texvec[2],
499  tex->noisebasis);
501  texvec[0],
502  texvec[1],
503  texvec[2] + ofs,
505  tex->noisebasis);
506 
507  texres->tin = nor[2];
508 
509  if (texres->nor) {
510 
511  copy_v3_v3(texres->nor, nor);
512  tex_normal_derivate(tex, texres);
513 
514  if (tex->stype == TEX_WALLOUT) {
515  texres->nor[0] = -texres->nor[0];
516  texres->nor[1] = -texres->nor[1];
517  texres->nor[2] = -texres->nor[2];
518  }
519 
520  retval |= TEX_NOR;
521  }
522 
523  if (tex->stype == TEX_WALLOUT) {
524  texres->tin = 1.0f - texres->tin;
525  }
526 
527  if (texres->tin < 0.0f) {
528  texres->tin = 0.0f;
529  }
530 
531  return retval;
532 }
533 
534 /* ------------------------------------------------------------------------- */
535 /* newnoise: musgrave terrain noise types */
536 
537 static int mg_mFractalOrfBmTex(const Tex *tex, const float texvec[3], TexResult *texres)
538 {
539  int rv = TEX_INT;
540  float (*mgravefunc)(float, float, float, float, float, float, int);
541 
542  if (tex->stype == TEX_MFRACTAL) {
543  mgravefunc = BLI_noise_mg_multi_fractal;
544  }
545  else {
546  mgravefunc = BLI_noise_mg_fbm;
547  }
548 
549  texres->tin = tex->ns_outscale * mgravefunc(texvec[0],
550  texvec[1],
551  texvec[2],
552  tex->mg_H,
554  tex->mg_octaves,
555  tex->noisebasis);
556 
557  if (texres->nor != NULL) {
558  float ofs = tex->nabla / tex->noisesize; /* also scaling of texvec */
559 
560  /* calculate bumpnormal */
561  texres->nor[0] = tex->ns_outscale * mgravefunc(texvec[0] + ofs,
562  texvec[1],
563  texvec[2],
564  tex->mg_H,
566  tex->mg_octaves,
567  tex->noisebasis);
568  texres->nor[1] = tex->ns_outscale * mgravefunc(texvec[0],
569  texvec[1] + ofs,
570  texvec[2],
571  tex->mg_H,
573  tex->mg_octaves,
574  tex->noisebasis);
575  texres->nor[2] = tex->ns_outscale * mgravefunc(texvec[0],
576  texvec[1],
577  texvec[2] + ofs,
578  tex->mg_H,
580  tex->mg_octaves,
581  tex->noisebasis);
582 
583  tex_normal_derivate(tex, texres);
584  rv |= TEX_NOR;
585  }
586 
587  BRICONT;
588 
589  return rv;
590 }
591 
592 static int mg_ridgedOrHybridMFTex(const Tex *tex, const float texvec[3], TexResult *texres)
593 {
594  int rv = TEX_INT;
595  float (*mgravefunc)(float, float, float, float, float, float, float, float, int);
596 
597  if (tex->stype == TEX_RIDGEDMF) {
599  }
600  else {
602  }
603 
604  texres->tin = tex->ns_outscale * mgravefunc(texvec[0],
605  texvec[1],
606  texvec[2],
607  tex->mg_H,
609  tex->mg_octaves,
610  tex->mg_offset,
611  tex->mg_gain,
612  tex->noisebasis);
613 
614  if (texres->nor != NULL) {
615  float ofs = tex->nabla / tex->noisesize; /* also scaling of texvec */
616 
617  /* calculate bumpnormal */
618  texres->nor[0] = tex->ns_outscale * mgravefunc(texvec[0] + ofs,
619  texvec[1],
620  texvec[2],
621  tex->mg_H,
623  tex->mg_octaves,
624  tex->mg_offset,
625  tex->mg_gain,
626  tex->noisebasis);
627  texres->nor[1] = tex->ns_outscale * mgravefunc(texvec[0],
628  texvec[1] + ofs,
629  texvec[2],
630  tex->mg_H,
632  tex->mg_octaves,
633  tex->mg_offset,
634  tex->mg_gain,
635  tex->noisebasis);
636  texres->nor[2] = tex->ns_outscale * mgravefunc(texvec[0],
637  texvec[1],
638  texvec[2] + ofs,
639  tex->mg_H,
641  tex->mg_octaves,
642  tex->mg_offset,
643  tex->mg_gain,
644  tex->noisebasis);
645 
646  tex_normal_derivate(tex, texres);
647  rv |= TEX_NOR;
648  }
649 
650  BRICONT;
651 
652  return rv;
653 }
654 
655 static int mg_HTerrainTex(const Tex *tex, const float texvec[3], TexResult *texres)
656 {
657  int rv = TEX_INT;
658 
659  texres->tin = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0],
660  texvec[1],
661  texvec[2],
662  tex->mg_H,
664  tex->mg_octaves,
665  tex->mg_offset,
666  tex->noisebasis);
667 
668  if (texres->nor != NULL) {
669  float ofs = tex->nabla / tex->noisesize; /* also scaling of texvec */
670 
671  /* calculate bumpnormal */
672  texres->nor[0] = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0] + ofs,
673  texvec[1],
674  texvec[2],
675  tex->mg_H,
677  tex->mg_octaves,
678  tex->mg_offset,
679  tex->noisebasis);
680  texres->nor[1] = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0],
681  texvec[1] + ofs,
682  texvec[2],
683  tex->mg_H,
685  tex->mg_octaves,
686  tex->mg_offset,
687  tex->noisebasis);
688  texres->nor[2] = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0],
689  texvec[1],
690  texvec[2] + ofs,
691  tex->mg_H,
693  tex->mg_octaves,
694  tex->mg_offset,
695  tex->noisebasis);
696 
697  tex_normal_derivate(tex, texres);
698  rv |= TEX_NOR;
699  }
700 
701  BRICONT;
702 
703  return rv;
704 }
705 
706 static int mg_distNoiseTex(const Tex *tex, const float texvec[3], TexResult *texres)
707 {
708  int rv = TEX_INT;
709 
711  texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
712 
713  if (texres->nor != NULL) {
714  float ofs = tex->nabla / tex->noisesize; /* also scaling of texvec */
715 
716  /* calculate bumpnormal */
717  texres->nor[0] = BLI_noise_mg_variable_lacunarity(texvec[0] + ofs,
718  texvec[1],
719  texvec[2],
720  tex->dist_amount,
721  tex->noisebasis,
722  tex->noisebasis2);
723  texres->nor[1] = BLI_noise_mg_variable_lacunarity(texvec[0],
724  texvec[1] + ofs,
725  texvec[2],
726  tex->dist_amount,
727  tex->noisebasis,
728  tex->noisebasis2);
729  texres->nor[2] = BLI_noise_mg_variable_lacunarity(texvec[0],
730  texvec[1],
731  texvec[2] + ofs,
732  tex->dist_amount,
733  tex->noisebasis,
734  tex->noisebasis2);
735 
736  tex_normal_derivate(tex, texres);
737  rv |= TEX_NOR;
738  }
739 
740  BRICONT;
741 
742  return rv;
743 }
744 
745 /* ------------------------------------------------------------------------- */
746 /* newnoise: Voronoi texture type
747  *
748  * probably the slowest, especially with minkovsky, bumpmapping, could be done another way.
749  */
750 
751 static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres)
752 {
753  int rv = TEX_INT;
754  float da[4], pa[12]; /* distance and point coordinate arrays of 4 nearest neighbors */
755  float aw1 = fabsf(tex->vn_w1);
756  float aw2 = fabsf(tex->vn_w2);
757  float aw3 = fabsf(tex->vn_w3);
758  float aw4 = fabsf(tex->vn_w4);
759  float sc = (aw1 + aw2 + aw3 + aw4);
760  if (sc != 0.0f) {
761  sc = tex->ns_outscale / sc;
762  }
763 
764  BLI_noise_voronoi(texvec[0], texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
765  texres->tin = sc * fabsf(dot_v4v4(&tex->vn_w1, da));
766 
767  if (tex->vn_coltype) {
768  float ca[3]; /* cell color */
769  BLI_noise_cell_v3(pa[0], pa[1], pa[2], ca);
770  texres->tr = aw1 * ca[0];
771  texres->tg = aw1 * ca[1];
772  texres->tb = aw1 * ca[2];
773  BLI_noise_cell_v3(pa[3], pa[4], pa[5], ca);
774  texres->tr += aw2 * ca[0];
775  texres->tg += aw2 * ca[1];
776  texres->tb += aw2 * ca[2];
777  BLI_noise_cell_v3(pa[6], pa[7], pa[8], ca);
778  texres->tr += aw3 * ca[0];
779  texres->tg += aw3 * ca[1];
780  texres->tb += aw3 * ca[2];
781  BLI_noise_cell_v3(pa[9], pa[10], pa[11], ca);
782  texres->tr += aw4 * ca[0];
783  texres->tg += aw4 * ca[1];
784  texres->tb += aw4 * ca[2];
785  if (tex->vn_coltype >= 2) {
786  float t1 = (da[1] - da[0]) * 10;
787  if (t1 > 1) {
788  t1 = 1;
789  }
790  if (tex->vn_coltype == 3) {
791  t1 *= texres->tin;
792  }
793  else {
794  t1 *= sc;
795  }
796  texres->tr *= t1;
797  texres->tg *= t1;
798  texres->tb *= t1;
799  }
800  else {
801  texres->tr *= sc;
802  texres->tg *= sc;
803  texres->tb *= sc;
804  }
805  }
806 
807  if (texres->nor != NULL) {
808  float ofs = tex->nabla / tex->noisesize; /* also scaling of texvec */
809 
810  /* calculate bumpnormal */
811  BLI_noise_voronoi(texvec[0] + ofs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
812  texres->nor[0] = sc * fabsf(dot_v4v4(&tex->vn_w1, da));
813  BLI_noise_voronoi(texvec[0], texvec[1] + ofs, texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
814  texres->nor[1] = sc * fabsf(dot_v4v4(&tex->vn_w1, da));
815  BLI_noise_voronoi(texvec[0], texvec[1], texvec[2] + ofs, da, pa, tex->vn_mexp, tex->vn_distm);
816  texres->nor[2] = sc * fabsf(dot_v4v4(&tex->vn_w1, da));
817 
818  tex_normal_derivate(tex, texres);
819  rv |= TEX_NOR;
820  }
821 
822  if (tex->vn_coltype) {
823  BRICONTRGB;
824  texres->ta = 1.0;
825  return (rv | TEX_RGB);
826  }
827 
828  BRICONT;
829 
830  return rv;
831 }
832 
833 /* ------------------------------------------------------------------------- */
834 
835 static int texnoise(const Tex *tex, TexResult *texres, int thread)
836 {
837  float div = 3.0;
838  int val, ran, loop, shift = 29;
839 
841 
842  loop = tex->noisedepth;
843 
844  /* start from top bits since they have more variance */
845  val = ((ran >> shift) & 3);
846 
847  while (loop--) {
848  shift -= 2;
849  val *= ((ran >> shift) & 3);
850  div *= 3.0f;
851  }
852 
853  texres->tin = ((float)val) / div;
854 
855  BRICONT;
856  return TEX_INT;
857 }
858 
859 /* ------------------------------------------------------------------------- */
860 
861 static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1, float *adr2)
862 {
863  float x1, y1, z1, nor[3];
864  int ret;
865 
866  if (n == NULL) {
867  nor[0] = x;
868  nor[1] = y;
869  nor[2] = z; /* use local render coord */
870  }
871  else {
872  copy_v3_v3(nor, n);
873  }
874 
875  x1 = fabsf(nor[0]);
876  y1 = fabsf(nor[1]);
877  z1 = fabsf(nor[2]);
878 
879  if (z1 >= x1 && z1 >= y1) {
880  *adr1 = (x + 1.0f) / 2.0f;
881  *adr2 = (y + 1.0f) / 2.0f;
882  ret = 0;
883  }
884  else if (y1 >= x1 && y1 >= z1) {
885  *adr1 = (x + 1.0f) / 2.0f;
886  *adr2 = (z + 1.0f) / 2.0f;
887  ret = 1;
888  }
889  else {
890  *adr1 = (y + 1.0f) / 2.0f;
891  *adr2 = (z + 1.0f) / 2.0f;
892  ret = 2;
893  }
894  return ret;
895 }
896 
897 /* ------------------------------------------------------------------------- */
898 
899 static void do_2d_mapping(
900  const MTex *mtex, float texvec[3], const float n[3], float dxt[3], float dyt[3])
901 {
902  Tex *tex;
903  float fx, fy, fac1, area[8];
904  int ok, proj, areaflag = 0, wrap;
905 
906  /* #MTex variables localized, only cube-map doesn't cooperate yet. */
907  wrap = mtex->mapping;
908  tex = mtex->tex;
909 
910  if (!(dxt && dyt)) {
911 
912  if (wrap == MTEX_FLAT) {
913  fx = (texvec[0] + 1.0f) / 2.0f;
914  fy = (texvec[1] + 1.0f) / 2.0f;
915  }
916  else if (wrap == MTEX_TUBE) {
917  map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
918  }
919  else if (wrap == MTEX_SPHERE) {
920  map_to_sphere(&fx, &fy, texvec[0], texvec[1], texvec[2]);
921  }
922  else {
923  cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
924  }
925 
926  /* repeat */
927  if (tex->extend == TEX_REPEAT) {
928  if (tex->xrepeat > 1) {
929  float origf = fx *= tex->xrepeat;
930 
931  if (fx > 1.0f) {
932  fx -= (int)(fx);
933  }
934  else if (fx < 0.0f) {
935  fx += 1 - (int)(fx);
936  }
937 
938  if (tex->flag & TEX_REPEAT_XMIR) {
939  int orig = (int)floor(origf);
940  if (orig & 1) {
941  fx = 1.0f - fx;
942  }
943  }
944  }
945  if (tex->yrepeat > 1) {
946  float origf = fy *= tex->yrepeat;
947 
948  if (fy > 1.0f) {
949  fy -= (int)(fy);
950  }
951  else if (fy < 0.0f) {
952  fy += 1 - (int)(fy);
953  }
954 
955  if (tex->flag & TEX_REPEAT_YMIR) {
956  int orig = (int)floor(origf);
957  if (orig & 1) {
958  fy = 1.0f - fy;
959  }
960  }
961  }
962  }
963  /* crop */
964  if (tex->cropxmin != 0.0f || tex->cropxmax != 1.0f) {
965  fac1 = tex->cropxmax - tex->cropxmin;
966  fx = tex->cropxmin + fx * fac1;
967  }
968  if (tex->cropymin != 0.0f || tex->cropymax != 1.0f) {
969  fac1 = tex->cropymax - tex->cropymin;
970  fy = tex->cropymin + fy * fac1;
971  }
972 
973  texvec[0] = fx;
974  texvec[1] = fy;
975  }
976  else {
977 
978  if (wrap == MTEX_FLAT) {
979  fx = (texvec[0] + 1.0f) / 2.0f;
980  fy = (texvec[1] + 1.0f) / 2.0f;
981  dxt[0] /= 2.0f;
982  dxt[1] /= 2.0f;
983  dxt[2] /= 2.0f;
984  dyt[0] /= 2.0f;
985  dyt[1] /= 2.0f;
986  dyt[2] /= 2.0f;
987  }
988  else if (ELEM(wrap, MTEX_TUBE, MTEX_SPHERE)) {
989  /* exception: the seam behind (y<0.0) */
990  ok = 1;
991  if (texvec[1] <= 0.0f) {
992  fx = texvec[0] + dxt[0];
993  fy = texvec[0] + dyt[0];
994  if (fx >= 0.0f && fy >= 0.0f && texvec[0] >= 0.0f) {
995  /* pass */
996  }
997  else if (fx <= 0.0f && fy <= 0.0f && texvec[0] <= 0.0f) {
998  /* pass */
999  }
1000  else {
1001  ok = 0;
1002  }
1003  }
1004 
1005  if (ok) {
1006  if (wrap == MTEX_TUBE) {
1007  map_to_tube(area, area + 1, texvec[0], texvec[1], texvec[2]);
1008  map_to_tube(
1009  area + 2, area + 3, texvec[0] + dxt[0], texvec[1] + dxt[1], texvec[2] + dxt[2]);
1010  map_to_tube(
1011  area + 4, area + 5, texvec[0] + dyt[0], texvec[1] + dyt[1], texvec[2] + dyt[2]);
1012  }
1013  else {
1014  map_to_sphere(area, area + 1, texvec[0], texvec[1], texvec[2]);
1015  map_to_sphere(
1016  area + 2, area + 3, texvec[0] + dxt[0], texvec[1] + dxt[1], texvec[2] + dxt[2]);
1017  map_to_sphere(
1018  area + 4, area + 5, texvec[0] + dyt[0], texvec[1] + dyt[1], texvec[2] + dyt[2]);
1019  }
1020  areaflag = 1;
1021  }
1022  else {
1023  if (wrap == MTEX_TUBE) {
1024  map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
1025  }
1026  else {
1027  map_to_sphere(&fx, &fy, texvec[0], texvec[1], texvec[2]);
1028  }
1029  dxt[0] /= 2.0f;
1030  dxt[1] /= 2.0f;
1031  dyt[0] /= 2.0f;
1032  dyt[1] /= 2.0f;
1033  }
1034  }
1035  else {
1036 
1037  proj = cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
1038 
1039  if (proj == 1) {
1040  SWAP(float, dxt[1], dxt[2]);
1041  SWAP(float, dyt[1], dyt[2]);
1042  }
1043  else if (proj == 2) {
1044  float f1 = dxt[0], f2 = dyt[0];
1045  dxt[0] = dxt[1];
1046  dyt[0] = dyt[1];
1047  dxt[1] = dxt[2];
1048  dyt[1] = dyt[2];
1049  dxt[2] = f1;
1050  dyt[2] = f2;
1051  }
1052 
1053  dxt[0] *= 0.5f;
1054  dxt[1] *= 0.5f;
1055  dxt[2] *= 0.5f;
1056 
1057  dyt[0] *= 0.5f;
1058  dyt[1] *= 0.5f;
1059  dyt[2] *= 0.5f;
1060  }
1061 
1062  /* If area, then recalculate `dxt[]` and `dyt[]` */
1063  if (areaflag) {
1064  fx = area[0];
1065  fy = area[1];
1066  dxt[0] = area[2] - fx;
1067  dxt[1] = area[3] - fy;
1068  dyt[0] = area[4] - fx;
1069  dyt[1] = area[5] - fy;
1070  }
1071 
1072  /* repeat */
1073  if (tex->extend == TEX_REPEAT) {
1074  float max = 1.0f;
1075  if (tex->xrepeat > 1) {
1076  float origf = fx *= tex->xrepeat;
1077 
1078  /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
1079  if (tex->texfilter == TXF_BOX) {
1080  if (fx > 1.0f) {
1081  fx -= (int)(fx);
1082  }
1083  else if (fx < 0.0f) {
1084  fx += 1 - (int)(fx);
1085  }
1086 
1087  if (tex->flag & TEX_REPEAT_XMIR) {
1088  int orig = (int)floor(origf);
1089  if (orig & 1) {
1090  fx = 1.0f - fx;
1091  }
1092  }
1093  }
1094 
1095  max = tex->xrepeat;
1096 
1097  dxt[0] *= tex->xrepeat;
1098  dyt[0] *= tex->xrepeat;
1099  }
1100  if (tex->yrepeat > 1) {
1101  float origf = fy *= tex->yrepeat;
1102 
1103  /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
1104  if (tex->texfilter == TXF_BOX) {
1105  if (fy > 1.0f) {
1106  fy -= (int)(fy);
1107  }
1108  else if (fy < 0.0f) {
1109  fy += 1 - (int)(fy);
1110  }
1111 
1112  if (tex->flag & TEX_REPEAT_YMIR) {
1113  int orig = (int)floor(origf);
1114  if (orig & 1) {
1115  fy = 1.0f - fy;
1116  }
1117  }
1118  }
1119 
1120  if (max < tex->yrepeat) {
1121  max = tex->yrepeat;
1122  }
1123 
1124  dxt[1] *= tex->yrepeat;
1125  dyt[1] *= tex->yrepeat;
1126  }
1127  if (max != 1.0f) {
1128  dxt[2] *= max;
1129  dyt[2] *= max;
1130  }
1131  }
1132  /* crop */
1133  if (tex->cropxmin != 0.0f || tex->cropxmax != 1.0f) {
1134  fac1 = tex->cropxmax - tex->cropxmin;
1135  fx = tex->cropxmin + fx * fac1;
1136  dxt[0] *= fac1;
1137  dyt[0] *= fac1;
1138  }
1139  if (tex->cropymin != 0.0f || tex->cropymax != 1.0f) {
1140  fac1 = tex->cropymax - tex->cropymin;
1141  fy = tex->cropymin + fy * fac1;
1142  dxt[1] *= fac1;
1143  dyt[1] *= fac1;
1144  }
1145 
1146  texvec[0] = fx;
1147  texvec[1] = fy;
1148  }
1149 }
1150 
1151 /* ************************************** */
1152 
1153 static int multitex(Tex *tex,
1154  const float texvec[3],
1155  float dxt[3],
1156  float dyt[3],
1157  int osatex,
1158  TexResult *texres,
1159  const short thread,
1160  const short which_output,
1161  struct ImagePool *pool,
1162  const bool skip_load_image,
1163  const bool texnode_preview,
1164  const bool use_nodes)
1165 {
1166  float tmpvec[3];
1167  int retval = 0; /* return value, int:0, col:1, nor:2, everything:3 */
1168 
1169  texres->talpha = false; /* is set when image texture returns alpha (considered premul) */
1170 
1171  if (use_nodes && tex->use_nodes && tex->nodetree) {
1172  const float cfra = 1.0f; /* This was only set for Blender Internal render before. */
1173  retval = ntreeTexExecTree(tex->nodetree,
1174  texres,
1175  texvec,
1176  dxt,
1177  dyt,
1178  osatex,
1179  thread,
1180  tex,
1181  which_output,
1182  cfra,
1183  texnode_preview,
1184  NULL);
1185  }
1186  else {
1187  switch (tex->type) {
1188  case 0:
1189  texres->tin = 0.0f;
1190  return 0;
1191  case TEX_CLOUDS:
1192  retval = clouds(tex, texvec, texres);
1193  break;
1194  case TEX_WOOD:
1195  retval = wood(tex, texvec, texres);
1196  break;
1197  case TEX_MARBLE:
1198  retval = marble(tex, texvec, texres);
1199  break;
1200  case TEX_MAGIC:
1201  retval = magic(tex, texvec, texres);
1202  break;
1203  case TEX_BLEND:
1204  retval = blend(tex, texvec, texres);
1205  break;
1206  case TEX_STUCCI:
1207  retval = stucci(tex, texvec, texres);
1208  break;
1209  case TEX_NOISE:
1210  retval = texnoise(tex, texres, thread);
1211  break;
1212  case TEX_IMAGE:
1213  if (osatex) {
1214  retval = imagewraposa(
1215  tex, tex->ima, NULL, texvec, dxt, dyt, texres, pool, skip_load_image);
1216  }
1217  else {
1218  retval = imagewrap(tex, tex->ima, texvec, texres, pool, skip_load_image);
1219  }
1220  if (tex->ima) {
1222  }
1223  break;
1224  case TEX_MUSGRAVE:
1225  /* newnoise: musgrave types */
1226 
1227  /* ton: added this, for Blender convention reason.
1228  * artificer: added the use of tmpvec to avoid scaling texvec
1229  */
1230  copy_v3_v3(tmpvec, texvec);
1231  mul_v3_fl(tmpvec, 1.0f / tex->noisesize);
1232 
1233  switch (tex->stype) {
1234  case TEX_MFRACTAL:
1235  case TEX_FBM:
1236  retval = mg_mFractalOrfBmTex(tex, tmpvec, texres);
1237  break;
1238  case TEX_RIDGEDMF:
1239  case TEX_HYBRIDMF:
1240  retval = mg_ridgedOrHybridMFTex(tex, tmpvec, texres);
1241  break;
1242  case TEX_HTERRAIN:
1243  retval = mg_HTerrainTex(tex, tmpvec, texres);
1244  break;
1245  }
1246  break;
1247  /* newnoise: voronoi type */
1248  case TEX_VORONOI:
1249  /* ton: added this, for Blender convention reason.
1250  * artificer: added the use of tmpvec to avoid scaling texvec
1251  */
1252  copy_v3_v3(tmpvec, texvec);
1253  mul_v3_fl(tmpvec, 1.0f / tex->noisesize);
1254 
1255  retval = voronoiTex(tex, tmpvec, texres);
1256  break;
1257  case TEX_DISTNOISE:
1258  /* ton: added this, for Blender convention reason.
1259  * artificer: added the use of tmpvec to avoid scaling texvec
1260  */
1261  copy_v3_v3(tmpvec, texvec);
1262  mul_v3_fl(tmpvec, 1.0f / tex->noisesize);
1263 
1264  retval = mg_distNoiseTex(tex, tmpvec, texres);
1265  break;
1266  }
1267  }
1268 
1269  if (tex->flag & TEX_COLORBAND) {
1270  float col[4];
1271  if (BKE_colorband_evaluate(tex->coba, texres->tin, col)) {
1272  texres->talpha = true;
1273  texres->tr = col[0];
1274  texres->tg = col[1];
1275  texres->tb = col[2];
1276  texres->ta = col[3];
1277  retval |= TEX_RGB;
1278  }
1279  }
1280  return retval;
1281 }
1282 
1284  const float texvec[3],
1285  float dxt[3],
1286  float dyt[3],
1287  int osatex,
1288  TexResult *texres,
1289  const short thread,
1290  short which_output,
1291  MTex *mtex,
1292  struct ImagePool *pool,
1293  const bool scene_color_manage,
1294  const bool skip_load_image,
1295  const bool texnode_preview,
1296  const bool use_nodes)
1297 {
1298  if (tex == NULL) {
1299  memset(texres, 0, sizeof(TexResult));
1300  return 0;
1301  }
1302 
1303  if (mtex) {
1304  which_output = mtex->which_output;
1305  }
1306 
1307  if (tex->type == TEX_IMAGE) {
1308  int rgbnor;
1309 
1310  if (mtex) {
1311  float texvec_l[3];
1312  copy_v3_v3(texvec_l, texvec);
1313  /* we have mtex, use it for 2d mapping images only */
1314  do_2d_mapping(mtex, texvec_l, NULL, dxt, dyt);
1315  rgbnor = multitex(tex,
1316  texvec_l,
1317  dxt,
1318  dyt,
1319  osatex,
1320  texres,
1321  thread,
1322  which_output,
1323  pool,
1324  skip_load_image,
1325  texnode_preview,
1326  use_nodes);
1327 
1328  if (mtex->mapto & MAP_COL) {
1330 
1331  /* don't linearize float buffers, assumed to be linear */
1332  if (ibuf != NULL && ibuf->rect_float == NULL && (rgbnor & TEX_RGB) && scene_color_manage) {
1334  }
1335 
1337  }
1338  }
1339  else {
1340  /* we don't have mtex, do default flat 2d projection */
1341  MTex localmtex;
1342  float texvec_l[3], dxt_l[3], dyt_l[3];
1343 
1344  localmtex.mapping = MTEX_FLAT;
1345  localmtex.tex = tex;
1346  localmtex.object = NULL;
1347  localmtex.texco = TEXCO_ORCO;
1348 
1349  copy_v3_v3(texvec_l, texvec);
1350  if (dxt && dyt) {
1351  copy_v3_v3(dxt_l, dxt);
1352  copy_v3_v3(dyt_l, dyt);
1353  }
1354  else {
1355  zero_v3(dxt_l);
1356  zero_v3(dyt_l);
1357  }
1358 
1359  do_2d_mapping(&localmtex, texvec_l, NULL, dxt_l, dyt_l);
1360  rgbnor = multitex(tex,
1361  texvec_l,
1362  dxt_l,
1363  dyt_l,
1364  osatex,
1365  texres,
1366  thread,
1367  which_output,
1368  pool,
1369  skip_load_image,
1370  texnode_preview,
1371  use_nodes);
1372 
1373  {
1375 
1376  /* don't linearize float buffers, assumed to be linear */
1377  if (ibuf != NULL && ibuf->rect_float == NULL && (rgbnor & TEX_RGB) && scene_color_manage) {
1379  }
1380 
1382  }
1383  }
1384 
1385  return rgbnor;
1386  }
1387 
1388  return multitex(tex,
1389  texvec,
1390  dxt,
1391  dyt,
1392  osatex,
1393  texres,
1394  thread,
1395  which_output,
1396  pool,
1397  skip_load_image,
1398  texnode_preview,
1399  use_nodes);
1400 }
1401 
1402 /* this is called from the shader and texture nodes
1403  * Use it from render pipeline only!
1404  */
1406  const float texvec[3],
1407  float dxt[3],
1408  float dyt[3],
1409  int osatex,
1410  TexResult *texres,
1411  const short thread,
1412  short which_output,
1413  MTex *mtex,
1414  struct ImagePool *pool)
1415 {
1416  return multitex_nodes_intern(tex,
1417  texvec,
1418  dxt,
1419  dyt,
1420  osatex,
1421  texres,
1422  thread,
1423  which_output,
1424  mtex,
1425  pool,
1426  true,
1427  false,
1428  false,
1429  true);
1430 }
1431 
1440  float texvec[3],
1441  float dxt[3],
1442  float dyt[3],
1443  int osatex,
1444  TexResult *texres,
1445  const short thread,
1446  struct ImagePool *pool,
1447  bool scene_color_manage,
1448  const bool skip_load_image)
1449 {
1450  return multitex_nodes_intern(tex,
1451  texvec,
1452  dxt,
1453  dyt,
1454  osatex,
1455  texres,
1456  thread,
1457  0,
1458  NULL,
1459  pool,
1460  scene_color_manage,
1461  skip_load_image,
1462  false,
1463  true);
1464 }
1465 
1466 /* extern-tex doesn't support nodes (ntreeBeginExec() can't be called when rendering is going on)\
1467  *
1468  * Use it for stuff which is out of render pipeline.
1469  */
1471  const float texvec[3],
1472  TexResult *texres,
1473  struct ImagePool *pool,
1474  bool scene_color_manage,
1475  const bool skip_load_image)
1476 {
1477  return multitex_nodes_intern(tex,
1478  texvec,
1479  NULL,
1480  NULL,
1481  0,
1482  texres,
1483  0,
1484  0,
1485  NULL,
1486  pool,
1487  scene_color_manage,
1488  skip_load_image,
1489  false,
1490  false);
1491 }
1492 
1493 /* ------------------------------------------------------------------------- */
1494 
1495 /* in = destination, tex = texture, out = previous color */
1496 /* fact = texture strength, facg = button strength value */
1498  float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype)
1499 {
1500  float facm;
1501 
1502  switch (blendtype) {
1503  case MTEX_BLEND:
1504  fact *= facg;
1505  facm = 1.0f - fact;
1506 
1507  in[0] = (fact * tex[0] + facm * out[0]);
1508  in[1] = (fact * tex[1] + facm * out[1]);
1509  in[2] = (fact * tex[2] + facm * out[2]);
1510  break;
1511 
1512  case MTEX_MUL:
1513  fact *= facg;
1514  facm = 1.0f - fact;
1515  in[0] = (facm + fact * tex[0]) * out[0];
1516  in[1] = (facm + fact * tex[1]) * out[1];
1517  in[2] = (facm + fact * tex[2]) * out[2];
1518  break;
1519 
1520  case MTEX_SCREEN:
1521  fact *= facg;
1522  facm = 1.0f - fact;
1523  in[0] = 1.0f - (facm + fact * (1.0f - tex[0])) * (1.0f - out[0]);
1524  in[1] = 1.0f - (facm + fact * (1.0f - tex[1])) * (1.0f - out[1]);
1525  in[2] = 1.0f - (facm + fact * (1.0f - tex[2])) * (1.0f - out[2]);
1526  break;
1527 
1528  case MTEX_OVERLAY:
1529  fact *= facg;
1530  facm = 1.0f - fact;
1531 
1532  if (out[0] < 0.5f) {
1533  in[0] = out[0] * (facm + 2.0f * fact * tex[0]);
1534  }
1535  else {
1536  in[0] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[0])) * (1.0f - out[0]);
1537  }
1538  if (out[1] < 0.5f) {
1539  in[1] = out[1] * (facm + 2.0f * fact * tex[1]);
1540  }
1541  else {
1542  in[1] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[1])) * (1.0f - out[1]);
1543  }
1544  if (out[2] < 0.5f) {
1545  in[2] = out[2] * (facm + 2.0f * fact * tex[2]);
1546  }
1547  else {
1548  in[2] = 1.0f - (facm + 2.0f * fact * (1.0f - tex[2])) * (1.0f - out[2]);
1549  }
1550  break;
1551 
1552  case MTEX_SUB:
1553  fact = -fact;
1555  case MTEX_ADD:
1556  fact *= facg;
1557  in[0] = (fact * tex[0] + out[0]);
1558  in[1] = (fact * tex[1] + out[1]);
1559  in[2] = (fact * tex[2] + out[2]);
1560  break;
1561 
1562  case MTEX_DIV:
1563  fact *= facg;
1564  facm = 1.0f - fact;
1565 
1566  if (tex[0] != 0.0f) {
1567  in[0] = facm * out[0] + fact * out[0] / tex[0];
1568  }
1569  if (tex[1] != 0.0f) {
1570  in[1] = facm * out[1] + fact * out[1] / tex[1];
1571  }
1572  if (tex[2] != 0.0f) {
1573  in[2] = facm * out[2] + fact * out[2] / tex[2];
1574  }
1575 
1576  break;
1577 
1578  case MTEX_DIFF:
1579  fact *= facg;
1580  facm = 1.0f - fact;
1581  in[0] = facm * out[0] + fact * fabsf(tex[0] - out[0]);
1582  in[1] = facm * out[1] + fact * fabsf(tex[1] - out[1]);
1583  in[2] = facm * out[2] + fact * fabsf(tex[2] - out[2]);
1584  break;
1585 
1586  case MTEX_DARK:
1587  fact *= facg;
1588  facm = 1.0f - fact;
1589 
1590  in[0] = min_ff(out[0], tex[0]) * fact + out[0] * facm;
1591  in[1] = min_ff(out[1], tex[1]) * fact + out[1] * facm;
1592  in[2] = min_ff(out[2], tex[2]) * fact + out[2] * facm;
1593  break;
1594 
1595  case MTEX_LIGHT:
1596  fact *= facg;
1597 
1598  in[0] = max_ff(fact * tex[0], out[0]);
1599  in[1] = max_ff(fact * tex[1], out[1]);
1600  in[2] = max_ff(fact * tex[2], out[2]);
1601  break;
1602 
1603  case MTEX_BLEND_HUE:
1604  fact *= facg;
1605  copy_v3_v3(in, out);
1606  ramp_blend(MA_RAMP_HUE, in, fact, tex);
1607  break;
1608  case MTEX_BLEND_SAT:
1609  fact *= facg;
1610  copy_v3_v3(in, out);
1611  ramp_blend(MA_RAMP_SAT, in, fact, tex);
1612  break;
1613  case MTEX_BLEND_VAL:
1614  fact *= facg;
1615  copy_v3_v3(in, out);
1616  ramp_blend(MA_RAMP_VAL, in, fact, tex);
1617  break;
1618  case MTEX_BLEND_COLOR:
1619  fact *= facg;
1620  copy_v3_v3(in, out);
1621  ramp_blend(MA_RAMP_COLOR, in, fact, tex);
1622  break;
1623  case MTEX_SOFT_LIGHT:
1624  fact *= facg;
1625  copy_v3_v3(in, out);
1626  ramp_blend(MA_RAMP_SOFT, in, fact, tex);
1627  break;
1628  case MTEX_LIN_LIGHT:
1629  fact *= facg;
1630  copy_v3_v3(in, out);
1631  ramp_blend(MA_RAMP_LINEAR, in, fact, tex);
1632  break;
1633  }
1634 }
1635 
1636 float texture_value_blend(float tex, float out, float fact, float facg, int blendtype)
1637 {
1638  float in = 0.0, facm, col, scf;
1639  int flip = (facg < 0.0f);
1640 
1641  facg = fabsf(facg);
1642 
1643  fact *= facg;
1644  facm = 1.0f - fact;
1645  if (flip) {
1646  SWAP(float, fact, facm);
1647  }
1648 
1649  switch (blendtype) {
1650  case MTEX_BLEND:
1651  in = fact * tex + facm * out;
1652  break;
1653 
1654  case MTEX_MUL:
1655  facm = 1.0f - facg;
1656  in = (facm + fact * tex) * out;
1657  break;
1658 
1659  case MTEX_SCREEN:
1660  facm = 1.0f - facg;
1661  in = 1.0f - (facm + fact * (1.0f - tex)) * (1.0f - out);
1662  break;
1663 
1664  case MTEX_OVERLAY:
1665  facm = 1.0f - facg;
1666  if (out < 0.5f) {
1667  in = out * (facm + 2.0f * fact * tex);
1668  }
1669  else {
1670  in = 1.0f - (facm + 2.0f * fact * (1.0f - tex)) * (1.0f - out);
1671  }
1672  break;
1673 
1674  case MTEX_SUB:
1675  fact = -fact;
1677  case MTEX_ADD:
1678  in = fact * tex + out;
1679  break;
1680 
1681  case MTEX_DIV:
1682  if (tex != 0.0f) {
1683  in = facm * out + fact * out / tex;
1684  }
1685  break;
1686 
1687  case MTEX_DIFF:
1688  in = facm * out + fact * fabsf(tex - out);
1689  break;
1690 
1691  case MTEX_DARK:
1692  in = min_ff(out, tex) * fact + out * facm;
1693  break;
1694 
1695  case MTEX_LIGHT:
1696  col = fact * tex;
1697  if (col > out) {
1698  in = col;
1699  }
1700  else {
1701  in = out;
1702  }
1703  break;
1704 
1705  case MTEX_SOFT_LIGHT:
1706  scf = 1.0f - (1.0f - tex) * (1.0f - out);
1707  in = facm * out + fact * ((1.0f - out) * tex * out) + (out * scf);
1708  break;
1709 
1710  case MTEX_LIN_LIGHT:
1711  if (tex > 0.5f) {
1712  in = out + fact * (2.0f * (tex - 0.5f));
1713  }
1714  else {
1715  in = out + fact * (2.0f * tex - 1.0f);
1716  }
1717  break;
1718  }
1719 
1720  return in;
1721 }
1722 
1723 /* ------------------------------------------------------------------------- */
1724 
1730 bool RE_texture_evaluate(const MTex *mtex,
1731  const float vec[3],
1732  const int thread,
1733  struct ImagePool *pool,
1734  const bool skip_load_image,
1735  const bool texnode_preview,
1736  /* Return arguments. */
1737  float *r_intensity,
1738  float r_rgba[4])
1739 {
1740  Tex *tex;
1741  TexResult texr;
1742  float dxt[3], dyt[3], texvec[3];
1743  int rgb;
1744 
1745  tex = mtex->tex;
1746  if (tex == NULL) {
1747  return 0;
1748  }
1749  texr.nor = NULL;
1750 
1751  /* placement */
1752  if (mtex->projx) {
1753  texvec[0] = mtex->size[0] * (vec[mtex->projx - 1] + mtex->ofs[0]);
1754  }
1755  else {
1756  texvec[0] = mtex->size[0] * (mtex->ofs[0]);
1757  }
1758 
1759  if (mtex->projy) {
1760  texvec[1] = mtex->size[1] * (vec[mtex->projy - 1] + mtex->ofs[1]);
1761  }
1762  else {
1763  texvec[1] = mtex->size[1] * (mtex->ofs[1]);
1764  }
1765 
1766  if (mtex->projz) {
1767  texvec[2] = mtex->size[2] * (vec[mtex->projz - 1] + mtex->ofs[2]);
1768  }
1769  else {
1770  texvec[2] = mtex->size[2] * (mtex->ofs[2]);
1771  }
1772 
1773  /* texture */
1774  if (tex->type == TEX_IMAGE) {
1775  do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
1776  }
1777 
1778  rgb = multitex(tex,
1779  texvec,
1780  dxt,
1781  dyt,
1782  0,
1783  &texr,
1784  thread,
1785  mtex->which_output,
1786  pool,
1787  skip_load_image,
1788  texnode_preview,
1789  true);
1790 
1791  if (rgb) {
1793  }
1794  else {
1795  texr.tr = mtex->r;
1796  texr.tg = mtex->g;
1797  texr.tb = mtex->b;
1798  }
1799 
1800  *r_intensity = texr.tin;
1801  r_rgba[0] = texr.tr;
1802  r_rgba[1] = texr.tg;
1803  r_rgba[2] = texr.tb;
1804  r_rgba[3] = texr.ta;
1805 
1806  return (rgb != 0);
1807 }
typedef float(TangentPoint)[2]
bool BKE_colorband_evaluate(const struct ColorBand *coba, float in, float out[4])
void BKE_image_pool_release_ibuf(struct Image *ima, struct ImBuf *ibuf, struct ImagePool *pool)
Definition: image.c:5261
struct ImBuf * BKE_image_pool_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, struct ImagePool *pool)
Definition: image.c:5213
void BKE_image_tag_time(struct Image *ima)
Definition: image.c:1184
General operations, lookup, etc. for materials.
void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
Definition: material.c:1395
int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, const float co[3], float dxt[3], float dyt[3], int osatex, const short thread, const struct Tex *tex, short which_output, int cfra, int preview, struct MTex *mtex)
#define ATTR_FALLTHROUGH
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
#define M_PI
Definition: BLI_math_base.h:38
void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const float z)
Definition: math_geom.c:5236
void map_to_tube(float *r_u, float *r_v, const float x, const float y, const float z)
Definition: math_geom.c:5221
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float dot_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v3(float r[3])
float BLI_noise_mg_hetero_terrain(float x, float y, float z, float H, float lacunarity, float octaves, float offset, int noisebasis)
Definition: noise.c:1442
float BLI_noise_mg_multi_fractal(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
Definition: noise.c:1376
float BLI_noise_mg_ridged_multi_fractal(float x, float y, float z, float H, float lacunarity, float octaves, float offset, float gain, int noisebasis)
Definition: noise.c:1603
float BLI_noise_mg_variable_lacunarity(float x, float y, float z, float distortion, int nbas1, int nbas2)
Definition: noise.c:1677
float BLI_noise_generic_noise(float noisesize, float x, float y, float z, bool hard, int noisebasis)
Definition: noise.c:1172
void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
Definition: noise.c:931
float BLI_noise_mg_fbm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
Definition: noise.c:1305
void BLI_noise_cell_v3(float x, float y, float z, float r_ca[3])
Definition: noise.c:1147
float BLI_noise_mg_hybrid_multi_fractal(float x, float y, float z, float H, float lacunarity, float octaves, float offset, float gain, int noisebasis)
Definition: noise.c:1519
float BLI_noise_generic_turbulence(float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
Definition: noise.c:1230
Random number functions.
void BLI_rng_threaded_free(struct RNG_THREAD_ARRAY *rngarr) ATTR_NONNULL(1)
Definition: rand.cc:263
RNG_THREAD_ARRAY * BLI_rng_threaded_new(void)
Definition: rand.cc:250
int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread) ATTR_WARN_UNUSED_RESULT
Definition: rand.cc:268
#define SWAP(type, a, b)
#define ELEM(...)
#define MA_RAMP_VAL
#define MA_RAMP_SOFT
#define MA_RAMP_LINEAR
#define MA_RAMP_SAT
#define MA_RAMP_HUE
#define TEXCO_ORCO
#define MAP_COL
#define MA_RAMP_COLOR
Object is a sort of wrapper for general info.
#define MTEX_LIGHT
#define TEX_RAD
#define MTEX_MUL
#define MTEX_BLEND_VAL
#define TEX_SHARPER
#define TEX_REPEAT_YMIR
#define TEX_NOR
#define TEX_COLOR
#define TEX_COLORBAND
#define TEX_HYBRIDMF
#define TEX_TRI
#define TEX_LIN
#define MTEX_OVERLAY
#define TEX_INT
#define TEX_BLEND
#define MTEX_DIV
#define MTEX_BLEND_HUE
#define TEX_RIDGEDMF
#define TEX_RINGNOISE
#define MTEX_SPHERE
#define TEX_WALLOUT
#define MTEX_TUBE
#define TEX_REPEAT
#define TEX_BAND
#define MTEX_SUB
#define TEX_DISTNOISE
#define TEX_SOFT
#define TEX_SHARP
#define MTEX_SCREEN
#define MTEX_LIN_LIGHT
#define TEX_RING
#define TXF_BOX
#define TEX_FBM
#define TEX_MFRACTAL
#define TEX_RGB
#define TEX_HALO
#define TEX_BANDNOISE
#define MTEX_DIFF
#define TEX_EASE
#define MTEX_BLEND_SAT
#define MTEX_BLEND
#define TEX_REPEAT_XMIR
#define TEX_DIAG
#define MTEX_SOFT_LIGHT
#define TEX_MARBLE
#define TEX_QUAD
#define TEX_HTERRAIN
#define MTEX_BLEND_COLOR
#define TEX_SIN
#define MTEX_ADD
#define MTEX_FLAT
#define TEX_NOISESOFT
#define TEX_WOOD
#define MTEX_DARK
#define TEX_FLIPBLEND
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble y1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate Vector White RGB Map Separate Set Z Dilate Combine Combine Color Channel Split ID Combine Luminance Directional Alpha Distance Hue Movie Ellipse Bokeh View Corner Anti Mix RGB Hue Separate TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_STUCCI
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume TEX_IMAGE
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate Vector White RGB Map Separate Set Z Dilate Combine Combine Color Channel Split ID Combine Luminance Directional Alpha Distance Hue Movie Ellipse Bokeh View Corner Anti Mix RGB Hue Separate TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_MUSGRAVE
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate Vector White RGB Map Separate Set Z Dilate Combine Combine Color Channel Split ID Combine Luminance Directional Alpha Distance Hue Movie Ellipse Bokeh View Corner Anti Mix RGB Hue Separate TEX_NODE_PROC TEX_NODE_PROC TEX_NODE_PROC TEX_CLOUDS
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky TEX_NOISE
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave TEX_VORONOI
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate Vector White RGB Map Separate Set Z Dilate Combine Combine Color Channel Split ID Combine Luminance Directional Alpha Distance Hue Movie Ellipse Bokeh View Corner Anti Mix RGB Hue Separate TEX_NODE_PROC TEX_NODE_PROC TEX_MAGIC
uint nor
uint col
#define sinf(x)
#define cosf(x)
#define atan2f(x, y)
#define floorf(x)
#define fabsf(x)
#define sqrtf(x)
static float turb(float x, float y, float z, int oct, int hard, int nb, float ampscale, float freqscale)
static unsigned a[3]
Definition: RandGen.cpp:92
static void area(int d1, int d2, int e1, int e2, float weights[2])
static GPUContext * wrap(Context *ctx)
return ret
struct ColorSpace * rect_colorspace
float * rect_float
short texco
char projy
char projz
char mapping
char projx
short which_output
float ofs[3]
short mapto
struct Object * object
float size[3]
struct Tex * tex
int talpha
Definition: RE_texture.h:85
float tb
Definition: RE_texture.h:84
float * nor
Definition: RE_texture.h:86
float tin
Definition: RE_texture.h:84
float ta
Definition: RE_texture.h:84
float tr
Definition: RE_texture.h:84
float tg
Definition: RE_texture.h:84
float cropymin
float dist_amount
float noisesize
short xrepeat
float vn_w4
short noisedepth
float ns_outscale
short noisetype
float vn_w2
float cropxmax
float cropymax
float mg_lacunarity
float mg_offset
float nabla
char use_nodes
float vn_mexp
float mg_gain
short noisebasis2
short vn_coltype
short stype
float mg_octaves
struct ImageUser iuser
struct ColorBand * coba
int texfilter
short vn_distm
float cropxmin
short flag
float mg_H
short type
float vn_w3
struct bNodeTree * nodetree
short noisebasis
float vn_w1
struct Image * ima
short extend
short yrepeat
float turbul
#define BRICONT
#define BRICONTRGB
int imagewrap(struct Tex *tex, struct Image *ima, const float texvec[3], struct TexResult *texres, struct ImagePool *pool, const bool skip_load_image)
int imagewraposa(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], const float dxt[2], const float dyt[2], struct TexResult *texres, struct ImagePool *pool, const bool skip_load_image)
static float tex_sin(float a)
static int mg_mFractalOrfBmTex(const Tex *tex, const float texvec[3], TexResult *texres)
static int marble(const Tex *tex, const float texvec[3], TexResult *texres)
static int multitex(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, const short which_output, struct ImagePool *pool, const bool skip_load_image, const bool texnode_preview, const bool use_nodes)
static int stucci(const Tex *tex, const float texvec[3], TexResult *texres)
static void do_2d_mapping(const MTex *mtex, float texvec[3], const float n[3], float dxt[3], float dyt[3])
static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres)
int multitex_ext_safe(Tex *tex, const float texvec[3], TexResult *texres, struct ImagePool *pool, bool scene_color_manage, const bool skip_load_image)
static RNG_THREAD_ARRAY * random_tex_array
int multitex_nodes(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, short which_output, MTex *mtex, struct ImagePool *pool)
static float tex_saw(float a)
static int multitex_nodes_intern(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, short which_output, MTex *mtex, struct ImagePool *pool, const bool scene_color_manage, const bool skip_load_image, const bool texnode_preview, const bool use_nodes)
bool RE_texture_evaluate(const MTex *mtex, const float vec[3], const int thread, struct ImagePool *pool, const bool skip_load_image, const bool texnode_preview, float *r_intensity, float r_rgba[4])
static int mg_distNoiseTex(const Tex *tex, const float texvec[3], TexResult *texres)
static float wood_int(const Tex *tex, float x, float y, float z)
static int mg_ridgedOrHybridMFTex(const Tex *tex, const float texvec[3], TexResult *texres)
static int wood(const Tex *tex, const float texvec[3], TexResult *texres)
void RE_texture_rng_init(void)
static int mg_HTerrainTex(const Tex *tex, const float texvec[3], TexResult *texres)
static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1, float *adr2)
static int magic(const Tex *tex, const float texvec[3], TexResult *texres)
int multitex_ext(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, struct ImagePool *pool, bool scene_color_manage, const bool skip_load_image)
static int blend(const Tex *tex, const float texvec[3], TexResult *texres)
static float marble_int(const Tex *tex, float x, float y, float z)
static int texnoise(const Tex *tex, TexResult *texres, int thread)
void RE_texture_rng_exit(void)
float texture_value_blend(float tex, float out, float fact, float facg, int blendtype)
void texture_rgb_blend(float in[3], const float tex[3], const float out[3], float fact, float facg, int blendtype)
static void tex_normal_derivate(const Tex *tex, TexResult *texres)
static float tex_tri(float a)
static int clouds(const Tex *tex, const float texvec[3], TexResult *texres)
float max
ccl_device_inline float2 floor(const float2 &a)