70 texres->
tin = (1.0f +
x) / 2.0f;
73 texres->
tin = (1.0f +
x) / 2.0f;
74 if (texres->
tin < 0.0f) {
78 texres->
tin *= texres->
tin;
82 texres->
tin = (1.0f +
x) / 2.0f;
83 if (texres->
tin <= 0.0f) {
86 else if (texres->
tin >= 1.0f) {
90 t = texres->
tin * texres->
tin;
91 texres->
tin = (3.0f * t - 2.0f * t * texres->
tin);
95 texres->
tin = (2.0f + x +
y) / 4.0f;
101 texres->
tin = 1.0f -
sqrtf(x * x + y * y + texvec[2] * texvec[2]);
102 if (texres->
tin < 0.0f) {
106 texres->
tin *= texres->
tin;
149 texres->
trgba[3] = 1.0;
161 a = 0.5f + 0.5f *
sinf(a);
169 const float b = 2 *
M_PI;
182 const float b = 2 *
M_PI;
183 const float rmax = 1.0;
185 a = rmax - 2.0f *
fabsf(
floorf((a * (1.0f /
b)) + 0.5f) - (a * (1.0f /
b)));
209 wi = waveform[wf]((x + y +
z) * 10.0f);
212 wi = waveform[wf](
sqrtf(x * x + y * y +
z *
z) * 20.0f);
218 wi = waveform[wf]((x + y +
z) * 10.0f + wi);
224 wi = waveform[wf](
sqrtf(x * x + y * y +
z *
z) * 20.0f + wi);
257 n = 5.0f * (x + y +
z);
268 mi = waveform[wf](mi);
301 x =
sinf((texvec[0] + texvec[1] + texvec[2]) * 5.0f);
302 y =
cosf((-texvec[0] + texvec[1] - texvec[2]) * 5.0f);
303 z = -
cosf((-texvec[0] - texvec[1] + texvec[2]) * 5.0f);
308 y = -
cosf(x - y +
z);
317 x = -
cosf(-x + y -
z);
320 y = -
sinf(-x + y +
z);
323 y = -
cosf(-x + y +
z);
332 x = -
cosf(-x - y +
z);
335 y = -
sinf(x - y +
z);
354 texres->
trgba[0] = 0.5f -
x;
355 texres->
trgba[1] = 0.5f -
y;
356 texres->
trgba[2] = 0.5f -
z;
358 texres->
tin = (1.0f / 3.0f) * (texres->
trgba[0] + texres->
trgba[1] + texres->
trgba[2]);
361 texres->
trgba[3] = 1.0f;
395 texres->
tin = 1.0f - texres->
tin;
398 if (texres->
tin < 0.0f) {
504 float sc = (aw1 + aw2 + aw3 + aw4);
516 texres->
trgba[0] = aw1 * ca[0];
517 texres->
trgba[1] = aw1 * ca[1];
518 texres->
trgba[2] = aw1 * ca[2];
520 texres->
trgba[0] += aw2 * ca[0];
521 texres->
trgba[1] += aw2 * ca[1];
522 texres->
trgba[2] += aw2 * ca[2];
524 texres->
trgba[0] += aw3 * ca[0];
525 texres->
trgba[1] += aw3 * ca[1];
526 texres->
trgba[2] += aw3 * ca[2];
528 texres->
trgba[0] += aw4 * ca[0];
529 texres->
trgba[1] += aw4 * ca[1];
530 texres->
trgba[2] += aw4 * ca[2];
532 float t1 = (da[1] - da[0]) * 10;
542 texres->
trgba[0] *= t1;
543 texres->
trgba[1] *= t1;
544 texres->
trgba[2] *= t1;
547 texres->
trgba[0] *= sc;
548 texres->
trgba[1] *= sc;
549 texres->
trgba[2] *= sc;
555 texres->
trgba[3] = 1.0;
569 int val, ran, loop, shift = 29;
576 val = ((ran >> shift) & 3);
580 val *= ((ran >> shift) & 3);
592static int cubemap_glob(
const float n[3],
float x,
float y,
float z,
float *adr1,
float *adr2)
594 float x1, y1, z1,
nor[3];
610 if (z1 >= x1 && z1 >= y1) {
611 *adr1 = (x + 1.0f) / 2.0f;
612 *adr2 = (y + 1.0f) / 2.0f;
615 else if (y1 >= x1 && y1 >= z1) {
616 *adr1 = (x + 1.0f) / 2.0f;
617 *adr2 = (
z + 1.0f) / 2.0f;
621 *adr1 = (y + 1.0f) / 2.0f;
622 *adr2 = (
z + 1.0f) / 2.0f;
631 const MTex *mtex,
float texvec[3],
const float n[3],
float dxt[3],
float dyt[3])
634 float fx, fy, fac1, area[8];
635 int ok, proj, areaflag = 0,
wrap;
644 fx = (texvec[0] + 1.0f) / 2.0f;
645 fy = (texvec[1] + 1.0f) / 2.0f;
648 map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
654 cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
665 else if (fx < 0.0f) {
682 else if (fy < 0.0f) {
710 fx = (texvec[0] + 1.0f) / 2.0f;
711 fy = (texvec[1] + 1.0f) / 2.0f;
722 if (texvec[1] <= 0.0f) {
723 fx = texvec[0] + dxt[0];
724 fy = texvec[0] + dyt[0];
725 if (fx >= 0.0f && fy >= 0.0f && texvec[0] >= 0.0f) {
728 else if (fx <= 0.0f && fy <= 0.0f && texvec[0] <= 0.0f) {
738 map_to_tube(area, area + 1, texvec[0], texvec[1], texvec[2]);
740 area + 2, area + 3, texvec[0] + dxt[0], texvec[1] + dxt[1], texvec[2] + dxt[2]);
742 area + 4, area + 5, texvec[0] + dyt[0], texvec[1] + dyt[1], texvec[2] + dyt[2]);
745 map_to_sphere(area, area + 1, texvec[0], texvec[1], texvec[2]);
747 area + 2, area + 3, texvec[0] + dxt[0], texvec[1] + dxt[1], texvec[2] + dxt[2]);
749 area + 4, area + 5, texvec[0] + dyt[0], texvec[1] + dyt[1], texvec[2] + dyt[2]);
755 map_to_tube(&fx, &fy, texvec[0], texvec[1], texvec[2]);
768 proj =
cubemap_glob(n, texvec[0], texvec[1], texvec[2], &fx, &fy);
771 std::swap(dxt[1], dxt[2]);
772 std::swap(dyt[1], dyt[2]);
774 else if (proj == 2) {
775 float f1 = dxt[0], f2 = dyt[0];
797 dxt[0] = area[2] - fx;
798 dxt[1] = area[3] - fy;
799 dyt[0] = area[4] - fx;
800 dyt[1] = area[5] - fy;
814 else if (fx < 0.0f) {
839 else if (fy < 0.0f) {
885 const float texvec[3],
891 const short which_output,
893 const bool skip_load_image,
894 const bool texnode_preview,
895 const bool use_nodes)
903 const float cfra = 1.0f;
926 retval =
wood(
tex, texvec, texres);
932 retval =
magic(
tex, texvec, texres);
935 retval =
blend(
tex, texvec, texres);
946 tex,
tex->
ima,
nullptr, texvec, dxt, dyt, texres, pool, skip_load_image);
1009 const float texvec[3],
1018 const bool scene_color_manage,
1019 const bool skip_load_image,
1020 const bool texnode_preview,
1021 const bool use_nodes)
1023 if (
tex ==
nullptr) {
1070 float texvec_l[3], dxt_l[3], dyt_l[3];
1074 localmtex.
object =
nullptr;
1134 const float texvec[3],
1161 const float texvec[3],
1168 bool scene_color_manage,
1169 const bool skip_load_image)
1188 const float texvec[3],
1191 bool scene_color_manage,
1192 const bool skip_load_image)
1214 float in = 0.0, facm,
col, scf;
1215 int flip = (facg < 0.0f);
1222 std::swap(fact, facm);
1225 switch (blendtype) {
1227 in = fact *
tex + facm * out;
1232 in = (facm + fact *
tex) * out;
1237 in = 1.0f - (facm + fact * (1.0f -
tex)) * (1.0f - out);
1243 in = out * (facm + 2.0f * fact *
tex);
1246 in = 1.0f - (facm + 2.0f * fact * (1.0f -
tex)) * (1.0f - out);
1254 in = fact *
tex + out;
1259 in = facm * out + fact * out /
tex;
1264 in = facm * out + fact *
fabsf(
tex - out);
1268 in =
min_ff(out,
tex) * fact + out * facm;
1282 scf = 1.0f - (1.0f -
tex) * (1.0f - out);
1283 in = facm * out + fact * ((1.0f - out) *
tex * out) + (out * scf);
1288 in = out + fact * (2.0f * (
tex - 0.5f));
1291 in = out + fact * (2.0f *
tex - 1.0f);
1305 const bool skip_load_image,
1306 const bool texnode_preview,
1313 float dxt[3], dyt[3], texvec[3];
1317 if (
tex ==
nullptr) {
1323 texvec[0] = mtex->
size[0] * (vec[mtex->
projx - 1] + mtex->
ofs[0]);
1326 texvec[0] = mtex->
size[0] * (mtex->
ofs[0]);
1330 texvec[1] = mtex->
size[1] * (vec[mtex->
projy - 1] + mtex->
ofs[1]);
1333 texvec[1] = mtex->
size[1] * (mtex->
ofs[1]);
1337 texvec[2] = mtex->
size[2] * (vec[mtex->
projz - 1] + mtex->
ofs[2]);
1340 texvec[2] = mtex->
size[2] * (mtex->
ofs[2]);
1368 *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 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)
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)
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], ColorSpace *colorspace)
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
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)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
ccl_device_inline float2 floor(const float2 a)
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)
Frequency::GEOMETRY nor[]
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)
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)
static float tex_sin(float a)
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, const MTex *mtex, ImagePool *pool)
static int mg_mFractalOrfBmTex(const Tex *tex, const float texvec[3], TexResult *texres)
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)
static RNG_THREAD_ARRAY * random_tex_array
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, const MTex *mtex, ImagePool *pool, const bool scene_color_manage, const bool skip_load_image, const bool texnode_preview, const bool use_nodes)
static float tex_saw(float a)
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)
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 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, ImagePool *pool, const bool skip_load_image, const bool texnode_preview, const bool use_nodes)
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], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, ImagePool *pool, bool scene_color_manage, const bool skip_load_image)
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)