67 texres->
tin = (1.0f +
x) / 2.0f;
70 texres->
tin = (1.0f +
x) / 2.0f;
71 if (texres->
tin < 0.0f) {
75 texres->
tin *= texres->
tin;
79 texres->
tin = (1.0f +
x) / 2.0f;
80 if (texres->
tin <= 0.0f) {
83 else if (texres->
tin >= 1.0f) {
87 t = texres->
tin * texres->
tin;
88 texres->
tin = (3.0f * t - 2.0f * t * texres->
tin);
92 texres->
tin = (2.0f +
x +
y) / 4.0f;
98 texres->
tin = 1.0f -
sqrtf(
x *
x +
y *
y + texvec[2] * texvec[2]);
99 texres->
tin = std::max(texres->
tin, 0.0f);
101 texres->
tin *= texres->
tin;
144 texres->
trgba[3] = 1.0;
156 a = 0.5f + 0.5f *
sinf(a);
164 const float b = 2 *
M_PI;
177 const float b = 2 *
M_PI;
178 const float rmax = 1.0;
180 a = rmax - 2.0f *
fabsf(
floorf((a * (1.0f /
b)) + 0.5f) - (a * (1.0f /
b)));
192 short wt = tex->
stype;
204 wi = waveform[wf]((
x +
y +
z) * 10.0f);
207 wi = waveform[wf](
sqrtf(
x *
x +
y *
y +
z *
z) * 20.0f);
213 wi = waveform[wf]((
x +
y +
z) * 10.0f + wi);
219 wi = waveform[wf](
sqrtf(
x *
x +
y *
y +
z *
z) * 20.0f + wi);
229 texres->
tin =
wood_int(tex, texvec[0], texvec[1], texvec[2]);
241 short mt = tex->
stype;
252 n = 5.0f * (
x +
y +
z);
263 mi = waveform[wf](mi);
279 texres->
tin =
marble_int(tex, texvec[0], texvec[1], texvec[2]);
296 x =
sinf((texvec[0] + texvec[1] + texvec[2]) * 5.0f);
297 y =
cosf((-texvec[0] + texvec[1] - texvec[2]) * 5.0f);
298 z = -
cosf((-texvec[0] - texvec[1] + texvec[2]) * 5.0f);
349 texres->
trgba[0] = 0.5f -
x;
350 texres->
trgba[1] = 0.5f -
y;
351 texres->
trgba[2] = 0.5f -
z;
353 texres->
tin = (1.0f / 3.0f) * (texres->
trgba[0] + texres->
trgba[1] + texres->
trgba[2]);
356 texres->
trgba[3] = 1.0f;
376 ofs = tex->
turbul / 200.0f;
390 texres->
tin = 1.0f - texres->
tin;
393 texres->
tin = std::max(texres->
tin, 0.0f);
497 float sc = (aw1 + aw2 + aw3 + aw4);
509 texres->
trgba[0] = aw1 * ca[0];
510 texres->
trgba[1] = aw1 * ca[1];
511 texres->
trgba[2] = aw1 * ca[2];
513 texres->
trgba[0] += aw2 * ca[0];
514 texres->
trgba[1] += aw2 * ca[1];
515 texres->
trgba[2] += aw2 * ca[2];
517 texres->
trgba[0] += aw3 * ca[0];
518 texres->
trgba[1] += aw3 * ca[1];
519 texres->
trgba[2] += aw3 * ca[2];
521 texres->
trgba[0] += aw4 * ca[0];
522 texres->
trgba[1] += aw4 * ca[1];
523 texres->
trgba[2] += aw4 * ca[2];
525 float t1 = (da[1] - da[0]) * 10;
526 t1 = std::min<float>(t1, 1);
533 texres->
trgba[0] *= t1;
534 texres->
trgba[1] *= t1;
535 texres->
trgba[2] *= t1;
538 texres->
trgba[0] *= sc;
539 texres->
trgba[1] *= sc;
540 texres->
trgba[2] *= sc;
546 texres->
trgba[3] = 1.0;
560 int val, ran, loop, shift = 29;
567 val = ((ran >> shift) & 3);
571 val *= ((ran >> shift) & 3);
583static int cubemap_glob(
const float n[3],
float x,
float y,
float z,
float *adr1,
float *adr2)
585 float x1, y1, z1,
nor[3];
601 if (z1 >= x1 && z1 >= y1) {
602 *adr1 = (
x + 1.0f) / 2.0f;
603 *adr2 = (
y + 1.0f) / 2.0f;
606 else if (y1 >= x1 && y1 >= z1) {
607 *adr1 = (
x + 1.0f) / 2.0f;
608 *adr2 = (
z + 1.0f) / 2.0f;
612 *adr1 = (
y + 1.0f) / 2.0f;
613 *adr2 = (
z + 1.0f) / 2.0f;
634 fx = (texvec[0] + 1.0f) / 2.0f;
635 fy = (texvec[1] + 1.0f) / 2.0f;
638 map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
644 cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
650 float origf = fx *= tex->
xrepeat;
655 else if (fx < 0.0f) {
660 int orig = int(
floor(origf));
667 float origf = fy *= tex->
yrepeat;
672 else if (fy < 0.0f) {
677 int orig = int(
floor(origf));
702 const float texvec[3],
705 const short which_output,
707 const bool skip_load_image,
708 const bool texnode_preview,
709 const bool use_nodes)
717 const float cfra = 1.0f;
719 tex->
nodetree, texres, texvec,
thread, tex, which_output, cfra, texnode_preview,
nullptr);
727 retval =
clouds(tex, texvec, texres);
730 retval =
wood(tex, texvec, texres);
733 retval =
marble(tex, texvec, texres);
736 retval =
magic(tex, texvec, texres);
739 retval =
blend(tex, texvec, texres);
742 retval =
stucci(tex, texvec, texres);
748 retval =
imagewrap(tex, tex->
ima, texvec, texres, pool, skip_load_image);
761 switch (tex->
stype) {
807 const float texvec[3],
813 const bool scene_color_manage,
814 const bool skip_load_image,
815 const bool texnode_preview,
816 const bool use_nodes)
818 if (tex ==
nullptr) {
866 localmtex.
object =
nullptr;
912 const float texvec[3],
920 tex, texvec, texres,
thread, which_output, mtex, pool,
true,
false,
false,
true);
924 const float texvec[3],
928 bool scene_color_manage,
929 const bool skip_load_image)
945 const float texvec[3],
948 bool scene_color_manage,
949 const bool skip_load_image)
952 tex, texvec, texres, 0, 0,
nullptr, pool, scene_color_manage, skip_load_image,
false,
false);
959 float in = 0.0, facm, scf;
960 int flip = (facg < 0.0f);
967 std::swap(fact, facm);
972 in = fact * tex + facm *
out;
977 in = (facm + fact * tex) *
out;
982 in = 1.0f - (facm + fact * (1.0f - tex)) * (1.0f -
out);
988 in =
out * (facm + 2.0f * fact * tex);
991 in = 1.0f - (facm + 2.0f * fact * (1.0f - tex)) * (1.0f -
out);
999 in = fact * tex +
out;
1004 in = facm *
out + fact *
out / tex;
1021 scf = 1.0f - (1.0f - tex) * (1.0f -
out);
1022 in = facm *
out + fact * ((1.0f -
out) * tex *
out) + (
out * scf);
1027 in =
out + fact * (2.0f * (tex - 0.5f));
1030 in =
out + fact * (2.0f * tex - 1.0f);
1044 const bool skip_load_image,
1045 const bool texnode_preview,
1056 if (tex ==
nullptr) {
1062 texvec[0] = mtex->
size[0] * (vec[mtex->
projx - 1] + mtex->
ofs[0]);
1065 texvec[0] = mtex->
size[0] * (mtex->
ofs[0]);
1069 texvec[1] = mtex->
size[1] * (vec[mtex->
projy - 1] + mtex->
ofs[1]);
1072 texvec[1] = mtex->
size[1] * (mtex->
ofs[1]);
1076 texvec[2] = mtex->
size[2] * (vec[mtex->
projz - 1] + mtex->
ofs[2]);
1079 texvec[2] = mtex->
size[2] * (mtex->
ofs[2]);
1104 *r_intensity = texr.
tin;
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
void BKE_image_tag_time(Image *ima)
ImBuf * BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool)
void BKE_image_pool_release_ibuf(Image *ima, ImBuf *ibuf, ImagePool *pool)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
bool map_to_sphere(float *r_u, float *r_v, float x, float y, float z)
bool map_to_tube(float *r_u, float *r_v, float x, float y, float z)
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)
float BLI_noise_mg_hetero_terrain(float x, float y, float z, float H, float lacunarity, float octaves, float offset, int noisebasis)
float BLI_noise_mg_multi_fractal(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
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)
float BLI_noise_mg_variable_lacunarity(float x, float y, float z, float distortion, int nbas1, int nbas2)
float BLI_noise_generic_noise(float noisesize, float x, float y, float z, bool hard, int noisebasis)
void BLI_noise_voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
float BLI_noise_mg_fbm(float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
void BLI_noise_cell_v3(float x, float y, float z, float r_ca[3])
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)
float BLI_noise_generic_turbulence(float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
void BLI_rng_threaded_free(struct RNG_THREAD_ARRAY *rngarr) ATTR_NONNULL(1)
RNG_THREAD_ARRAY * BLI_rng_threaded_new(void)
int BLI_rng_thread_rand(RNG_THREAD_ARRAY *rngarr, int thread) ATTR_WARN_UNUSED_RESULT
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], const ColorSpace *colorspace)
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, const float co[3], short thread, const struct Tex *tex, short which_output, int cfra, int preview, struct MTex *mtex)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
static float turb(float x, float y, float z, int oct, int hard, int nb, float ampscale, float freqscale)
float wrap(float value, float max, float min)
const ColorSpace * colorspace
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
struct bNodeTree * nodetree
int imagewrap(struct Tex *tex, struct Image *ima, const float texvec[3], struct TexResult *texres, struct ImagePool *pool, 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 stucci(const Tex *tex, const float texvec[3], TexResult *texres)
static int voronoiTex(const Tex *tex, const float texvec[3], TexResult *texres)
static RNG_THREAD_ARRAY * random_tex_array
static float tex_saw(float a)
static int multitex_nodes_intern(Tex *tex, const float texvec[3], TexResult *texres, const short thread, short which_output, const MTex *mtex, ImagePool *pool, const bool scene_color_manage, const bool skip_load_image, const bool texnode_preview, const bool use_nodes)
static int mg_distNoiseTex(const Tex *tex, const float texvec[3], TexResult *texres)
static int multitex(Tex *tex, const float texvec[3], TexResult *texres, const short thread, const short which_output, ImagePool *pool, const bool skip_load_image, const bool texnode_preview, const bool use_nodes)
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()
static int mg_HTerrainTex(const Tex *tex, const float texvec[3], TexResult *texres)
bool RE_texture_evaluate(const MTex *mtex, const float vec[3], const int thread, ImagePool *pool, const bool skip_load_image, const bool texnode_preview, float *r_intensity, float r_rgba[4])
static void do_2d_mapping(const MTex *mtex, float texvec[3], const float n[3])
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, const float texvec[3], TexResult *texres, const short thread, ImagePool *pool, bool scene_color_manage, const bool skip_load_image)
int multitex_nodes(Tex *tex, const float texvec[3], TexResult *texres, const short thread, short which_output, const MTex *mtex, ImagePool *pool)
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()
int multitex_ext_safe(Tex *tex, const float texvec[3], TexResult *texres, ImagePool *pool, bool scene_color_manage, const bool skip_load_image)
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)