Code improvements + Mix node #30

Merged
Bogdan Nagirniak merged 18 commits from BogdanNagirniak/blender:matx-code-improvements into matx-export-material 2023-09-22 18:23:13 +02:00
Showing only changes of commit 14a381c024 - Show all commits

View File

@ -135,9 +135,9 @@ class WaveFunction : public mf::MultiFunction {
MutableSpan<float> r_fac = params.uninitialized_single_output<float>(8, "Fac");
mask.foreach_index([&](const int64_t i) {
float3 pos = vector[i] * scale[i];
float3 p = vector[i] * scale[i];
/* Prevent precision issues on unit coordinates. */
pos = (pos + 0.000001f) * 0.999999f;
p = (p + 0.000001f) * 0.999999f;
float n = 0.0f;
float val = 0.0f;
@ -146,21 +146,21 @@ class WaveFunction : public mf::MultiFunction {
case SHD_WAVE_BANDS:
switch (bands_direction_) {
case SHD_WAVE_BANDS_DIRECTION_X:
n = pos.x * 20.0f;
n = p.x * 20.0f;
break;
case SHD_WAVE_BANDS_DIRECTION_Y:
n = pos.y * 20.0f;
n = p.y * 20.0f;
break;
case SHD_WAVE_BANDS_DIRECTION_Z:
n = pos.z * 20.0f;
n = p.z * 20.0f;
break;
case SHD_WAVE_BANDS_DIRECTION_DIAGONAL:
n = (pos.x + pos.y + pos.z) * 10.0f;
n = (p.x + p.y + p.z) * 10.0f;
break;
}
break;
case SHD_WAVE_RINGS:
float3 rp = pos;
float3 rp = p;
switch (rings_direction_) {
case SHD_WAVE_RINGS_DIRECTION_X:
rp *= float3(0.0f, 1.0f, 1.0f);
@ -183,7 +183,7 @@ class WaveFunction : public mf::MultiFunction {
if (distortion[i] != 0.0f) {
n += distortion[i] *
(noise::perlin_fractal(pos * dscale[i], detail[i], droughness[i], 2.0f, true) * 2.0f -
(noise::perlin_fractal(p * dscale[i], detail[i], droughness[i], 2.0f, true) * 2.0f -
1.0f);
}