Blender  V3.3
texture_procedural.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include <math.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 
13 #include "BLI_math.h"
14 #include "BLI_noise.h"
15 #include "BLI_rand.h"
16 #include "BLI_utildefines.h"
17 
18 #include "DNA_anim_types.h"
19 #include "DNA_image_types.h"
20 #include "DNA_light_types.h"
21 #include "DNA_material_types.h"
22 #include "DNA_meshdata_types.h"
23 #include "DNA_node_types.h"
24 #include "DNA_object_types.h"
25 #include "DNA_texture_types.h"
26 
27 #include "IMB_colormanagement.h"
28 #include "IMB_imbuf_types.h"
29 
30 #include "BKE_colorband.h"
31 #include "BKE_image.h"
32 #include "BKE_material.h"
33 #include "BKE_node.h"
34 #include "BKE_scene.h"
35 #include "BKE_texture.h"
36 
37 #include "NOD_texture.h"
38 
39 #include "MEM_guardedalloc.h"
40 
41 #include "render_types.h"
42 #include "texture_common.h"
43 
44 #include "RE_texture.h"
45 
47 
49 {
51 }
52 
54 {
55  if (random_tex_array == NULL) {
56  return;
57  }
60 }
61 
62 /* ------------------------------------------------------------------------- */
63 
64 static int blend(const Tex *tex, const float texvec[3], TexResult *texres)
65 {
66  float x, y, t;
67 
68  if (tex->flag & TEX_FLIPBLEND) {
69  x = texvec[1];
70  y = texvec[0];
71  }
72  else {
73  x = texvec[0];
74  y = texvec[1];
75  }
76 
77  if (tex->stype == TEX_LIN) { /* Linear. */
78  texres->tin = (1.0f + x) / 2.0f;
79  }
80  else if (tex->stype == TEX_QUAD) { /* Quadratic. */
81  texres->tin = (1.0f + x) / 2.0f;
82  if (texres->tin < 0.0f) {
83  texres->tin = 0.0f;
84  }
85  else {
86  texres->tin *= texres->tin;
87  }
88  }
89  else if (tex->stype == TEX_EASE) { /* Ease. */
90  texres->tin = (1.0f + x) / 2.0f;
91  if (texres->tin <= 0.0f) {
92  texres->tin = 0.0f;
93  }
94  else if (texres->tin >= 1.0f) {
95  texres->tin = 1.0f;
96  }
97  else {
98  t = texres->tin * texres->tin;
99  texres->tin = (3.0f * t - 2.0f * t * texres->tin);
100  }
101  }
102  else if (tex->stype == TEX_DIAG) { /* Diagonal. */
103  texres->tin = (2.0f + x + y) / 4.0f;
104  }
105  else if (tex->stype == TEX_RAD) { /* Radial. */
106  texres->tin = (atan2f(y, x) / (float)(2 * M_PI) + 0.5f);
107  }
108  else { /* sphere TEX_SPHERE */
109  texres->tin = 1.0f - sqrtf(x * x + y * y + texvec[2] * texvec[2]);
110  if (texres->tin < 0.0f) {
111  texres->tin = 0.0f;
112  }
113  if (tex->stype == TEX_HALO) {
114  texres->tin *= texres->tin; /* Halo. */
115  }
116  }
117 
118  BRICONT;
119 
120  return TEX_INT;
121 }
122 
123 /* ------------------------------------------------------------------------- */
124 /* ************************************************************************* */
125 
126 /* newnoise: all noise-based types now have different noise-bases to choose from. */
127 
128 static int clouds(const Tex *tex, const float texvec[3], TexResult *texres)
129 {
130  int rv = TEX_INT;
131 
133  texvec[0],
134  texvec[1],
135  texvec[2],
136  tex->noisedepth,
138  tex->noisebasis);
139 
140  if (tex->stype == TEX_COLOR) {
141  texres->trgba[0] = texres->tin;
143  texvec[1],
144  texvec[0],
145  texvec[2],
146  tex->noisedepth,
148  tex->noisebasis);
150  texvec[1],
151  texvec[2],
152  texvec[0],
153  tex->noisedepth,
155  tex->noisebasis);
156  BRICONTRGB;
157  texres->trgba[3] = 1.0;
158  return (rv | TEX_RGB);
159  }
160 
161  BRICONT;
162 
163  return rv;
164 }
165 
166 /* creates a sine wave */
167 static float tex_sin(float a)
168 {
169  a = 0.5f + 0.5f * sinf(a);
170 
171  return a;
172 }
173 
174 /* creates a saw wave */
175 static float tex_saw(float a)
176 {
177  const float b = 2 * M_PI;
178 
179  int n = (int)(a / b);
180  a -= n * b;
181  if (a < 0) {
182  a += b;
183  }
184  return a / b;
185 }
186 
187 /* creates a triangle wave */
188 static float tex_tri(float a)
189 {
190  const float b = 2 * M_PI;
191  const float rmax = 1.0;
192 
193  a = rmax - 2.0f * fabsf(floorf((a * (1.0f / b)) + 0.5f) - (a * (1.0f / b)));
194 
195  return a;
196 }
197 
198 /* computes basic wood intensity value at x,y,z */
199 static float wood_int(const Tex *tex, float x, float y, float z)
200 {
201  float wi = 0;
202  /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
203  short wf = tex->noisebasis2;
204  /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
205  short wt = tex->stype;
206 
207  float (*waveform[3])(float); /* create array of pointers to waveform functions */
208  waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
209  waveform[1] = tex_saw;
210  waveform[2] = tex_tri;
211 
212  if ((wf > TEX_TRI) || (wf < TEX_SIN)) {
213  wf = 0; /* check to be sure noisebasis2 is initialized ahead of time */
214  }
215 
216  if (wt == TEX_BAND) {
217  wi = waveform[wf]((x + y + z) * 10.0f);
218  }
219  else if (wt == TEX_RING) {
220  wi = waveform[wf](sqrtf(x * x + y * y + z * z) * 20.0f);
221  }
222  else if (wt == TEX_BANDNOISE) {
223  wi = tex->turbul *
226  wi = waveform[wf]((x + y + z) * 10.0f + wi);
227  }
228  else if (wt == TEX_RINGNOISE) {
229  wi = tex->turbul *
232  wi = waveform[wf](sqrtf(x * x + y * y + z * z) * 20.0f + wi);
233  }
234 
235  return wi;
236 }
237 
238 static int wood(const Tex *tex, const float texvec[3], TexResult *texres)
239 {
240  int rv = TEX_INT;
241 
242  texres->tin = wood_int(tex, texvec[0], texvec[1], texvec[2]);
243 
244  BRICONT;
245 
246  return rv;
247 }
248 
249 /* computes basic marble intensity at x,y,z */
250 static float marble_int(const Tex *tex, float x, float y, float z)
251 {
252  float n, mi;
253  short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */
254  short mt = tex->stype; /* marble type: TEX_SOFT=0, TEX_SHARP=1, TEX_SHAPER=2 */
255 
256  float (*waveform[3])(float); /* create array of pointers to waveform functions */
257  waveform[0] = tex_sin; /* assign address of tex_sin() function to pointer array */
258  waveform[1] = tex_saw;
259  waveform[2] = tex_tri;
260 
261  if ((wf > TEX_TRI) || (wf < TEX_SIN)) {
262  wf = 0; /* check to be sure noisebasis2 isn't initialized ahead of time */
263  }
264 
265  n = 5.0f * (x + y + z);
266 
268  x,
269  y,
270  z,
271  tex->noisedepth,
273  tex->noisebasis);
274 
275  if (mt >= TEX_SOFT) { /* TEX_SOFT always true */
276  mi = waveform[wf](mi);
277  if (mt == TEX_SHARP) {
278  mi = sqrtf(mi);
279  }
280  else if (mt == TEX_SHARPER) {
281  mi = sqrtf(sqrtf(mi));
282  }
283  }
284 
285  return mi;
286 }
287 
288 static int marble(const Tex *tex, const float texvec[3], TexResult *texres)
289 {
290  int rv = TEX_INT;
291 
292  texres->tin = marble_int(tex, texvec[0], texvec[1], texvec[2]);
293 
294  BRICONT;
295 
296  return rv;
297 }
298 
299 /* ------------------------------------------------------------------------- */
300 
301 static int magic(const Tex *tex, const float texvec[3], TexResult *texres)
302 {
303  float x, y, z, turb;
304  int n;
305 
306  n = tex->noisedepth;
307  turb = tex->turbul / 5.0f;
308 
309  x = sinf((texvec[0] + texvec[1] + texvec[2]) * 5.0f);
310  y = cosf((-texvec[0] + texvec[1] - texvec[2]) * 5.0f);
311  z = -cosf((-texvec[0] - texvec[1] + texvec[2]) * 5.0f);
312  if (n > 0) {
313  x *= turb;
314  y *= turb;
315  z *= turb;
316  y = -cosf(x - y + z);
317  y *= turb;
318  if (n > 1) {
319  x = cosf(x - y - z);
320  x *= turb;
321  if (n > 2) {
322  z = sinf(-x - y - z);
323  z *= turb;
324  if (n > 3) {
325  x = -cosf(-x + y - z);
326  x *= turb;
327  if (n > 4) {
328  y = -sinf(-x + y + z);
329  y *= turb;
330  if (n > 5) {
331  y = -cosf(-x + y + z);
332  y *= turb;
333  if (n > 6) {
334  x = cosf(x + y + z);
335  x *= turb;
336  if (n > 7) {
337  z = sinf(x + y - z);
338  z *= turb;
339  if (n > 8) {
340  x = -cosf(-x - y + z);
341  x *= turb;
342  if (n > 9) {
343  y = -sinf(x - y + z);
344  y *= turb;
345  }
346  }
347  }
348  }
349  }
350  }
351  }
352  }
353  }
354  }
355 
356  if (turb != 0.0f) {
357  turb *= 2.0f;
358  x /= turb;
359  y /= turb;
360  z /= turb;
361  }
362  texres->trgba[0] = 0.5f - x;
363  texres->trgba[1] = 0.5f - y;
364  texres->trgba[2] = 0.5f - z;
365 
366  texres->tin = (1.0f / 3.0f) * (texres->trgba[0] + texres->trgba[1] + texres->trgba[2]);
367 
368  BRICONTRGB;
369  texres->trgba[3] = 1.0f;
370 
371  return TEX_RGB;
372 }
373 
374 /* ------------------------------------------------------------------------- */
375 
376 /* newnoise: stucci also modified to use different noisebasis */
377 static int stucci(const Tex *tex, const float texvec[3], TexResult *texres)
378 {
379  float b2, ofs;
380  int retval = TEX_INT;
381 
383  texvec[0],
384  texvec[1],
385  texvec[2],
387  tex->noisebasis);
388 
389  ofs = tex->turbul / 200.0f;
390 
391  if (tex->stype) {
392  ofs *= (b2 * b2);
393  }
394 
396  texvec[0],
397  texvec[1],
398  texvec[2] + ofs,
400  tex->noisebasis);
401 
402  if (tex->stype == TEX_WALLOUT) {
403  texres->tin = 1.0f - texres->tin;
404  }
405 
406  if (texres->tin < 0.0f) {
407  texres->tin = 0.0f;
408  }
409 
410  return retval;
411 }
412 
413 /* ------------------------------------------------------------------------- */
414 /* newnoise: musgrave terrain noise types */
415 
416 static int mg_mFractalOrfBmTex(const Tex *tex, const float texvec[3], TexResult *texres)
417 {
418  int rv = TEX_INT;
419  float (*mgravefunc)(float, float, float, float, float, float, int);
420 
421  if (tex->stype == TEX_MFRACTAL) {
422  mgravefunc = BLI_noise_mg_multi_fractal;
423  }
424  else {
425  mgravefunc = BLI_noise_mg_fbm;
426  }
427 
428  texres->tin = tex->ns_outscale * mgravefunc(texvec[0],
429  texvec[1],
430  texvec[2],
431  tex->mg_H,
433  tex->mg_octaves,
434  tex->noisebasis);
435 
436  BRICONT;
437 
438  return rv;
439 }
440 
441 static int mg_ridgedOrHybridMFTex(const Tex *tex, const float texvec[3], TexResult *texres)
442 {
443  int rv = TEX_INT;
444  float (*mgravefunc)(float, float, float, float, float, float, float, float, int);
445 
446  if (tex->stype == TEX_RIDGEDMF) {
448  }
449  else {
451  }
452 
453  texres->tin = tex->ns_outscale * mgravefunc(texvec[0],
454  texvec[1],
455  texvec[2],
456  tex->mg_H,
458  tex->mg_octaves,
459  tex->mg_offset,
460  tex->mg_gain,
461  tex->noisebasis);
462 
463  BRICONT;
464 
465  return rv;
466 }
467 
468 static int mg_HTerrainTex(const Tex *tex, const float texvec[3], TexResult *texres)
469 {
470  int rv = TEX_INT;
471 
472  texres->tin = tex->ns_outscale * BLI_noise_mg_hetero_terrain(texvec[0],
473  texvec[1],
474  texvec[2],
475  tex->mg_H,
477  tex->mg_octaves,
478  tex->mg_offset,
479  tex->noisebasis);
480 
481  BRICONT;
482 
483  return rv;
484 }
485 
486 static int mg_distNoiseTex(const Tex *tex, const float texvec[3], TexResult *texres)
487 {
488  int rv = TEX_INT;
489 
491  texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
492 
493  BRICONT;
494 
495  return rv;
496 }
497 
498 /* ------------------------------------------------------------------------- */
499 /* newnoise: Voronoi texture type
500  *
501  * probably the slowest, especially with minkovsky, bump-mapping, could be done another way.
502  */
503 
504 static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres)
505 {
506  int rv = TEX_INT;
507  float da[4], pa[12]; /* distance and point coordinate arrays of 4 nearest neighbors */
508  float aw1 = fabsf(tex->vn_w1);
509  float aw2 = fabsf(tex->vn_w2);
510  float aw3 = fabsf(tex->vn_w3);
511  float aw4 = fabsf(tex->vn_w4);
512  float sc = (aw1 + aw2 + aw3 + aw4);
513  if (sc != 0.0f) {
514  sc = tex->ns_outscale / sc;
515  }
516 
517  BLI_noise_voronoi(texvec[0], texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
518  texres->tin = sc * fabsf(dot_v4v4(&tex->vn_w1, da));
519 
520  if (tex->vn_coltype) {
521  float ca[3]; /* cell color */
522  BLI_noise_cell_v3(pa[0], pa[1], pa[2], ca);
523  texres->trgba[0] = aw1 * ca[0];
524  texres->trgba[1] = aw1 * ca[1];
525  texres->trgba[2] = aw1 * ca[2];
526  BLI_noise_cell_v3(pa[3], pa[4], pa[5], ca);
527  texres->trgba[0] += aw2 * ca[0];
528  texres->trgba[1] += aw2 * ca[1];
529  texres->trgba[2] += aw2 * ca[2];
530  BLI_noise_cell_v3(pa[6], pa[7], pa[8], ca);
531  texres->trgba[0] += aw3 * ca[0];
532  texres->trgba[1] += aw3 * ca[1];
533  texres->trgba[2] += aw3 * ca[2];
534  BLI_noise_cell_v3(pa[9], pa[10], pa[11], ca);
535  texres->trgba[0] += aw4 * ca[0];
536  texres->trgba[1] += aw4 * ca[1];
537  texres->trgba[2] += aw4 * ca[2];
538  if (tex->vn_coltype >= 2) {
539  float t1 = (da[1] - da[0]) * 10;
540  if (t1 > 1) {
541  t1 = 1;
542  }
543  if (tex->vn_coltype == 3) {
544  t1 *= texres->tin;
545  }
546  else {
547  t1 *= sc;
548  }
549  texres->trgba[0] *= t1;
550  texres->trgba[1] *= t1;
551  texres->trgba[2] *= t1;
552  }
553  else {
554  texres->trgba[0] *= sc;
555  texres->trgba[1] *= sc;
556  texres->trgba[2] *= sc;
557  }
558  }
559 
560  if (tex->vn_coltype) {
561  BRICONTRGB;
562  texres->trgba[3] = 1.0;
563  return (rv | TEX_RGB);
564  }
565 
566  BRICONT;
567 
568  return rv;
569 }
570 
571 /* ------------------------------------------------------------------------- */
572 
573 static int texnoise(const Tex *tex, TexResult *texres, int thread)
574 {
575  float div = 3.0;
576  int val, ran, loop, shift = 29;
577 
579 
580  loop = tex->noisedepth;
581 
582  /* start from top bits since they have more variance */
583  val = ((ran >> shift) & 3);
584 
585  while (loop--) {
586  shift -= 2;
587  val *= ((ran >> shift) & 3);
588  div *= 3.0f;
589  }
590 
591  texres->tin = ((float)val) / div;
592 
593  BRICONT;
594  return TEX_INT;
595 }
596 
597 /* ------------------------------------------------------------------------- */
598 
599 static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1, float *adr2)
600 {
601  float x1, y1, z1, nor[3];
602  int ret;
603 
604  if (n == NULL) {
605  nor[0] = x;
606  nor[1] = y;
607  nor[2] = z; /* use local render coord */
608  }
609  else {
610  copy_v3_v3(nor, n);
611  }
612 
613  x1 = fabsf(nor[0]);
614  y1 = fabsf(nor[1]);
615  z1 = fabsf(nor[2]);
616 
617  if (z1 >= x1 && z1 >= y1) {
618  *adr1 = (x + 1.0f) / 2.0f;
619  *adr2 = (y + 1.0f) / 2.0f;
620  ret = 0;
621  }
622  else if (y1 >= x1 && y1 >= z1) {
623  *adr1 = (x + 1.0f) / 2.0f;
624  *adr2 = (z + 1.0f) / 2.0f;
625  ret = 1;
626  }
627  else {
628  *adr1 = (y + 1.0f) / 2.0f;
629  *adr2 = (z + 1.0f) / 2.0f;
630  ret = 2;
631  }
632  return ret;
633 }
634 
635 /* ------------------------------------------------------------------------- */
636 
637 static void do_2d_mapping(
638  const MTex *mtex, float texvec[3], const float n[3], float dxt[3], float dyt[3])
639 {
640  Tex *tex;
641  float fx, fy, fac1, area[8];
642  int ok, proj, areaflag = 0, wrap;
643 
644  /* #MTex variables localized, only cube-map doesn't cooperate yet. */
645  wrap = mtex->mapping;
646  tex = mtex->tex;
647 
648  if (!(dxt && dyt)) {
649 
650  if (wrap == MTEX_FLAT) {
651  fx = (texvec[0] + 1.0f) / 2.0f;
652  fy = (texvec[1] + 1.0f) / 2.0f;
653  }
654  else if (wrap == MTEX_TUBE) {
655  map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
656  }
657  else if (wrap == MTEX_SPHERE) {
658  map_to_sphere(&fx, &fy, texvec[0], texvec[1], texvec[2]);
659  }
660  else {
661  cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
662  }
663 
664  /* repeat */
665  if (tex->extend == TEX_REPEAT) {
666  if (tex->xrepeat > 1) {
667  float origf = fx *= tex->xrepeat;
668 
669  if (fx > 1.0f) {
670  fx -= (int)(fx);
671  }
672  else if (fx < 0.0f) {
673  fx += 1 - (int)(fx);
674  }
675 
676  if (tex->flag & TEX_REPEAT_XMIR) {
677  int orig = (int)floor(origf);
678  if (orig & 1) {
679  fx = 1.0f - fx;
680  }
681  }
682  }
683  if (tex->yrepeat > 1) {
684  float origf = fy *= tex->yrepeat;
685 
686  if (fy > 1.0f) {
687  fy -= (int)(fy);
688  }
689  else if (fy < 0.0f) {
690  fy += 1 - (int)(fy);
691  }
692 
693  if (tex->flag & TEX_REPEAT_YMIR) {
694  int orig = (int)floor(origf);
695  if (orig & 1) {
696  fy = 1.0f - fy;
697  }
698  }
699  }
700  }
701  /* crop */
702  if (tex->cropxmin != 0.0f || tex->cropxmax != 1.0f) {
703  fac1 = tex->cropxmax - tex->cropxmin;
704  fx = tex->cropxmin + fx * fac1;
705  }
706  if (tex->cropymin != 0.0f || tex->cropymax != 1.0f) {
707  fac1 = tex->cropymax - tex->cropymin;
708  fy = tex->cropymin + fy * fac1;
709  }
710 
711  texvec[0] = fx;
712  texvec[1] = fy;
713  }
714  else {
715 
716  if (wrap == MTEX_FLAT) {
717  fx = (texvec[0] + 1.0f) / 2.0f;
718  fy = (texvec[1] + 1.0f) / 2.0f;
719  dxt[0] /= 2.0f;
720  dxt[1] /= 2.0f;
721  dxt[2] /= 2.0f;
722  dyt[0] /= 2.0f;
723  dyt[1] /= 2.0f;
724  dyt[2] /= 2.0f;
725  }
726  else if (ELEM(wrap, MTEX_TUBE, MTEX_SPHERE)) {
727  /* exception: the seam behind (y<0.0) */
728  ok = 1;
729  if (texvec[1] <= 0.0f) {
730  fx = texvec[0] + dxt[0];
731  fy = texvec[0] + dyt[0];
732  if (fx >= 0.0f && fy >= 0.0f && texvec[0] >= 0.0f) {
733  /* pass */
734  }
735  else if (fx <= 0.0f && fy <= 0.0f && texvec[0] <= 0.0f) {
736  /* pass */
737  }
738  else {
739  ok = 0;
740  }
741  }
742 
743  if (ok) {
744  if (wrap == MTEX_TUBE) {
745  map_to_tube(area, area + 1, texvec[0], texvec[1], texvec[2]);
746  map_to_tube(
747  area + 2, area + 3, texvec[0] + dxt[0], texvec[1] + dxt[1], texvec[2] + dxt[2]);
748  map_to_tube(
749  area + 4, area + 5, texvec[0] + dyt[0], texvec[1] + dyt[1], texvec[2] + dyt[2]);
750  }
751  else {
752  map_to_sphere(area, area + 1, texvec[0], texvec[1], texvec[2]);
754  area + 2, area + 3, texvec[0] + dxt[0], texvec[1] + dxt[1], texvec[2] + dxt[2]);
756  area + 4, area + 5, texvec[0] + dyt[0], texvec[1] + dyt[1], texvec[2] + dyt[2]);
757  }
758  areaflag = 1;
759  }
760  else {
761  if (wrap == MTEX_TUBE) {
762  map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
763  }
764  else {
765  map_to_sphere(&fx, &fy, texvec[0], texvec[1], texvec[2]);
766  }
767  dxt[0] /= 2.0f;
768  dxt[1] /= 2.0f;
769  dyt[0] /= 2.0f;
770  dyt[1] /= 2.0f;
771  }
772  }
773  else {
774 
775  proj = cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
776 
777  if (proj == 1) {
778  SWAP(float, dxt[1], dxt[2]);
779  SWAP(float, dyt[1], dyt[2]);
780  }
781  else if (proj == 2) {
782  float f1 = dxt[0], f2 = dyt[0];
783  dxt[0] = dxt[1];
784  dyt[0] = dyt[1];
785  dxt[1] = dxt[2];
786  dyt[1] = dyt[2];
787  dxt[2] = f1;
788  dyt[2] = f2;
789  }
790 
791  dxt[0] *= 0.5f;
792  dxt[1] *= 0.5f;
793  dxt[2] *= 0.5f;
794 
795  dyt[0] *= 0.5f;
796  dyt[1] *= 0.5f;
797  dyt[2] *= 0.5f;
798  }
799 
800  /* If area, then recalculate `dxt[]` and `dyt[]` */
801  if (areaflag) {
802  fx = area[0];
803  fy = area[1];
804  dxt[0] = area[2] - fx;
805  dxt[1] = area[3] - fy;
806  dyt[0] = area[4] - fx;
807  dyt[1] = area[5] - fy;
808  }
809 
810  /* repeat */
811  if (tex->extend == TEX_REPEAT) {
812  float max = 1.0f;
813  if (tex->xrepeat > 1) {
814  float origf = fx *= tex->xrepeat;
815 
816  /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
817  if (tex->texfilter == TXF_BOX) {
818  if (fx > 1.0f) {
819  fx -= (int)(fx);
820  }
821  else if (fx < 0.0f) {
822  fx += 1 - (int)(fx);
823  }
824 
825  if (tex->flag & TEX_REPEAT_XMIR) {
826  int orig = (int)floor(origf);
827  if (orig & 1) {
828  fx = 1.0f - fx;
829  }
830  }
831  }
832 
833  max = tex->xrepeat;
834 
835  dxt[0] *= tex->xrepeat;
836  dyt[0] *= tex->xrepeat;
837  }
838  if (tex->yrepeat > 1) {
839  float origf = fy *= tex->yrepeat;
840 
841  /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
842  if (tex->texfilter == TXF_BOX) {
843  if (fy > 1.0f) {
844  fy -= (int)(fy);
845  }
846  else if (fy < 0.0f) {
847  fy += 1 - (int)(fy);
848  }
849 
850  if (tex->flag & TEX_REPEAT_YMIR) {
851  int orig = (int)floor(origf);
852  if (orig & 1) {
853  fy = 1.0f - fy;
854  }
855  }
856  }
857 
858  if (max < tex->yrepeat) {
859  max = tex->yrepeat;
860  }
861 
862  dxt[1] *= tex->yrepeat;
863  dyt[1] *= tex->yrepeat;
864  }
865  if (max != 1.0f) {
866  dxt[2] *= max;
867  dyt[2] *= max;
868  }
869  }
870  /* crop */
871  if (tex->cropxmin != 0.0f || tex->cropxmax != 1.0f) {
872  fac1 = tex->cropxmax - tex->cropxmin;
873  fx = tex->cropxmin + fx * fac1;
874  dxt[0] *= fac1;
875  dyt[0] *= fac1;
876  }
877  if (tex->cropymin != 0.0f || tex->cropymax != 1.0f) {
878  fac1 = tex->cropymax - tex->cropymin;
879  fy = tex->cropymin + fy * fac1;
880  dxt[1] *= fac1;
881  dyt[1] *= fac1;
882  }
883 
884  texvec[0] = fx;
885  texvec[1] = fy;
886  }
887 }
888 
889 /* ************************************** */
890 
891 static int multitex(Tex *tex,
892  const float texvec[3],
893  float dxt[3],
894  float dyt[3],
895  int osatex,
896  TexResult *texres,
897  const short thread,
898  const short which_output,
899  struct ImagePool *pool,
900  const bool skip_load_image,
901  const bool texnode_preview,
902  const bool use_nodes)
903 {
904  float tmpvec[3];
905  int retval = 0; /* return value, TEX_INT or TEX_RGB. */
906 
907  texres->talpha = false; /* is set when image texture returns alpha (considered premul) */
908 
909  if (use_nodes && tex->use_nodes && tex->nodetree) {
910  const float cfra = 1.0f; /* This was only set for Blender Internal render before. */
911  retval = ntreeTexExecTree(tex->nodetree,
912  texres,
913  texvec,
914  dxt,
915  dyt,
916  osatex,
917  thread,
918  tex,
919  which_output,
920  cfra,
921  texnode_preview,
922  NULL);
923  }
924  else {
925  switch (tex->type) {
926  case 0:
927  texres->tin = 0.0f;
928  return 0;
929  case TEX_CLOUDS:
930  retval = clouds(tex, texvec, texres);
931  break;
932  case TEX_WOOD:
933  retval = wood(tex, texvec, texres);
934  break;
935  case TEX_MARBLE:
936  retval = marble(tex, texvec, texres);
937  break;
938  case TEX_MAGIC:
939  retval = magic(tex, texvec, texres);
940  break;
941  case TEX_BLEND:
942  retval = blend(tex, texvec, texres);
943  break;
944  case TEX_STUCCI:
945  retval = stucci(tex, texvec, texres);
946  break;
947  case TEX_NOISE:
948  retval = texnoise(tex, texres, thread);
949  break;
950  case TEX_IMAGE:
951  if (osatex) {
952  retval = imagewraposa(
953  tex, tex->ima, NULL, texvec, dxt, dyt, texres, pool, skip_load_image);
954  }
955  else {
956  retval = imagewrap(tex, tex->ima, texvec, texres, pool, skip_load_image);
957  }
958  if (tex->ima) {
960  }
961  break;
962  case TEX_MUSGRAVE:
963  /* newnoise: musgrave types */
964 
965  /* NOTE(@ton): added this, for Blender convention reason.
966  * NOTE(@artificer): added the use of tmpvec to avoid scaling texvec. */
967  copy_v3_v3(tmpvec, texvec);
968  mul_v3_fl(tmpvec, 1.0f / tex->noisesize);
969 
970  switch (tex->stype) {
971  case TEX_MFRACTAL:
972  case TEX_FBM:
973  retval = mg_mFractalOrfBmTex(tex, tmpvec, texres);
974  break;
975  case TEX_RIDGEDMF:
976  case TEX_HYBRIDMF:
977  retval = mg_ridgedOrHybridMFTex(tex, tmpvec, texres);
978  break;
979  case TEX_HTERRAIN:
980  retval = mg_HTerrainTex(tex, tmpvec, texres);
981  break;
982  }
983  break;
984  /* newnoise: voronoi type */
985  case TEX_VORONOI:
986  /* NOTE(@ton): added this, for Blender convention reason.
987  * NOTE(@artificer): added the use of tmpvec to avoid scaling texvec. */
988  copy_v3_v3(tmpvec, texvec);
989  mul_v3_fl(tmpvec, 1.0f / tex->noisesize);
990 
991  retval = voronoiTex(tex, tmpvec, texres);
992  break;
993  case TEX_DISTNOISE:
994  /* NOTE(@ton): added this, for Blender convention reason.
995  * NOTE(@artificer): added the use of tmpvec to avoid scaling texvec. */
996  copy_v3_v3(tmpvec, texvec);
997  mul_v3_fl(tmpvec, 1.0f / tex->noisesize);
998 
999  retval = mg_distNoiseTex(tex, tmpvec, texres);
1000  break;
1001  }
1002  }
1003 
1004  if (tex->flag & TEX_COLORBAND) {
1005  float col[4];
1006  if (BKE_colorband_evaluate(tex->coba, texres->tin, col)) {
1007  texres->talpha = true;
1008  copy_v4_v4(texres->trgba, col);
1009  retval |= TEX_RGB;
1010  }
1011  }
1012  return retval;
1013 }
1014 
1016  const float texvec[3],
1017  float dxt[3],
1018  float dyt[3],
1019  int osatex,
1020  TexResult *texres,
1021  const short thread,
1022  short which_output,
1023  MTex *mtex,
1024  struct ImagePool *pool,
1025  const bool scene_color_manage,
1026  const bool skip_load_image,
1027  const bool texnode_preview,
1028  const bool use_nodes)
1029 {
1030  if (tex == NULL) {
1031  memset(texres, 0, sizeof(TexResult));
1032  return 0;
1033  }
1034 
1035  if (mtex) {
1036  which_output = mtex->which_output;
1037  }
1038 
1039  if (tex->type == TEX_IMAGE) {
1040  int retval;
1041 
1042  if (mtex) {
1043  float texvec_l[3];
1044  copy_v3_v3(texvec_l, texvec);
1045  /* we have mtex, use it for 2d mapping images only */
1046  do_2d_mapping(mtex, texvec_l, NULL, dxt, dyt);
1047  retval = multitex(tex,
1048  texvec_l,
1049  dxt,
1050  dyt,
1051  osatex,
1052  texres,
1053  thread,
1054  which_output,
1055  pool,
1056  skip_load_image,
1057  texnode_preview,
1058  use_nodes);
1059 
1060  if (mtex->mapto & MAP_COL) {
1062 
1063  /* don't linearize float buffers, assumed to be linear */
1064  if (ibuf != NULL && ibuf->rect_float == NULL && (retval & TEX_RGB) && scene_color_manage) {
1066  }
1067 
1069  }
1070  }
1071  else {
1072  /* we don't have mtex, do default flat 2d projection */
1073  MTex localmtex;
1074  float texvec_l[3], dxt_l[3], dyt_l[3];
1075 
1076  localmtex.mapping = MTEX_FLAT;
1077  localmtex.tex = tex;
1078  localmtex.object = NULL;
1079  localmtex.texco = TEXCO_ORCO;
1080 
1081  copy_v3_v3(texvec_l, texvec);
1082  if (dxt && dyt) {
1083  copy_v3_v3(dxt_l, dxt);
1084  copy_v3_v3(dyt_l, dyt);
1085  }
1086  else {
1087  zero_v3(dxt_l);
1088  zero_v3(dyt_l);
1089  }
1090 
1091  do_2d_mapping(&localmtex, texvec_l, NULL, dxt_l, dyt_l);
1092  retval = multitex(tex,
1093  texvec_l,
1094  dxt_l,
1095  dyt_l,
1096  osatex,
1097  texres,
1098  thread,
1099  which_output,
1100  pool,
1101  skip_load_image,
1102  texnode_preview,
1103  use_nodes);
1104 
1105  {
1107 
1108  /* don't linearize float buffers, assumed to be linear */
1109  if (ibuf != NULL && ibuf->rect_float == NULL && (retval & TEX_RGB) && scene_color_manage) {
1111  }
1112 
1114  }
1115  }
1116 
1117  return retval;
1118  }
1119 
1120  return multitex(tex,
1121  texvec,
1122  dxt,
1123  dyt,
1124  osatex,
1125  texres,
1126  thread,
1127  which_output,
1128  pool,
1129  skip_load_image,
1130  texnode_preview,
1131  use_nodes);
1132 }
1133 
1135  const float texvec[3],
1136  float dxt[3],
1137  float dyt[3],
1138  int osatex,
1139  TexResult *texres,
1140  const short thread,
1141  short which_output,
1142  MTex *mtex,
1143  struct ImagePool *pool)
1144 {
1145  return multitex_nodes_intern(tex,
1146  texvec,
1147  dxt,
1148  dyt,
1149  osatex,
1150  texres,
1151  thread,
1152  which_output,
1153  mtex,
1154  pool,
1155  true,
1156  false,
1157  false,
1158  true);
1159 }
1160 
1162  float texvec[3],
1163  float dxt[3],
1164  float dyt[3],
1165  int osatex,
1166  TexResult *texres,
1167  const short thread,
1168  struct ImagePool *pool,
1169  bool scene_color_manage,
1170  const bool skip_load_image)
1171 {
1172  return multitex_nodes_intern(tex,
1173  texvec,
1174  dxt,
1175  dyt,
1176  osatex,
1177  texres,
1178  thread,
1179  0,
1180  NULL,
1181  pool,
1182  scene_color_manage,
1183  skip_load_image,
1184  false,
1185  true);
1186 }
1187 
1189  const float texvec[3],
1190  TexResult *texres,
1191  struct ImagePool *pool,
1192  bool scene_color_manage,
1193  const bool skip_load_image)
1194 {
1195  return multitex_nodes_intern(tex,
1196  texvec,
1197  NULL,
1198  NULL,
1199  0,
1200  texres,
1201  0,
1202  0,
1203  NULL,
1204  pool,
1205  scene_color_manage,
1206  skip_load_image,
1207  false,
1208  false);
1209 }
1210 
1211 /* ------------------------------------------------------------------------- */
1212 
1213 float texture_value_blend(float tex, float out, float fact, float facg, int blendtype)
1214 {
1215  float in = 0.0, facm, col, scf;
1216  int flip = (facg < 0.0f);
1217 
1218  facg = fabsf(facg);
1219 
1220  fact *= facg;
1221  facm = 1.0f - fact;
1222  if (flip) {
1223  SWAP(float, fact, facm);
1224  }
1225 
1226  switch (blendtype) {
1227  case MTEX_BLEND:
1228  in = fact * tex + facm * out;
1229  break;
1230 
1231  case MTEX_MUL:
1232  facm = 1.0f - facg;
1233  in = (facm + fact * tex) * out;
1234  break;
1235 
1236  case MTEX_SCREEN:
1237  facm = 1.0f - facg;
1238  in = 1.0f - (facm + fact * (1.0f - tex)) * (1.0f - out);
1239  break;
1240 
1241  case MTEX_OVERLAY:
1242  facm = 1.0f - facg;
1243  if (out < 0.5f) {
1244  in = out * (facm + 2.0f * fact * tex);
1245  }
1246  else {
1247  in = 1.0f - (facm + 2.0f * fact * (1.0f - tex)) * (1.0f - out);
1248  }
1249  break;
1250 
1251  case MTEX_SUB:
1252  fact = -fact;
1254  case MTEX_ADD:
1255  in = fact * tex + out;
1256  break;
1257 
1258  case MTEX_DIV:
1259  if (tex != 0.0f) {
1260  in = facm * out + fact * out / tex;
1261  }
1262  break;
1263 
1264  case MTEX_DIFF:
1265  in = facm * out + fact * fabsf(tex - out);
1266  break;
1267 
1268  case MTEX_DARK:
1269  in = min_ff(out, tex) * fact + out * facm;
1270  break;
1271 
1272  case MTEX_LIGHT:
1273  col = fact * tex;
1274  if (col > out) {
1275  in = col;
1276  }
1277  else {
1278  in = out;
1279  }
1280  break;
1281 
1282  case MTEX_SOFT_LIGHT:
1283  scf = 1.0f - (1.0f - tex) * (1.0f - out);
1284  in = facm * out + fact * ((1.0f - out) * tex * out) + (out * scf);
1285  break;
1286 
1287  case MTEX_LIN_LIGHT:
1288  if (tex > 0.5f) {
1289  in = out + fact * (2.0f * (tex - 0.5f));
1290  }
1291  else {
1292  in = out + fact * (2.0f * tex - 1.0f);
1293  }
1294  break;
1295  }
1296 
1297  return in;
1298 }
1299 
1300 /* ------------------------------------------------------------------------- */
1301 
1302 bool RE_texture_evaluate(const MTex *mtex,
1303  const float vec[3],
1304  const int thread,
1305  struct ImagePool *pool,
1306  const bool skip_load_image,
1307  const bool texnode_preview,
1308  /* Return arguments. */
1309  float *r_intensity,
1310  float r_rgba[4])
1311 {
1312  Tex *tex;
1313  TexResult texr;
1314  float dxt[3], dyt[3], texvec[3];
1315  int rgb;
1316 
1317  tex = mtex->tex;
1318  if (tex == NULL) {
1319  return 0;
1320  }
1321 
1322  /* placement */
1323  if (mtex->projx) {
1324  texvec[0] = mtex->size[0] * (vec[mtex->projx - 1] + mtex->ofs[0]);
1325  }
1326  else {
1327  texvec[0] = mtex->size[0] * (mtex->ofs[0]);
1328  }
1329 
1330  if (mtex->projy) {
1331  texvec[1] = mtex->size[1] * (vec[mtex->projy - 1] + mtex->ofs[1]);
1332  }
1333  else {
1334  texvec[1] = mtex->size[1] * (mtex->ofs[1]);
1335  }
1336 
1337  if (mtex->projz) {
1338  texvec[2] = mtex->size[2] * (vec[mtex->projz - 1] + mtex->ofs[2]);
1339  }
1340  else {
1341  texvec[2] = mtex->size[2] * (mtex->ofs[2]);
1342  }
1343 
1344  /* texture */
1345  if (tex->type == TEX_IMAGE) {
1346  do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
1347  }
1348 
1349  rgb = multitex(tex,
1350  texvec,
1351  dxt,
1352  dyt,
1353  0,
1354  &texr,
1355  thread,
1356  mtex->which_output,
1357  pool,
1358  skip_load_image,
1359  texnode_preview,
1360  true);
1361 
1362  if (rgb) {
1364  }
1365  else {
1366  copy_v3_fl3(texr.trgba, mtex->r, mtex->g, mtex->b);
1367  }
1368 
1369  *r_intensity = texr.tin;
1370  copy_v4_v4(r_rgba, texr.trgba);
1371 
1372  return (rgb != 0);
1373 }
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)
struct ImBuf * BKE_image_pool_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, struct ImagePool *pool)
void BKE_image_tag_time(struct Image *ima)
General operations, lookup, etc. for materials.
#define ATTR_FALLTHROUGH
MINLINE float min_ff(float a, float b)
#define M_PI
Definition: BLI_math_base.h:20
void map_to_tube(float *r_u, float *r_v, float x, float y, float z)
Definition: math_geom.c:4917
void map_to_sphere(float *r_u, float *r_v, float x, float y, float z)
Definition: math_geom.c:4932
MINLINE void copy_v4_v4(float r[4], const float a[4])
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 copy_v3_fl3(float v[3], float x, float y, float z)
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:1388
float BLI_noise_mg_multi_fractal(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
Definition: noise.c:1329
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:1534
float BLI_noise_mg_variable_lacunarity(float x, float y, float z, float distortion, int nbas1, int nbas2)
Definition: noise.c:1605
float BLI_noise_generic_noise(float noisesize, float x, float y, float z, bool hard, int noisebasis)
Definition: noise.c:1150
void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
Definition: noise.c:914
float BLI_noise_mg_fbm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
Definition: noise.c:1269
void BLI_noise_cell_v3(float x, float y, float z, float r_ca[3])
Definition: noise.c:1128
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:1458
float BLI_noise_generic_turbulence(float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
Definition: noise.c:1207
Random number functions.
void BLI_rng_threaded_free(struct RNG_THREAD_ARRAY *rngarr) ATTR_NONNULL(1)
Definition: rand.cc:251
RNG_THREAD_ARRAY * BLI_rng_threaded_new(void)
Definition: rand.cc:238
int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread) ATTR_WARN_UNUSED_RESULT
Definition: rand.cc:256
#define SWAP(type, a, b)
#define ELEM(...)
#define TEXCO_ORCO
#define MAP_COL
Object is a sort of wrapper for general info.
#define MTEX_LIGHT
#define TEX_RAD
#define MTEX_MUL
#define TEX_SHARPER
#define TEX_REPEAT_YMIR
#define TEX_COLOR
#define TEX_CLOUDS
#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 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_STUCCI
#define TEX_RING
#define TXF_BOX
#define TEX_FBM
#define TEX_MUSGRAVE
#define TEX_MFRACTAL
#define TEX_RGB
#define TEX_HALO
#define TEX_BANDNOISE
#define MTEX_DIFF
#define TEX_EASE
#define MTEX_BLEND
#define TEX_REPEAT_XMIR
#define TEX_DIAG
#define MTEX_SOFT_LIGHT
#define TEX_MARBLE
#define TEX_QUAD
#define TEX_HTERRAIN
#define TEX_SIN
#define MTEX_ADD
#define MTEX_FLAT
#define TEX_NOISESOFT
#define TEX_MAGIC
#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.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise TEX_VORONOI
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture TEX_NOISE
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block TEX_IMAGE
int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, const float co[3], float dxt[3], float dyt[3], int osatex, short thread, const struct Tex *tex, short which_output, int cfra, int preview, struct MTex *mtex)
Definition: thread.h:34
#define sinf(x)
Definition: cuda/compat.h:102
#define cosf(x)
Definition: cuda/compat.h:101
uint nor
uint col
static float turb(float x, float y, float z, int oct, int hard, int nb, float ampscale, float freqscale)
#define atan2f(x, y)
Definition: metal/compat.h:227
#define floorf(x)
Definition: metal/compat.h:224
#define fabsf(x)
Definition: metal/compat.h:219
#define sqrtf(x)
Definition: metal/compat.h:243
static unsigned a[3]
Definition: RandGen.cpp:78
static struct PartialUpdateUser * wrap(PartialUpdateUserImpl *user)
static void area(int d1, int d2, int e1, int e2, float weights[2])
T floor(const T &a)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken rgb("rgb", pxr::TfToken::Immortal)
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:89
float tin
Definition: RE_texture.h:86
float trgba[4]
Definition: RE_texture.h:87
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
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 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, bool skip_load_image)
int imagewrap(struct Tex *tex, struct Image *ima, const float texvec[3], struct TexResult *texres, struct ImagePool *pool, bool skip_load_image)
Definition: texture_image.c:84
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)
static float tex_tri(float a)
static int clouds(const Tex *tex, const float texvec[3], TexResult *texres)
float max